当前位置:网站首页>[1] Basic knowledge of ros2 - summary version of operation commands
[1] Basic knowledge of ros2 - summary version of operation commands
2022-07-07 13:31:00 【Plum fruit tea】
List of articles
This article is mainly about the previously used ROS2 Instructions are summarized , Convenient for subsequent reference . It mainly includes : Function pack 、 node 、 topic of conversation 、 service 、 action 、 Parameters 、launch、ros2 bag Wait for the operation order .
1. Function pack
# 1. Create a workspace
mkdir -p test_ws/src
cd test_ws/src
# 2. Create Feature Pack
ros2 pkg create <package-name> --build-type {
cmake,ament_cmake,ament_python} --dependencies < Rely on names >
# 3. Compile function packs
colcon build --packages-select <package-name>
# 4. List all feature packs
ros2 pkg list
# 5. List the executable files under the function package
ros2 pkg executables turtlesim
# 6. List the path of the Feature Pack
ros2 pkg prefix turtlesim
# 7. List the description file of the function package
ros2 pkg xml turtlesim
Detailed link :[3] ROS2 How to use the function pack
2. node
# ros2 run Function pack name Executable name
ros2 run <package_name> <executable_name>
# View all node names
ros2 node list
# View node information
ros2 node info /turtlesim
# Node remapping
ros2 run turtlesim turtlesim_node --ros-args --remap __node:=my_turtle
Detailed link :[4] ROS2 How to use the node of preliminary exploration
3. topic of conversation
# 1. Check the list of topics
ros2 topic list
# 2. View a list of topics with type attribute suffixes
ros2 topic list -t
# 3. Check the topic content ros2 topic echo <topic_name>
ros2 topic echo /turtle1/cmd_vel
# 4. Check the topic info
ros2 topic info /turtle1/cmd_vel
# 5. View the data structure of the topic message , coordination ros2 topic list -t Use
ros2 interface show /geometry_msgs/msg/Twist
# 6. Check the frequency of topic Publishing
ros2 topic hz /turtle1/cmd_vel
# 7. Post topic news ros2 topic pub <topic_name> <msg_type> '<args>'
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}}"
# Use the plug-in to view the relationship between topics
rqt_graph
Detailed link :[5] ROS2 A preliminary study of communication mechanism ( topic of conversation )
4. service
# 1. View the list of services
ros2 service list
# 2. Check the service interface type
ros2 service type /add_two_ints
# 3. Find a service that uses an interface
ros2 service find example_interfaces/srv/AddTwoInts
# 4. Call service interface
ros2 service call /add_two_ints example_interfaces/srv/AddTwoInts "{a: 5,b: 10}"
Detailed link :[7] ROS2 A preliminary study of communication mechanism ( service )
5. action
# 1. see Action list
ros2 action list
# 2. see Action list +Action type
ros2 action list -t
# 3. Check the interface information
ros2 interface show [Action type ]
# 4. see Action Information
ros2 action info [Action name ]
# Action Request the server to send data
ros2 action send_goals [Action name ] [Action type ] [valus] --feedback
Detailed link :[10] ROS2 A preliminary study of communication mechanism ( action )
6. Parameters
# 1. View the parameter list of all nodes
ros2 param list
# 2. View the details of a parameter
ros2 param describe <node_name> <param_name>
# 3. Get the direct of the parameter
ros2 param get <node_name> <param_name>
# 4. Set the value of the parameter ( Temporary modification )
ros2 param set <node_name> <parameter_name> <value>
# 5. First set Set the parameter value , Again dump Save parameter file (yaml Format )
ros2 param dump <node_name>
# 6. Load the call parameter file
ros2 param load <node_name> <file_name>
# 7. Load the call parameter file when starting the node
ros2 run <package_name> <executable_name> --ros-args --params-file <file_name>
Detailed link :[12] ROS2 A preliminary study of communication mechanism ( Parameters )
7. launch Templates
# stay ROS2 in , commonly launch The file suffix format is name_launch.py perhaps name.launch.py
touch my_script_launch.py
gedit my_script_launch.py
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='turtlesim',
namespace='turtlesim1',
executable='turtlesim_node',
name='sim'
),
Node(
package='turtlesim',
namespace='turtlesim2',
executable='turtlesim_node',
name='sim'
),
Node(
package='turtlesim',
executable='mimic',
name='mimic',
remappings=[
('/input/pose', '/turtlesim1/turtle1/pose'),
('/output/cmd_vel', '/turtlesim2/turtle1/cmd_vel'),
]
)
])
Detailed link :[14] ROS2 Probe into node management tools launch file
8. ros2 bag
# 1. Record topic messages
ros2 bag record <topic_name>
# 2. Record multiple topic messages
ros2 bag record -o <file_dir_name> <topic_name_1> <topic_name_2>...<topic_name_n>
# 3. Record all topic messages
ros2 bag record -a
# 4. View the topic data record file information ( For example, the time of topic recording , size , type , Number )
ros2 bag info <file_dir_name>
# 5. Play the recorded topic data
ros2 bag play <file_dir_name>
# 6. Loop through the recorded topic data
ros2 bag play <file_dir_name> -l
# 7. Speed up (2 Double speed )
ros2 bag play <file_dir_name> -r 2
# 8. Play the data of the specified topic
ros2 bag play <file_dir_name> --topic <topic_name>
Detailed link :[15] ROS2 The data of recording topics ros2 bag
边栏推荐
- Cinnamon Applet 入门
- MySQL入门尝鲜
- MySQL error 28 and solution
- 分布式事务解决方案
- MongoDB 分片总结
- Simple and easy-to-use code specification
- Cloud detection 2020: self attention generation countermeasure network for cloud detection in high-resolution remote sensing images
- ESP32系列专栏
- Navicat运行sql文件导入数据不全或导入失败
- Cmake learning and use notes (1)
猜你喜欢
centso7 openssl 报错Verify return code: 20 (unable to get local issuer certificate)
分布式事务解决方案
10 pictures open the door of CPU cache consistency
Error lnk2019: unresolved external symbol
Ogre入门尝鲜
Storage principle inside mongodb
Ways to improve the performance of raspberry pie
Flink | 多流转换
MySQL error 28 and solution
OSI 七层模型
随机推荐
Japanese government and enterprise employees got drunk and lost 460000 information USB flash drives. They publicly apologized and disclosed password rules
Shell batch file name (excluding extension) lowercase to uppercase
mysql 局域网内访问不到的问题
聊聊伪共享
MongoDB的导入导出、备份恢复总结
记一次 .NET 某新能源系统 线程疯涨 分析
Show the mathematical formula in El table
Esp32 series column
《厌女:日本的女性嫌恶》摘录
分布式事务解决方案
学习突围2 - 关于高效学习的方法
10 pictures open the door of CPU cache consistency
Signal strength (RSSI) knowledge sorting
How to make the new window opened by electorn on the window taskbar
RealBasicVSR测试图片、视频
ESP32构解工程添加组件
Custom thread pool rejection policy
Pay close attention to the work of safety production and make every effort to ensure the safety of people's lives and property
ESP32 ① 编译环境
How to make join run faster?