当前位置:网站首页>[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
边栏推荐
猜你喜欢

QQ的药,腾讯的票
![[dark horse morning post] Huawei refutes rumors about](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[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

Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file

MATLAB中polarscatter函数使用

10 张图打开 CPU 缓存一致性的大门

Final review notes of single chip microcomputer principle

室内ROS机器人导航调试记录(膨胀半径的选取经验)

Introduction and basic use of stored procedures

Cloud detection 2020: self attention generation countermeasure network for cloud detection in high-resolution remote sensing images

Getting started with cinnamon applet
随机推荐
cmake 学习使用笔记(一)
Vscode编辑器ESP32头文件波浪线不跳转彻底解决
OSI seven layer model
MongoDB 分片总结
Isprs2021/ remote sensing image cloud detection: a geographic information driven method and a new large-scale remote sensing cloud / snow detection data set
[learning notes] segment tree selection
Milkdown 控件图标
MongoDB的用户管理总结
数字ic设计——SPI
Cinnamon 任务栏网速
ESP32构解工程添加组件
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
[untitled]
分布式事务解决方案
Digital IC Design SPI
LIS 最长上升子序列问题(动态规划、贪心+二分)
我那“不好惹”的00后下属:不差钱,怼领导,抵制加班
PACP学习笔记三:PCAP方法说明
DETR介绍
迅为iTOP-IMX6ULL开发板Pinctrl和GPIO子系统实验-修改设备树文件