赞
踩
在foxy版本下运行ros2_control遇到的问题,最终没有做成。换humble后可行,建议换版本
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"],
)
[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
yaml文件第x行缺少东西,或者缩进格式有问题
[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.
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",
},
)
)
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
[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]
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] <<<
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)
[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>
[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
原因为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, # 为节点设置命名空间
)
# 为相应节点传递参数,节点名设置必须对 /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
sudo apt install gdb
gdb -arg <cmd>
gdb -arg gzserver -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so
(gdb) r
(gdb) bt
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。