无法通过Teleop与键盘控制TurtleBot3移动,如何让Gazebo GUI订阅cmd_vel?
解决TurtleBot3在Gazebo中无法响应/cmd_vel的问题
1. 确认话题订阅状态
- 打开终端执行
rostopic list,确认/cmd_vel话题存在。 - 执行
rostopic info /cmd_vel,查看订阅者列表。如果看不到/gazebo或turtlebot3_diff_drive_controller类节点,说明控制器未正确关联。
2. 重新启动标准启动文件
TurtleBot3官方launch文件会自动加载控制器并完成话题订阅,停止当前所有节点后,运行对应模型的启动命令:
# 以Burger模型为例,其他模型替换为waffle/waffle_pi roslaunch turtlebot3_gazebo turtlebot3_world.launch model:=burger
3. 手动加载差速驱动控制器(自动启动失败时)
如果上述launch文件未加载控制器,单独启动控制器管理器:
rosrun controller_manager controller_manager spawner turtlebot3_diff_drive_controller
启动后再次用rostopic info /cmd_vel检查,应能看到控制器节点已订阅该话题。
4. 手动验证速度指令
用以下命令手动发布速度指令,测试机器人是否响应:
rostopic pub /cmd_vel geometry_msgs/Twist "linear: {x: 0.2, y: 0.0, z: 0.0} angular: {x: 0.0, y: 0.0, z: 0.0}" -r 10
如果机器人移动,说明Teleop节点可能存在配置问题;如果仍不动,检查URDF中的驱动插件配置。
5. 检查URDF中的驱动插件配置
确认turtlebot3_description包的URDF文件中,差速驱动插件是否正确配置了cmd_vel话题:
<plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so"> <rosDebugLevel>Debug</rosDebugLevel> <publishWheelTF>true</publishWheelTF> <robotNamespace>/</robotNamespace> <publishTf>1</publishTf> <publishWheelJointState>true</publishWheelJointState> <alwaysOn>true</alwaysOn> <updateRate>100.0</updateRate> <leftJoint>wheel_left_joint</leftJoint> <rightJoint>wheel_right_joint</rightJoint> <wheelSeparation>0.160</wheelSeparation> <wheelDiameter>0.066</wheelDiameter> <torque>10</torque> <commandTopic>cmd_vel</commandTopic> <odometryTopic>odom</odometryTopic> <odometryFrame>odom</odometryFrame> <robotBaseFrame>base_footprint</robotBaseFrame> </plugin>
确保<commandTopic>cmd_vel</commandTopic>存在且路径正确。
内容的提问来源于stack exchange,提问作者Niescte
相关产品推荐
相关产品推荐

