之前,个人博客大量教程分节介绍过这些命令行,此文做一个总述,更方便了解全貌。
如何快速导入这些环境呢?
colcon build --symlink-install
C:\ros_ws\webots_ros2>colcon build
[2.178s] root DEBUG Using proactor: IocpProactor
Starting >>> control_msgs
Starting >>> controller_manager_msgs
Starting >>> vision_msgs
Starting >>> realtime_tools
Starting >>> ros2_control_test_assets
Starting >>> dynamixel_sdk
Starting >>> webots_ros2_ur_e_description
Starting >>> ackermann_msgs
Finished <<< webots_ros2_ur_e_description [5.11s]
Starting >>> angles
Finished <<< ros2_control_test_assets [7.39s]
Starting >>> turtlebot3_description
Finished <<< dynamixel_sdk [8.98s]
Starting >>> turtlebot3_node
Finished <<< angles [7.53s]
Starting >>> dynamixel_sdk_custom_interfaces
Finished <<< turtlebot3_description [7.91s]
Starting >>> turtlebot3_cartographer
Finished <<< turtlebot3_cartographer [7.69s]
Starting >>> turtlebot3_example
Finished <<< realtime_tools [23.6s]
Starting >>> turtlebot3_navigation2
Finished <<< turtlebot3_example [5.89s]
Starting >>> turtlebot3_teleop
Finished <<< turtlebot3_node [20.3s]
Starting >>> webots_ros2_importer
Finished <<< turtlebot3_navigation2 [11.0s]
Starting >>> turtlebot3_bringup
Finished <<< ackermann_msgs [35.2s]
Finished <<< controller_manager_msgs [36.6s]
Finished <<< turtlebot3_teleop [7.88s]
Finished <<< webots_ros2_importer [7.44s]
Finished <<< vision_msgs [39.6s]
Starting >>> webots_ros2_msgs
Finished <<< turtlebot3_bringup [5.92s]
Starting >>> turtlebot3
Finished <<< dynamixel_sdk_custom_interfaces [28.8s]
Starting >>> dynamixel_sdk_examples
Finished <<< control_msgs [43.3s]
Starting >>> hardware_interface
Finished <<< turtlebot3 [5.70s]
Finished <<< dynamixel_sdk_examples [8.50s]
Finished <<< hardware_interface [15.6s]
Starting >>> controller_interface
Starting >>> transmission_interface
Finished <<< webots_ros2_msgs [20.9s]
Starting >>> webots_ros2_core
Starting >>> webots_ros2_driver
Finished <<< webots_ros2_core [4.45s]
Starting >>> webots_ros2_abb
Starting >>> webots_ros2_universal_robot
Starting >>> webots_ros2_epuck
Starting >>> webots_ros2_examples
Starting >>> webots_ros2_mavic
Finished <<< transmission_interface [15.8s]
Starting >>> webots_ros2_tesla
Finished <<< controller_interface [18.1s]
Starting >>> controller_manager
Finished <<< webots_ros2_abb [12.0s]
Finished <<< webots_ros2_universal_robot [11.9s]
Starting >>> webots_ros2_tiago
Starting >>> webots_ros2_tutorials
Finished <<< webots_ros2_examples [11.9s]
Finished <<< webots_ros2_epuck [12.2s]
Starting >>> webots_ros2_demos
Finished <<< webots_ros2_mavic [17.3s]
Finished <<< webots_ros2_driver [49.4s]
Finished <<< webots_ros2_tiago [34.5s]
Finished <<< webots_ros2_tesla [37.1s]
Finished <<< webots_ros2_tutorials [34.5s]
Finished <<< webots_ros2_demos [31.5s]
Finished <<< controller_manager [48.0s]
Starting >>> forward_command_controller
Starting >>> joint_state_broadcaster
Starting >>> diff_drive_controller
Starting >>> webots_ros2_control
Starting >>> force_torque_sensor_broadcaster
Starting >>> imu_sensor_broadcaster
Starting >>> joint_trajectory_controller
Starting >>> ros2controlcli
Finished <<< ros2controlcli [9.67s]
Starting >>> gripper_controllers
[143.592s] colcon.colcon_cmake.task.cmake.build WARNING Could not run installation step for package 'gripper_controllers' because it has no 'install' target
--- stderr: gripper_controllers
CMake Warning at CMakeLists.txt:5 (message):
gripper controllers are not available on OSX or Windows
---
Finished <<< gripper_controllers [5.92s]
Starting >>> ros2_control
Finished <<< joint_state_broadcaster [25.6s]
Starting >>> joint_state_controller
Finished <<< forward_command_controller [26.8s]
Starting >>> effort_controllers
Finished <<< force_torque_sensor_broadcaster [26.9s]
Finished <<< ros2_control [10.9s]
Starting >>> position_controllers
Starting >>> velocity_controllers
Finished <<< imu_sensor_broadcaster [28.1s]
Finished <<< diff_drive_controller [29.3s]
Finished <<< webots_ros2_control [29.5s]
Starting >>> webots_ros2_turtlebot
Finished <<< joint_trajectory_controller [32.0s]
Finished <<< webots_ros2_turtlebot [11.7s]
Starting >>> webots_ros2
Finished <<< joint_state_controller [19.0s]
Finished <<< effort_controllers [21.8s]
Finished <<< position_controllers [21.2s]
Finished <<< velocity_controllers [21.2s]
Starting >>> ros2_controllers
Finished <<< webots_ros2 [11.6s]
Finished <<< ros2_controllers [5.81s]
Summary: 53 packages finished [3min 1s]
1 package had stderr output: gripper_controllers
C:\ros_ws\webots_ros2>
为简单起见,只讲解二进制安装包附带的默认包。
所有 ROS2 命令都遵循以下语法:
ros2 <main_command> <sub_command> <<arguments>>
实例 :
ros2 pkg list
ros2 pkg executables
使用 Tab 补全完成命令,或查看可用选项列表。
示例:
这是最基础的ROS示例,必须掌握。
ROS 最基本的例子——发布者/订阅者
ros2 run <package_name> <executable_name> <<optional_command_line_arguments>> *注意空格
观察 ROS 2 运行时系统到目前为止的状态...
C:\ros_ws>ros2 run demo_nodes_cpp talker [INFO] [1627943926.877007500] [talker]: Publishing: 'Hello World: 1' [INFO] [1627943927.881649300] [talker]: Publishing: 'Hello World: 2' [INFO] [1627943928.882885900] [talker]: Publishing: 'Hello World: 3' [INFO] [1627943929.875583600] [talker]: Publishing: 'Hello World: 4' [INFO] [1627943930.888021900] [talker]: Publishing: 'Hello World: 5' [INFO] [1627943931.887165700] [talker]: Publishing: 'Hello World: 6' [INFO] [1627943932.871433900] [talker]: Publishing: 'Hello World: 7' [INFO] [1627943933.875443600] [talker]: Publishing: 'Hello World: 8' [INFO] [1627943934.874058100] [talker]: Publishing: 'Hello World: 9' [INFO] [1627943935.871674100] [talker]: Publishing: 'Hello World: 10' [INFO] [1627943936.877424900] [talker]: Publishing: 'Hello World: 11' [INFO] [1627943937.883121100] [talker]: Publishing: 'Hello World: 12' [INFO] [1627943938.874110100] [talker]: Publishing: 'Hello World: 13' [INFO] [1627943939.879654100] [talker]: Publishing: 'Hello World: 14' [INFO] [1627943940.886396700] [talker]: Publishing: 'Hello World: 15' [INFO] [1627943941.875835300] [talker]: Publishing: 'Hello World: 16' [INFO] [1627943942.876223700] [talker]: Publishing: 'Hello World: 17' [INFO] [1627943943.872789300] [talker]: Publishing: 'Hello World: 18' [INFO] [1627943944.884865900] [talker]: Publishing: 'Hello World: 19' [INFO] [1627943945.878195100] [talker]: Publishing: 'Hello World: 20' [INFO] [1627943946.881809600] [talker]: Publishing: 'Hello World: 21' [INFO] [1627943947.874536300] [talker]: Publishing: 'Hello World: 22' [INFO] [1627943948.871196200] [talker]: Publishing: 'Hello World: 23'
节点
主题
C:\ros_ws\webots_ros2>ros2 interface show std_msgs/msg/String # This was originally provided as an example message. # It is deprecated as of Foxy # It is recommended to create your own semantically meaningful message. # However if you would like to continue using this please use the equivalent in example_msgs. string data
C:\ros_ws\webots_ros2>ros2 interface proto std_msgs/msg/String "data: '' "
C:\ros_ws>ros2 launch demo_nodes_cpp talker_listener.launch.py [INFO] [launch]: All log files can be found below C:\Users\zhangrelay\.ros/log\2021-08-03-15-15-10-692151-LAPTOP-5REQ7K1L-9852 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [talker.EXE-1]: process started with pid [9608] [INFO] [listener.EXE-2]: process started with pid [16824] [talker.EXE-1] [INFO] [1627974912.070719100] [talker]: Publishing: 'Hello World: 1' [listener.EXE-2] [INFO] [1627974912.086495000] [listener]: I heard: [Hello World: 1] [talker.EXE-1] [INFO] [1627974913.090884400] [talker]: Publishing: 'Hello World: 2' [listener.EXE-2] [INFO] [1627974913.122120700] [listener]: I heard: [Hello World: 2] [talker.EXE-1] [INFO] [1627974914.085433000] [talker]: Publishing: 'Hello World: 3' [listener.EXE-2] [INFO] [1627974914.101354000] [listener]: I heard: [Hello World: 3] [talker.EXE-1] [INFO] [1627974915.084586200] [talker]: Publishing: 'Hello World: 4' [listener.EXE-2] [INFO] [1627974915.100422500] [listener]: I heard: [Hello World: 4]
ros2 run demo_nodes_cpp add_two_ints_server
ros2 run demo_nodes_cpp add_two_ints_client
C:\ros_ws\webots_ros2>ros2 run demo_nodes_cpp add_two_ints_server [INFO] [1627975189.301810900] [add_two_ints_server]: Incoming request a: 2 b: 3 [INFO] [1627975198.975293000] [add_two_ints_server]: Incoming request a: 2 b: 3 [INFO] [1627975216.994539900] [add_two_ints_server]: Incoming request a: 5 b: 6
更多内容,参考官方文档。
更多内容,参考官方文档。
功能包医生本地化!
Shell 1 Source ROS1, Run ROS1 stuff Shell 2 Source ROS1, Source ROS2, Run bridge Shell 3
-End-