当前位置:网站首页>[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
边栏推荐
猜你喜欢
随机推荐
Read PG in data warehouse in one article_ stat
Pay close attention to the work of safety production and make every effort to ensure the safety of people's lives and property
分布式事务解决方案
QQ的药,腾讯的票
LeetCode_ Binary search_ Medium_ 153. Find the minimum value in the rotation sort array
解决缓存击穿问题
Unity build error: the name "editorutility" does not exist in the current context
JS function returns multiple values
Milkdown 控件图标
如何让electorn打开的新窗口在window任务栏上面
Getting started with cinnamon applet
clion mingw64中文乱码
【等保】云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
Split screen bug notes
PAcP learning note 3: pcap method description
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours
[learning notes] zkw segment tree
Scrapy教程经典实战【新概念英语】
【面试高频题】难度 2.5/5,简单结合 DFS 的 Trie 模板级运用题
About how appium closes apps (resolved)