チュートリアルより。インストールした後これ実行していけばROS2がどういうものかなんとなくわかる。
turtlesim:カメ🐢のシミュレータ
source /opt/ros/jazzy/setup.zsh
ros2 pkg executables turtlesim
ros2 run turtlesim turtlesim_node
rqt
ros2 run turtlesim turtle_teleop_key --ros-args --remap turtle1/cmd_vel:=turtle2/cmd_vel
ノードについて:プロセスみたいなもの
ros2 node list
ros2 node info /teleop_turtle
トピックについて:非同期通信、publisher/subscriber型
rqt_graph
ros2 topic list
ros2 topic list -t
ros2 topic echo /turtle1/cmd_vel
ros2 topic info /turtle1/cmd_vel
ros2 interface show geometry_msgs/msg/Twi
ros2 topic pub /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 --once -w 2 /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 echo /turtle1/poseros2 topic pub /pose geometry_msgs/msg/PoseStamped '{header: "auto", pose: {position: {x: 1.0, y: 2.0, z: 3.0}}}'
ros2 topic pub /reference sensor_msgs/msg/TimeReference '{header: "auto", time_ref: "now", source: "dumy"}'
ros2 topic hz /turtle1/pose
ros2 topic bw /turtle1/pose
ros2 topic find geometry_msgs/msg/Twist
サービスについて:同期通信、client/server型
ros2 service list
ros2 service type /clear
ros2 service list -t
ros2 service info /clear
ros2 service find std_srvs/srv/Empty
ros2 interface show std_srvs/srv/Empty
ros2 interface show turtlesim/srv/Spawn
ros2 service call /clear std_srvs/srv/Empty
ros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}"
ros2 param set /introspection_service service_configure_introspection contents
ros2 param set /introspection_client client_configure_introspection contents
ros2 service echo --flow-style /add_two_ints
パラメータについて:ノードの設定値
ros2 param list
ros2 param get /turtlesim background_g
ros2 param set /turtlesim background_r 150
ros2 param dump /turtlesim > turtlesim.yaml
ros2 param load /turtlesim turtlesim.yaml
ros2 run turtlesim turtlesim_node --ros-args --params-file turtlesim.yaml
アクション:キャンセル可能な長時間実行タスク (goal, feedback, result)
ros2 node info /turtlesim
ros2 node info /teleop_turtle
ros2 action list
ros2 action list -t
ros2 action type /turtle1/rotate_absolute
ros2 action info /turtle1/rotate_absolute
ros2 interface show turtlesim/action/RotateAbsolute
ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: 1.57}"
ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: -1.57}" --feedback
rqt_console:ログビューア
ros2 run rqt_console rqt_console
ros2 topic pub -r 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: 0.0}}"
ros2 run turtlesim turtlesim_node --ros-args --log-level WARN
参考