一 背景:
最近测试一款机器人,发布速度指令50HZ,
rostopic pub -r 50 /rotation_cmd_vel geometry_msgs/Twist "linear:
x: 0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.0"
但结束bash或wifi停掉后,机器人就停下了。
二:失败方法:
后来试过用如下指令
rostopic pub -r 50 /rotation_cmd_vel geometry_msgs/Twist "linear:
x: 0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0" &
&就是后台运行的意思,但发现结束bash或停掉wifi后,机器人还是停下了。
后来,发现通过用nohup结合shell脚本可以实现。
三:最终方法
1:新建一个shell脚本,如:auto.sh,通过vim或gedit输入:
rostopic pub -r 50 /rotation_cmd_vel geometry_msgs/Twist "linear:
x: 0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0"
2:然后 给shell添加执行权限 sudo chmod +x ./auto.sh
3:后台运行指令: nohup ./auto.sh &