ROS2与Turbot3-Multi多机协同教程-设备测试
文章说明
- 本教程主要介绍如何执行单机和多机测试
- 测试环境:
Ubuntu 24.04
+ROS2 Jazzy
前提准备
- Turbot3-Multi多机套件发货已经配置好系统和网络,不需要再额外配置
- 使用前,需要为NUC准备显示器和键鼠
- Turbot3-Multi多机套件中设备的系统密码都为
ubuntu
- 目前测试平台是一台配置好的路由器,一台
NUC
作为服务器server0
主机和三台burger
为从机,分别是client0
,client1
,client2
- 路由器的IP为
192.168.168.1
,WIFI名称为Turbot3-Multi
,密码为12345678
server0
的默认ip为192.168.168.98
client0
的默认ip为192.168.168.110
,client1
的默认ip为192.168.168.111
,client2
的默认ip为192.168.168.112
- 同时在
client
端都设置了NTP时间同步服务,指向同步server0
端的时间,确保设备在不联网的情况下时间一致
单机测试步骤
- [NUC] 启动单机
client0
的Burger设备,namepace默认为tb3_0
$ ./multi_scripts/single_robot.sh 0
------------------------------------------------------
./multi_scripts/single_robot.sh [client_id]
Such as: "./multi_scripts/single_robot.sh 0"
It will remotely launch the lidar and base of clinet0 robot.
------------------------------------------------------
### client minimal ###
--robot tb3_0 is done
PLAY [client0] **************************************************************************************
TASK [Gathering Facts] ******************************************************************************
ok: [client0]
TASK [client_minimal : ros2 launch turtlebot3_bringup robot.launch.py namespace:=tb3_0 (client)] ****
changed: [client0]
PLAY RECAP ******************************************************************************************
client0 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- [NUC] 查看tf
$ ros2 run rqt_tf_tree rqt_tf_tree
- [NUC] 查看话题
$ ros2 topic list
/parameter_events
/rosout
/tb3_0/battery_state
/tb3_0/cmd_vel
/tb3_0/imu
/tb3_0/joint_states
/tb3_0/magnetic_field
/tb3_0/odom
/tb3_0/robot_description
/tb3_0/scan
/tb3_0/sensor_state
/tf
/tf_static
- [NUC] 测试键盘控制
$ ./multi_scripts/single_key.sh 0
- [NUC] 中止单机
client0
中的ROS2相关的进程
$ ./multi_scripts/single_kill.sh 0
多机测试步骤
- [NUC] 在
server0
上执行,进行多机联通测试
$ ./multi_scripts/multi_ping.sh
------------------------------------------------------
./multi_scripts/multi_ping.sh [client number]
[client number] Default value: 3
Such as: "./multi_scripts/multi_ping.sh 2"
It will ping in order the ip of client0 and client1 robot.
------------------------------------------------------
------------------------------------------------------
Pinging 192.168.168.110
PING 192.168.168.110 (192.168.168.110) 56(84) bytes of data.
64 bytes from 192.168.168.110: icmp_seq=1 ttl=64 time=41.3 ms
64 bytes from 192.168.168.110: icmp_seq=2 ttl=64 time=72.0 ms
64 bytes from 192.168.168.110: icmp_seq=3 ttl=64 time=99.5 ms
--- 192.168.168.110 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 41.274/70.908/99.500/23.782 ms
------------------------------------------------------
------------------------------------------------------
Pinging 192.168.168.111
PING 192.168.168.111 (192.168.168.111) 56(84) bytes of data.
64 bytes from 192.168.168.111: icmp_seq=1 ttl=64 time=184 ms
64 bytes from 192.168.168.111: icmp_seq=2 ttl=64 time=7.92 ms
64 bytes from 192.168.168.111: icmp_seq=3 ttl=64 time=22.4 ms
--- 192.168.168.111 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 7.916/71.314/183.603/79.620 ms
------------------------------------------------------
------------------------------------------------------
Pinging 192.168.168.112
PING 192.168.168.112 (192.168.168.112) 56(84) bytes of data.
64 bytes from 192.168.168.112: icmp_seq=1 ttl=64 time=209 ms
64 bytes from 192.168.168.112: icmp_seq=2 ttl=64 time=44.3 ms
64 bytes from 192.168.168.112: icmp_seq=3 ttl=64 time=23.3 ms
--- 192.168.168.112 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 23.296/92.169/208.865/82.962 ms
------------------------------------------------------
- [NUC] 在server0上执行,启动多机测试
$ ./multi_scripts/multi_robot.sh
------------------------------------------------------
./multi_scripts/multi_robot.sh [client number]
[client number] Default value: 3
Such as: "./multi_scripts/multi_ping.sh 2"
It will remotely launch the lidar and base of client_0 and client_1 robot.
------------------------------------------------------
------------------------------------------------------
### client minimal ###
--robot tb3_0 is done
PLAY [client0] ***********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [client0]
TASK [client_minimal : ros2 launch turtlebot3_bringup robot.launch.py namespace:=tb3_0 (client)] *************************************************************************************************************
changed: [client0]
PLAY RECAP ***************************************************************************************************************************************************************************************************
client0 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
------------------------------------------------------
------------------------------------------------------
### client minimal ###
--robot tb3_1 is done
PLAY [client1] ***********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [client1]
TASK [client_minimal : ros2 launch turtlebot3_bringup robot.launch.py namespace:=tb3_1 (client)] *************************************************************************************************************
changed: [client1]
PLAY RECAP ***************************************************************************************************************************************************************************************************
client1 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
------------------------------------------------------
------------------------------------------------------
### client minimal ###
--robot tb3_2 is done
PLAY [client2] ***********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [client2]
TASK [client_minimal : ros2 launch turtlebot3_bringup robot.launch.py namespace:=tb3_2 (client)] *************************************************************************************************************
changed: [client2]
PLAY RECAP ***************************************************************************************************************************************************************************************************
client2 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
------------------------------------------------------
- [NUC] 查看tf
$ ros2 run rqt_tf_tree rqt_tf_tree
- [NUC] 查看话题
$ ros2 topic list
/parameter_events
/rosout
/tb3_0/battery_state
/tb3_0/cmd_vel
/tb3_0/imu
/tb3_0/joint_states
/tb3_0/magnetic_field
/tb3_0/odom
/tb3_0/robot_description
/tb3_0/scan
/tb3_0/sensor_state
/tb3_1/battery_state
/tb3_1/cmd_vel
/tb3_1/imu
/tb3_1/joint_states
/tb3_1/magnetic_field
/tb3_1/odom
/tb3_1/robot_description
/tb3_1/scan
/tb3_1/sensor_state
/tb3_2/battery_state
/tb3_2/cmd_vel
/tb3_2/imu
/tb3_2/joint_states
/tb3_2/magnetic_field
/tb3_2/odom
/tb3_2/robot_description
/tb3_2/scan
/tb3_2/sensor_state
/tf
/tf_static
- [NUC] 分别打开三个终端,测试键盘控制
$ ./multi_scripts/single_key.sh 0
$ ./multi_scripts/single_key.sh 1
$ ./multi_scripts/single_key.sh 2
- [NUC] 中止3个
client
端的ros2进程
$ ./multi_scripts/multi_kill.sh
- [NUC] 中止3个
client
端的ros2进程
$ ./multi_scripts/multi_kill.sh
------------------------------------------------------
./multi_scripts/multi_robot.sh [client number]
[client number] Default value: 3
Such as: "./multi_scripts/multi_ping.sh 2"
It will remotely kill all ros2 processes of client0 and client1 robot.
------------------------------------------------------
PLAY [client0] ***********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [client0]
TASK [client_kill : sudo pkill ros (client)] *****************************************************************************************************************************************************************
changed: [client0]
PLAY RECAP ***************************************************************************************************************************************************************************************************
client0 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
PLAY [client1] ***********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [client1]
TASK [client_kill : sudo pkill ros (client)] *****************************************************************************************************************************************************************
changed: [client1]
PLAY RECAP ***************************************************************************************************************************************************************************************************
client1 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
PLAY [client2] ***********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [client2]
TASK [client_kill : sudo pkill ros (client)] *****************************************************************************************************************************************************************
changed: [client2]
PLAY RECAP ***************************************************************************************************************************************************************************************************
client2 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- [NUC] 中止
server
端的ros2进程
$ ./multi_scripts/server_kill.sh
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号