您当前的位置: 首页 > 
  • 0浏览

    0关注

    483博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

高精度计算机视觉 发布时间:2022-03-24 22:35:24 ,浏览量:0

基于windows的ROS2。

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

rosrun rviz rviz

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

rviz2

就可以了。

一些基本指令

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

D:\>ros2 --help
usage: ros2 [-h] Call `ros2  -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  -h` for more detailed usage.

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

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

ros2 topic list
ros2 topic echo 
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 
ros2 service find std_srvs/srv/Empty
ros2 interface show std_srvs/srv/Empty
ros2 interface show turtlesim/srv/Spawn
ros2 service call   
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  
ros2 param get /turtlesim background_g
ros2 param set   
ros2 param set /turtlesim background_r 150
ros2 param dump 
ros2 param dump /turtlesim  #这在当前目录下会生成一个叫turtlesim.yaml的文件
ros2 param load  
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   
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

未完待续

关注
打赏
1661664439
查看更多评论
立即登录/注册

微信扫码登录

0.0391s