【ROS2】solidworks2021导出IRB52机器人的urdf,导入到coppeliasim和RViz2

4 篇文章 1 订阅
3 篇文章 0 订阅

原文链接 【ROS2】solidworks2021导出IRB52机器人的urdf,导入到coppeliasim和RViz2

原文有视频演示。本文无。

图片

Solidworks中机器人模型

图片

urdf导入到Coppeliasim-截图

图片

urdf在RViz2中显示-截图

笔记

一、下载机器人模型 

    从网络上(https://new.abb.com/products/robotics/zh/industrial-robots/irb-52)下载的ABB机器人step格式模型,solidworks加载后得到SLDASM文件,之后,对模型进行“解散子装配体”、“生成新子装配体”、“浮动”、“重命名树项目”一系列操作。

图片

二、Solidworks导出urdf注意事项

     对于相对复杂的串联机械臂,需要创建每个关节的转轴(参考几何体-基准轴),导出urdf时,设置关节位置和关节转轴方向可以先自动生成,第一次导出可能失败,这时候就需要自己指定参考坐标系和参考轴。可以利用第一次导出urdf生成的参考坐标系和参考轴,也可以自己建立关节转轴和关节位置坐标系。

图片

图片

三、导出urdf后处理

      导出的urdf可以通过插件URDF import导入到coppeliasim。对其增加非线程脚本和操作球、target\tip ,设置关节属性后,就可以演示了。

图片

图片

    但是要想在RViz2中显示,就有点麻烦。最新的urdf导出插件生成的包符合ROS1中使用的格式,但是要想在ROS2中使用需要做很多修改。

urdf导出包时记得修改包名。本例为irb52_urdf。将包拷贝到Ubuntu20.04系统中自己已创建的ROS2工作空间中,本例为“~/ws_moveit2/src”。

修改CMakeLists.txt,改为如下内容:

cmake_minimum_required(VERSION 3.5)project(irb52_urdf)
# Default to C99if(NOT CMAKE_C_STANDARD)  set(CMAKE_C_STANDARD 99)endif()
# Default to C++14if(NOT CMAKE_CXX_STANDARD)  set(CMAKE_CXX_STANDARD 14)endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")  add_compile_options(-Wall -Wextra -Wpedantic)endif()
# find dependenciesfind_package(ament_cmake REQUIRED)# uncomment the following section in order to fill in# further dependencies manually.# find_package(<dependency> REQUIRED)
if(BUILD_TESTING)  find_package(ament_lint_auto REQUIRED)  # the following line skips the linter which checks for copyrights  # uncomment the line when a copyright and license is not present in all source files  #set(ament_cmake_copyright_FOUND TRUE)  # the following line skips cpplint (only works in a git repo)  # uncomment the line when this package is not in a git repo  #set(ament_cmake_cpplint_FOUND TRUE)  ament_lint_auto_find_test_dependencies()endif()

install(DIRECTORY  meshes urdf textures config launch rviz   DESTINATION share/${PROJECT_NAME}/)ament_package()

修改package.xml​​​​​​​

<?xml version="1.0"?><?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?><package format="3">  <name>irb52_urdf</name>  <version>0.1.0</version>  <description>IRB52_URDF</description>  <maintainer email="chenxiaoyong0016@126.com">cxy</maintainer>  <license>BSD</license>
  <buildtool_depend>ament_cmake</buildtool_depend>
  <test_depend>ament_lint_auto</test_depend>  <test_depend>ament_lint_common</test_depend>
  <exec_depend>joint_state_publisher</exec_depend>  <exec_depend>joint_state_publisher_gui</exec_depend>  <exec_depend>robot_state_publisher</exec_depend>  <exec_depend>rviz2</exec_depend>  <exec_depend>xacro</exec_depend>  <export>    <build_type>ament_cmake</build_type>  </export></package>

新建launch目录,在其内新建文件display.launch.py,写入内容:​​​​​​​

import osfrom ament_index_python.packages import get_package_share_directoryfrom launch import LaunchDescriptionfrom launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescriptionfrom launch.conditions import IfConditionfrom launch.launch_description_sources import PythonLaunchDescriptionSourcefrom launch.substitutions import LaunchConfiguration, PythonExpressionfrom launch_ros.actions import Node
def generate_launch_description():    # Get the launch directory    bringup_dir = get_package_share_directory('irb52_urdf')    launch_dir = os.path.join(bringup_dir, 'launch')
    # Launch configuration variables specific to simulation    rviz_config_file = LaunchConfiguration('rviz_config_file')    use_robot_state_pub = LaunchConfiguration('use_robot_state_pub')    use_joint_state_pub = LaunchConfiguration('use_joint_state_pub')    use_rviz = LaunchConfiguration('use_rviz')    urdf_file= LaunchConfiguration('urdf_file')        declare_rviz_config_file_cmd = DeclareLaunchArgument(        'rviz_config_file',        default_value=os.path.join(bringup_dir, 'rviz', 'urdf.rviz'),        description='Full path to the RVIZ config file to use')      declare_use_robot_state_pub_cmd = DeclareLaunchArgument(        'use_robot_state_pub',        default_value='True',        description='Whether to start the robot state publisher')    declare_use_joint_state_pub_cmd = DeclareLaunchArgument(        'use_joint_state_pub',        default_value='True',        description='Whether to start the joint state publisher')    declare_use_rviz_cmd = DeclareLaunchArgument(        'use_rviz',        default_value='True',        description='Whether to start RVIZ')
    declare_urdf_cmd = DeclareLaunchArgument(        'urdf_file',        default_value=os.path.join(bringup_dir, 'urdf', 'irb52_urdf.urdf'),        description='Whether to start RVIZ') 
    start_robot_state_publisher_cmd = Node(        condition=IfCondition(use_robot_state_pub),        package='robot_state_publisher',        executable='robot_state_publisher',        name='robot_state_publisher',        output='screen',        #parameters=[{'use_sim_time': use_sim_time}],        arguments=[urdf_file])        start_joint_state_publisher_cmd = Node(        condition=IfCondition(use_joint_state_pub),        package='joint_state_publisher_gui',        executable='joint_state_publisher_gui',        name='joint_state_publisher_gui',        output='screen',        arguments=[urdf_file])        rviz_cmd = Node(        condition=IfCondition(use_rviz),        package='rviz2',        executable='rviz2',        name='rviz2',        arguments=['-d', rviz_config_file],        output='screen')              # Create the launch description and populate    ld = LaunchDescription()
    # Declare the launch options    ld.add_action(declare_rviz_config_file_cmd)    ld.add_action(declare_urdf_cmd)    ld.add_action(declare_use_robot_state_pub_cmd)    ld.add_action(declare_use_joint_state_pub_cmd)    ld.add_action(declare_use_rviz_cmd)

    # Add any conditioned actions    ld.add_action(start_joint_state_publisher_cmd)    ld.add_action(start_robot_state_publisher_cmd)    ld.add_action(rviz_cmd)
    return ld   

新建rviz目录,目录内新建urdf.rviz文件,内容如下:​​​​​​​

Panels:  - Class: rviz_common/Displays    Name: Displays  - Class: rviz_common/Views    Name: ViewsVisualization Manager:  Class: ""  Displays:    - Class: rviz_default_plugins/Grid      Name: Grid      Value: true    - Alpha: 0.8      Class: rviz_default_plugins/RobotModel      Description Source: Topic      Description Topic:        Value: /robot_description      Enabled: true      Name: RobotModel      Value: true    - Class: rviz_default_plugins/TF      Name: TF      Value: true  Global Options:    Fixed Frame: base_link    Frame Rate: 30  Name: root  Tools:    - Class: rviz_default_plugins/MoveCamera  Value: true  Views:    Current:      Class: rviz_default_plugins/Orbit      Distance: 1.7      Name: Current View      Pitch: 0.33      Value: Orbit (rviz)      Yaw: 5.5Window Geometry:  Height: 800  Width: 1200

三、ros2指令-构建和安装,获取安装,启动demo​​​​​​​

cxy@ubuntu:~/ws_moveit2$colcon build --packages-select irb52_urdfcxy@ubuntu:~/ws_moveit2$ . install/local_setup.bashcxy@ubuntu:~/ws_moveit2$ ros2 launch irb52_urdf display.launch.py

运行后,修改透明度

图片

参考:

https://github.com/ros/urdf_tutorial/tree/ros2 

https://index.ros.org/packages/#foxy

https://new.abb.com/products/robotics/zh/

https://new.abb.com/products/robotics/zh/industrial-robots/irb-52

https://wiki.ros.org/sw_urdf_exporter

https://github.com/benbongalon/ros2-urdf-tutorial/blob/master/urdf_tutorial/README.md

  • 6
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
操作流程如下: 1. 在SolidWorks中,安装插件SolidWorks to URDF Exporter,该插件可以将SolidWorks模型导出为URDF(Universal Robot Description Format)文件。 2. 在导出URDF文件之前,需要为SolidWorks模型添加必要的约束和关节,以便在URDF文件中正确表示模型的运动。可以使用SolidWorks中的“运动学”选项卡来添加这些约束和关节。 3. 使用SolidWorks to URDF Exporter插件导出URDF文件。在导出时,请确保选择正确的选项以保证URDF文件的正确性。 4. 在ROS2中,使用ROS2 URDF parser将URDF文件转换为ROS2中的格式。可以使用以下命令来安装ROS2 URDF parser: ``` sudo apt-get install ros-<distro>-urdfdom-py ``` 其中,<distro>是ROS2的发行版名称,例如“foxy”或“galactic”。 5. 将URDF文件转换为ROS2格式。使用以下命令将URDF文件转换为ROS2格式: ``` ros2 run robot_state_publisher robot_state_publisher /path/to/urdf/file ``` 其中,“/path/to/urdf/file”是URDF文件的路径。 6. 启动ROS2节点,以便可以使用ROS2控制机器人模型。可以使用以下命令来启动ROS2节点: ``` ros2 run <node_name> ``` 其中,“<node_name>”是要启动的ROS2节点的名称。 7. 使用ROS2中的控制器来控制机器人模型的运动。可以使用ROS2中的控制器来控制模型的运动,例如使用ROS2的JointStateController来控制机器人模型的关节状态。 以上就是SolidWorks导出URDF导入ROS2的操作流程。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值