基于ros2的lerobot urdf构建

📅 2026/7/10 9:32:51
基于ros2的lerobot urdf构建
一、导入源代码与原仓库原网站https://github.com/brukg/SO-100-arm由于我打算边学习moveit和VLA我这边就只取这里的urdf文件完成以后将urdf放进cmakelist中 然后构建看看效果二、完成以后写launch文件尝试用rviz来 打开这个东西yysy launch文件不是很熟 所以我这里就手把手带大家敲一次吧 顺便我也巩固一下一python的launch文件1.搭建框架import launch import launch_ros import os from launch import LaunchDescription def generate_launch_description(): return LaunchDescription([])2.导入urdf文件import launch import launch_ros import os from launch import LaunchDescription from ament_index_python.packages import get_package_share_directory def generate_launch_description(): package_pathos.path.join(get_package_share_directory(description_lerobot)) urdf_pathos.path.join(package_path,urdf,so_arm_100_5dof_arm.urdf.xacro) return LaunchDescription([])3.利用xacro来解析import launch import launch_ros import os from launch import LaunchDescription from ament_index_python.packages import get_package_share_directory def generate_launch_description(): package_pathos.path.join(get_package_share_directory(description_lerobot)) urdf_pathos.path.join(package_path,urdf,so_arm_100_5dof_arm.urdf.xacro) description_lerobotCommand([xacro,urdf_path]) return LaunchDescription([])4.写关节发布器与rviz2import launch import launch_ros import os from launch import LaunchDescription from ament_index_python.packages import get_package_share_directory def generate_launch_description(): package_pathos.path.join(get_package_share_directory(description_lerobot)) urdf_pathos.path.join(package_path,urdf,so_arm_100_5dof_arm.urdf.xacro) description_lerobotCommand([xacro,urdf_path]) robot_state_publisherNode( packagesrobot_state_publisher executablerobot_state_publisher parameters[{robot_description:description_lerobot}] outputscreen ) rviz2Node( packagesrviz2 executablerviz2 ) return LaunchDescription([ robot_state_publisher, rviz2 ])5.完善包和环境import launch from launch_ros.actions import Node import os from launch import LaunchDescription from launch.substitution import Command from ament_index_python.packages import get_package_share_directory def generate_launch_description(): package_pathos.path.join(get_package_share_directory(description_lerobot)) urdf_pathos.path.join(package_path,urdf,so_arm_100_5dof_arm.urdf.xacro) description_lerobotCommand([xacro,urdf_path]) robot_state_publisherNode( packagesrobot_state_publisher, executablerobot_state_publisher, parameters[{robot_description:description_lerobot}], outputscreen ) rviz2Node( packagesrviz2, executablerviz2 ) return LaunchDescription([ robot_state_publisher, rviz2 ])6.发现有好多问题 不想搞了 直接放完整版吧import launch from launch_ros.actions import Node import os from launch import LaunchDescription from launch.substitutions import Command from ament_index_python.packages import get_package_share_directory from launch_ros.parameter_descriptions import ParameterValue def generate_launch_description(): package_pathget_package_share_directory(description_lerobot) urdf_pathos.path.join(package_path, urdf, so_arm_100_5dof.urdf.xacro) rviz_configos.path.join(package_path, rviz, lerobot_rviz.rviz) xacro_cmd Command([ xacro , urdf_path, use_sim:false ]) description_lerobot ParameterValue(xacro_cmd, value_typestr) robot_state_publisherNode( packagerobot_state_publisher, executablerobot_state_publisher, parameters[{robot_description:description_lerobot}], outputscreen ) joint_state_publisherNode( packagejoint_state_publisher, executablejoint_state_publisher, ) rviz2Node( packagerviz2, executablerviz2, arguments[-d,rviz_config] ) return LaunchDescription([ robot_state_publisher, joint_state_publisher, rviz2 ])(二)xml格式?xml version1.0 launch let namelerobot_description value$(command xacro $(find-pkg-share description_lerobot)/urdf/so_arm_100_5dof.urdf.xacro use_sim:$(var use_sim)) / node pkgrobot_state_publisher executablerobot_state_publisher ourputscreen param namerobot_state_publisher value$(var lerobot_description) /node node pkgjoint_state_publisher execjoint_state_publisher outputscreen / node pkgrviz2 execrviz2 outputscreen args-d $(find-pkg-share description_lerobot)/rviz/lerobot_rviz.rviz / /launch /launch