ros笔记——Ros命令行

一、常用命令

  • rostopic
  • rosservice
  • rosnode
  • rosparam
  • rosmsg
  • rossrv

二、ros小海龟背后剖析

roscore
rosrun <package name> <node name>
rosrun turtlesim turtlesim_node

#可以查看当前系统节点的关系及通讯
rqt_graph
#打印Ros Node的信息
rosnode
#打印Ros topic信息
rostopic

Commands:
	rostopic bw	display bandwidth used by topic
	rostopic delay	display delay of topic from timestamp in header
	rostopic echo	print messages to screen
	rostopic find	find topics by type
	rostopic hz	display publishing rate of topic    
	rostopic info	print information about active topic
	rostopic list	list active topics
	rostopic pub	publish data to topic
	rostopic type	print topic or field type

小tip:双击tab键可以补全内容

rostopic pub <topic name> <message>
message:<message name> <message struct> <message context>


rostopic pub /turtle1/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" 
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -h
Usage: rostopic pub /topic type [args...]

Options:
  -h, --help            show this help message and exit
  -v                    print verbose output
  -r RATE, --rate=RATE  publishing rate (hz).  For -f and stdin input, this
                        defaults to 10.  Otherwise it is not set.
  -1, --once            publish one message and exit
  -f FILE, --file=FILE  read args from YAML file (Bagy)
  -l, --latch           enable latching for -f, -r and piped input.  This
                        latches the first message.
  -s, --substitute-keywords
                        When publishing with a rate, performs keyword ('now'
                        or 'auto') substitution for each message
  --use-rostime         use rostime for time stamps, else walltime is used
ll@ll-ThinkPad-P15-Gen-1:~$ rosservice
Commands:
	rosservice args	print service arguments
	rosservice call	call the service with the provided args
	rosservice find	find services by service type
	rosservice info	print information about service
	rosservice list	list active services
	rosservice type	print service type
	rosservice uri	print service ROSRPC uri

Type rosservice <command> -h for more detailed usage, e.g. 'rosservice call -h'

ll@ll-ThinkPad-P15-Gen-1:~$ rosservice call /spawn "x: 5.0
y: 5.0
theta: 0.0
name: 'tur2'" 
name: "tur2"
ll@ll-ThinkPad-P15-Gen-1:~$ rosservice call /spawn "x: 6.0
y: 6.0
theta: 0.0
name: 'tur3'" 
name: "tur3"

ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist "linear:
  x: 3.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 1.0" 
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 5 /tur2/cmd_vel geometry_msgs/Twist "linear:
  x: -5.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 1.57" 
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 12 /tur3/cmd_vel geometry_msgs/Twist "linear:
  x: 0.0
  y: 9.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 2.0" 

三、rosbag命令

rosbag用于记录当前执行的所有数据

记录当前数据并保存到压缩包内

rosbag record -a -O <bag name>

 执行保存的包名

rosbag play <bag name>

注意:rosservice的内容未保存

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_ZhouTao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值