初学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关注,拜托点个关注,谢谢