紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
6.2.3章节通过参数修改model参数报错格式不对
-
运行报错:
tingbo@DESKTOP-NHH5E05:~/chapt6/chapt6_ws$ ros2 launch fishbot_description display_robot.launch.py model :=/home/tingbo/chapt6/chapt6_ws/src/fishbot_description/urdf/first_robot.urdf.xacro malformed launch argument 'model', expected format '<name>:=<value>' tingbo@DESKTOP-NHH5E05:~/chapt6/chapt6_ws$ ros2 launch fishbot_description display_robot.launch.py model := /home/tingbo/chapt6/chapt6_ws/src/fishbot_description/ urdf/first_robot.urdf.xacro malformed launch argument 'model', expected format '<name>:=<value>' tingbo@DESKTOP-NHH5E05:~/chapt6/chapt6_ws$ ros2 launch fishbot_description display_robot.launch.py <model> : = </home/tingbo/chapt6/chapt6_ws/src/fishbot_descripti on/urdf/first_robot.urdf.xacro> bash: 未预期的记号 "newline" 附近有语法错误
-
@43996173
display_robot.launch.py代码:import launch import launch_ros from ament_index_python.packages import get_package_share_directory def generate_launch_description(): urdf_tutorial_path = get_package_share_directory('fishbot_description') default_model_path = urdf_tutorial_path + '/urdf/first_robot.urdf' #print (str(default_model_path)) default_rviz_config_path = urdf_tutorial_path + '/config/rviz/display_model.rviz' action_declare_arg_mode_path = launch.actions.DeclareLaunchArgument( name='model', default_value=str(default_model_path), description='URDF的绝对路径') robot_description=launch_ros.parameter_descriptions.ParameterValue( launch.substitutions.Command( ['xacro ', launch.substitutions.LaunchConfiguration('model')]), value_type=str) robot_state_publisher_node = launch_ros.actions.Node ( package='robot_state_publisher', executable='robot_state_publisher', parameters=[{'robot_description':robot_description}]) joint_state_publisher_node = launch_ros.actions.Node( package='joint_state_publisher', executable='joint_state_publisher', ) rviz_node = launch_ros.actions.Node( package='rviz2', executable='rviz2', arguments=['-d', default_rviz_config_path] ) return launch.LaunchDescription([ action_declare_arg_mode_path, joint_state_publisher_node, robot_state_publisher_node, rviz_node ])
first_robot.urdf.xacro代码:
<?xml version="1.0"?> <robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="first_robot"> <!--声明base模块--> <xacro:macro name="base_link" params="length radius"> <link name="base_link"> <visual> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <cylinder radius="${length}" length="${length}"/> </geometry> <material name="white"> <color rgba="1.0 1.0 1.0 0.5"/> </material> </visual> </link> </xacro:macro> <!--声明imu模块--> <xacro:macro name="imu_link" params="imu_name xyz"> <link name="${imu_name}_link"> <visual> <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/> <geometry> <box size="0.02 0.02 0.02"/> </geometry> </visual> <material name="black"> <color rgba="0.0 0.0 0.0 0.5"/> </material> </link> <joint name="${imu_name}_joint" type="fixed"> <parent link="base_link"/> <child link="${imu_name}_link"/> <origin xyz="${xyz}"/> </joint> </xacro:macro> <!--传递参数调用base_link模块--> <xacro:base_link length="0.12" radius="0.1"/> <!--传递参数调用imu模块--> <xacro:imu_link imu_name="imu_up" xyz="0 0 0.02" /> <xacro:imu_link imu_name="imu_down" xyz="0.0 0.0 -0.02" /> </robot>