ROS2命令速查

初学ROS2, 很多命令背不住,常用到的放一起备查备忘

0 安装

用小鱼的一键安装:

wget http://fishros.com/install -O fishros && . Fishros

1 package related

1.1 select package build

colcon build --packages-select packageName

1.2 Show installed ros2 packages

ros2 pkg list | grep navigation2

1.3 install dependency

rosdep install --from-paths src --ignore-src -r -y

1.4 Create new package

cd ~/dev_ws/src 
ros2 pkg create --build-type ament_python package_name

or

ros2 pkg create --build-type ament_cmake package_name

2 node related

ros2 node info node_name

3 TF related

3.1 View TF tree

ros2 run tf2_tools view_frames

(save to a pdf file)

3.2 publish static TF base_link to laser_link

ros2 run tf2_ros static_transform_publisher 0.58 0 0.58 0 0 0 base_link laser_link

语法:ros2 run tf2_ros static_transform_publisher --x 0 --y 0 --z 1 --yaw 0 --pitch 0 --roll 0 --frame-id world --child-frame-id mystaticturtle

3.3 publish static TF base_footprint to base_link

ros2 run tf2_ros static_transform_publisher 0 0 0.01 0 0 0 base_footprint base_link

3.4 check tf

ros2 run tf2_ros tf2_echo [reference_frame] [target_frame]

3.5 publish tf in launch file

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():

    ld = LaunchDescription()
    node = Node(package = "tf2_ros",
                       executable = "static_transform_publisher",
                       arguments = ["0 0 0 0 0 0 odom laser"])
    ld.add_action(node)

    return ld

4 topic related

4.1 show topics

ros2 topic list
ros2 topic info /tf_static
ros2 topic echo topicname

4.2 echo a specify field of some topic

$ ros2 topic echo  /velodyne_points --field header

4.3 Record Ros2 msg/topic

ros2 bag record -a

-a means all topics

ros2 bag info
ros2 bag play

4.4 publish topic

ros2 topic pub --once topic_name topic_type  "{ var1 : value1, var2 : value2}"

–once 表示发布一次,–rate 1 表示每秒发一次

5 Service related

5.1 service call

ros2 service call service_name service_type "{var:value}"

e.g.

ros2 service call /lifecycle_manager_navigation/is_active std_srvs/srv/Trigger “{timeout:3}

查询Navigation服务是否active状态,参数设置为3秒超时

6 Parameter related

6.1 ros2 param list

6.2 set parameter

ros2 param set <node_name> <parameter_name> <value>

6.3 get parameter

ros2 param get <node_name>  <parameter_name>

6.4 dump and load

ros2 param dump <node_name>
ros2 run <package_name> <executable_name> --ros-args --params-file <file_name>

7 Action related

ros2 action list
ros2 action list -t
ros2 action info action_name
ros2 interface show turtlesim/action/RotateAbsolute.action
ros2 action send_goal <action_name> <action_type> <values>

8 Nav2 related

8.1 copy default Nav2 parameters

cp /opt/ros/ROS_DISTRO/share/nav2_bringup/params/nav2_params.yaml src/fishbot_navigation2/config

8.2 Easy Slam Tool

ros2 launch slam_toolbox online_async_launch.py

8.3 Save map to file

ros2 run nav2_map_server map_saver_cli -t map -f filename

8.4 keyboard twist node

ros2 run teleop_twist_keyboard teleop_twist_keyboard 

Interface related

ros2 interface list
ros2 interface show interface_name
ros2 interface  proto interface_name
ros2 interface package package_name
ros2 interface packaes interface_name

10 Tools

rqt_graph

rqt

11 Ubuntu Cmds

11.1 Install offline package

sudo dpkg -i Sxssw.deb
or
sudo apt-get install ./tx4.deb

11.2 kill node in ros2

ros2 node list
killall <node_name_from_nodes_list>

——————————
需要500关注,拜托点个关注,谢谢

  • 43
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

code .

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

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

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

打赏作者

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

抵扣说明:

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

余额充值