ROS2进阶:基本指令与RVIZ2介绍

基于windows的ROS2。

在学习ROS的时候,你很可能已经习惯了这个

rosrun rviz rviz

而在ROS2,你只需要直接输入

rviz2

就可以了。

一些基本指令

你可以通过ros2 --help查询所有的的指令,

D:\>ros2 --help
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...

ros2 is an extensible command-line tool for ROS 2.

optional arguments:
  -h, --help            show this help message and exit

Commands:
  action     Various action related sub-commands
  bag        Various rosbag related sub-commands
  component  Various component related sub-commands
  daemon     Various daemon related sub-commands
  doctor     Check ROS setup and other potential issues
  interface  Show information about ROS interfaces
  launch     Run a launch file
  lifecycle  Various lifecycle related sub-commands
  multicast  Various multicast related sub-commands
  node       Various node related sub-commands
  param      Various param related sub-commands
  pkg        Various package related sub-commands
  run        Run a package specific executable
  security   Various security related sub-commands
  service    Various service related sub-commands
  test       Run a ROS2 launch test
  topic      Various topic related sub-commands
  trace      Trace ROS nodes to get information on their execution
  wtf        Use `wtf` as alias to `doctor`

  Call `ros2 <command> -h` for more detailed usage.

其中有些指令是极常用的,以turtlesim的教学为例,官方开始连续几章教学的主要内容包含的指令大致罗列如下,

ros2 node list
ros2 node info /turtlesim
ros2 node info /teleop_turtle

ros2 topic list
ros2 topic echo <topic_name>
ros2 topic echo /turtle1/cmd_vel
ros2 topic echo /turtle1/pose
ros2 topic hz /turtle1/pose   #注:hz表示频率
ros2 topic info /turtle1/cmd_vel
ros2 interface show geometry_msgs/msg/Twist
ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"
ros2 topic pub --rate 1 /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"

ros2 service list
ros2 service type /clear
ros2 service list -t
ros2 service find <type_name>
ros2 service find std_srvs/srv/Empty
ros2 interface show std_srvs/srv/Empty
ros2 interface show turtlesim/srv/Spawn
ros2 service call <service_name> <service_type> <arguments>
ros2 service call /clear std_srvs/srv/Empty
ros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}"

ros2 param list
ros2 param get <node_name> <parameter_name>
ros2 param get /turtlesim background_g
ros2 param set <node_name> <parameter_name> <value>
ros2 param set /turtlesim background_r 150
ros2 param dump <node_name>
ros2 param dump /turtlesim  #这在当前目录下会生成一个叫turtlesim.yaml的文件
ros2 param load <node_name> <parameter_file>
ros2 param load /turtlesim ./turtlesim.yaml
ros2 run turtlesim turtlesim_node --ros-args --params-file ./turtlesim.yaml

ros2 action list
ros2 action list -t #注:-t 表示type
ros2 action info /turtle1/rotate_absolute
ros2 interface show turtlesim/action/RotateAbsolute
ros2 action send_goal <action_name> <action_type> <values>
ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: 1.57}"
ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: -1.57}" --feedback

ROS在官网上对这些指令有详细的介绍,因为很简单,所以这里也不重复。

RVIZ2

未完待续

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值