当前位置:   article > 正文

[ros2]多机器人实现遇到的坑_ros2多机器人

ros2多机器人

ros2_control 问题汇总 foxy版本

在foxy版本下运行ros2_control遇到的问题,最终没有做成。换humble后可行,建议换版本

1. launch.substitutions.substitution_failure.SubstitutionFailure: executable ‘spawner’ not found on the libexec directory ‘/opt/ros/foxy/lib/controller_manager’

spawner —> spawner.py

joint_state_broadcaster_spawner = Node(
	package="controller_manager",
	executable="spawner.py",
	namespace=robot_name,
	arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"],
)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
2. 参数加载失败
[ros2_control_node-7] [ERROR] [1713539936.796875546] [rcl]: Failed to parse global arguments
[ros2_control_node-7] terminate called after throwing an instance of 'rclcpp::exceptions::RCLInvalidROSArgsError'
[ros2_control_node-7]   what():  failed to initialize rcl: Couldn't parse params file: '--params-file /home/xianzhou/DRLN_ws/install/models/share/models/config/omni_robot.yaml'. 
Error: No value at line 6, at /tmp/binarydeb/ros-foxy-rcl-yaml-param-parser-1.1.14/src/parse.c:204, at /tmp/binarydeb/ros-f	oxy-rcl-1.1.14/src/rcl/arguments.c:388
  • 1
  • 2
  • 3
  • 4

yaml文件第x行缺少东西,或者缩进格式有问题

3.缺少描述文件
[ros2_control_node-7] terminate called after throwing an instance of 'std::runtime_error'
[ros2_control_node-7]   what():  Unable to initialize resource manager, no robot description found.
  • 1
  • 2
launch_description.append(
    Node(
        package="controller_manager",
        executable="ros2_control_node",
        namespace=robot_name,
        parameters=[
        	{'robot_description': robot_description_config.toxml()},#添加描述文件
        	robot_controllers
        ],
        output={
            "stdout": "screen",
            "stderr": "screen",
        },
    )
)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
4. 意外遇到的后面没出现了(foxy)
ros2_control_node-7] terminate called after throwing an instance of 'pluginlib::LibraryLoadException'
[ros2_control_node-7]   what():  According to the loaded plugin descriptions the class 
gazebo_ros2_control/GazeboSystem with base class type hardware_interface::SystemInterface does not exist. 
Declared types are  fake_components/GenericSystem test_hardware_components/TestSystemCommandModes test_hardware_components/TestTwoJointSystem test_system
  • 1
  • 2
  • 3
  • 4
5. 未解决(foxy)
[gzserver-6] [ERROR] [1713614217.814968537] [robot_0.gazebo_ros2_control]: gazebo_ros2_control plugin is waiting for model URDF in parameter [] on the ROS param server.
[gzserver-6] [ERROR] [1713614217.916295512] [robot_0.gazebo_ros2_control]: expected [string] got [not set]
  • 1
  • 2
6. rviz启动报错:create_subscription() …(humble)
User
[rviz2-8] >>> [rcutils|error_handling.c:108] rcutils_set_error_state()
[rviz2-8] This error state is being overwritten:
[rviz2-8] 
[rviz2-8]   'create_subscription() called for existing topic name rt/parameter_events with incompatible type std_msgs::msg::dds_::String_, at ./src/subscription.cpp:146, at ./src/rcl/subscription.c:109'
[rviz2-8] 
[rviz2-8] with this new error message:
[rviz2-8] 
[rviz2-8]   'invalid allocator, at ./src/rcl/subscription.c:219'
[rviz2-8] 
[rviz2-8] rcutils_reset_error() should be called after error handling to avoid this.
[rviz2-8] <<<
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
         rviz = Node(
            package='rviz2',
            executable='rviz2',
            name='rviz2',
            output='log',
            arguments=['-d', rviz_file],
        )
        
         # 必须延后启动不然回报错
        rviz_event_handler = RegisterEventHandler(
            event_handler=OnProcessExit(
                target_action=omnidirectional_controller,
                on_exit=[rviz]
            )
        )
        
        launch_description.append(rviz_event_handler) 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
7. gazebo服务异常关闭(humble)

[ERROR] [gzserver-4]: process has died [pid 219008, exit code -11, cmd 'gzserver -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so']

code -11意思是访问了不存在的堆栈

<plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control">
                <robot_param>robot_description</robot_param>
                <robot_param_node>robot_state_publisher</robot_param_node>
                <!-- namespace会自动为订阅的话题和服务添加前缀,所以不需要单独写在<robot_param>里 !!! 花了我4天时间啊啊啊啊啊啊-->
                    <ros>
                        <namespace>${robot_name}</namespace>
                    </ros>
                <parameters>$(find models)/config/omni_robot.yaml</parameters>
            </plugin>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
8. joint_state_broadcaster没有发布joint_state话题
9. omnidirectional_controller节点未启动
10. 与问题8.9为同一问题
[gzserver-3] [WARN] [1713782716.562010716] [robot_0.controller_manager]: 'update_rate' parameter not set, using default value.
[gzserver-3] [ERROR] [1713782716.564438340] [robot_0.gazebo_ros2_control]: controller manager doesn't have an update_rate parameter
  • 1
  • 2

原因为yaml文件设置有问题,修改为下:

            joint_state_broadcaster_spawner = Node(
                package="controller_manager",
                executable="spawner",
                arguments=["joint_state_broadcaster"],	# 启动控制器,节点名为 /namespace/joint_state_broadcaster
                namespace=robot_name,  # 为节点设置命名空间
            )
            
            omni_base_controller_spawner = Node(
                package="controller_manager",
                executable="spawner",
                arguments=["omnidirectional_controller"],# 启动控制器,节点名为 /namespace/omnidirectional_controller
                namespace=robot_name,  # 为节点设置命名空间
            )
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • yaml设置
# 为相应节点传递参数,节点名设置必须对
/axebot_0/controller_manager:
  ros__parameters:
    update_rate: 20  # Hz
    use_sim_time: true

    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster

    omnidirectional_controller:
      type: omnidirectional_controllers/OmnidirectionalController

/axebot_0/omnidirectional_controller:
  ros__parameters:
    wheel_names: 
      - wheel1_joint
      - wheel2_joint
      - wheel3_joint

    robot_radius: 0.1
    wheel_radius: 0.053112205
    gamma: 30.0 # angle between body fixed y axis and the normal of wheel3

    publish_rate: 50.0
    odom_frame_id: odom
    base_frame_id: base_link
    pose_covariance_diagonal : [0.001, 0.001, 0.001, 0.001, 0.001, 0.01]
    twist_covariance_diagonal: [0.001, 0.001, 0.001, 0.001, 0.001, 0.01]
    odom_numeric_integration_method: runge_kutta2

    open_loop: false
    enable_odom_tf: true

    cmd_vel_timeout: 0.5
    use_stamped_vel: false

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36

调试方法

1. 使用backward_ros高亮错误
2. 使用gdb检查出错的文件
  1. install
    sudo apt install gdb
  2. 使用gdb
    gdb -arg <cmd>
    e.g. 使用gdb启动gazebo的服务端
    gdb -arg gzserver -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so
  3. 输入r并回车运行文件
    (gdb) r
  4. 遇到报错会输出堆栈信息,输入bt并回车输出详情
    (gdb) bt
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号