Sending Twist Messages to a Real Robot

本文介绍如何使用ROS命令启动TurtleBot机器人并控制其移动。通过roslaunch启动后,利用rostopic pub命令发送速度指令到/cmd_vel_mux/主题,实现对TurtleBot的导航与安全控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

实际使用的是kobuki 底座的turtlebot机器人,之前没有看资料,使用

roslaunch turtlebot_bringup minimal.launch

测试(提示音)通过后,查看rostopic list,发现有好多运行的节点,其中有

/cmd_vel_mux/的几个topic。

如:

cmd_vel_mux/input/navi

cmd_vel_mux/input/safety_controller

然后通过

rostopic type /cmd_vel_mux/input/navi

rostopic type /cmd_vel_mux/input/safety_controller

其格式均为:  geometry/Twist

因此可用如下指令来控制实际的turtlebot

rostopic pub -r 10 /cmd_vel_mux/safety_controller geometry_msgs/Twist '{linear: {x: 0, y: 0,z: 0}, angular: {x: 0, y: 0, z: 1.0}}'

rostopic pub -r 10 /cmd_vel_mux/navi geometry_msgs/Twist '{linear: {x: 0, y: 0,z: 0}, angular: {x: 0, y: 0, z: 1.0}}'

转载于:https://www.cnblogs.com/siahekai/p/5840321.html

xiaoyuan@ubuntu:~/diffusion_policy_graspping/src/arm_control/scripts$ python hdx_robot_socket1.py ===== 初始化机械臂 ===== Port /dev/ttyUSB0 HDX_ARM link success Port /dev/ttyUSB0 Open Success Port /dev/ttyUSB1 HDX_ARM link success Port /dev/ttyUSB1 Open Success ===== 启动客户端 ===== Client connected to port 15558 Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. Idle state. Press 'a' to start sending messages. State changed to ACTING ===== 执行 #0 ===== 当前关节角度: [254.07692308 39.28571429 17.18681319 291.57142857 119.63736264 75.06593407] 发送观察数据 #0, 数据大小: 1843224 bytes 发送成功! 耗时: 0.0005s 等待服务器响应... 接收超时,重试中... ===== 执行 #0 ===== 当前关节角度: [254.07692308 39.28571429 17.18681319 291.57142857 119.63736264 75.06593407] 发送观察数据 #0, 数据大小: 1843224 bytes 执行过程中出错: Operation cannot be accomplished in current state Traceback (most recent call last): File "hdx_robot_socket1.py", line 474, in handle_acting self.socket.send(message) File "/home/xiaoyuan/.local/lib/python3.8/site-packages/zmq/sugar/socket.py", line 698, in send return super().send(data, flags=flags, copy=copy, track=track) File "zmq/backend/cython/_zmq.py", line 1137, in zmq.backend.cython._zmq.Socket.send File "zmq/backend/cython/_zmq.py", line 1185, in zmq.backend.cython._zmq.Socket.send File "zmq/backend/cython/_zmq.py", line 1458, in zmq.backend.cython._zmq._send_copy File "zmq/backend/cython/_zmq.py", line 1453, in zmq.backend.cython._zmq._send_copy File "zmq/backend/cython/_zmq.py", line 187, in zmq.backend.cython._zmq._check_rc zmq.error.ZMQError: Operation cannot be accomplished in current state ===== 执行 #0 ===== 当前关节角度: [254.07692308 39.28571429 17.18681319 291.57142857 119.63736264 75.06593407] 发送观察数据 #0, 数据大小: 1843224 bytes 执行过程中出错: Operation cannot be accomplished in current state Traceback (most recent call last): File "hdx_robot_socket1.py", line 474, in handle_acting self.socket.send(message) File "/home/xiaoyuan/.local/lib/python3.8/site-packages/zmq/sugar/socket.py", line 698, in send return super().send(data, flags=flags, copy=copy, track=track) File "zmq/backend/cython/_zmq.py", line 1137, in zmq.backend.cython._zmq.Socket.send File "zmq/backend/cython/_zmq.py", line 1185, in zmq.backend.cython._zmq.Socket.send File "zmq/backend/cython/_zmq.py", line 1458, in zmq.backend.cython._zmq._send_copy File "zmq/backend/cython/_zmq.py", line 1453, in zmq.backend.cython._zmq._send_copy File "zmq/backend/cython/_zmq.py", line 187, in zmq.backend.cython._zmq._check_rc zmq.error.ZMQError: Operation cannot be accomplished in current state 执行 #0 失败,达到最大重试次数 Task finished 开始清理资源... 客户端关闭完成 程序退出
最新发布
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值