# ROS2 Communicate ## Test multiple Machines :spiral_note_pad: https://roboticsbackend.com/ros2-multiple-machines-including-raspberry-pi/ :spiral_note_pad:https://blog.csdn.net/zwwang2014/article/details/84849820 ### Simple test **1. get the IP address of each machine inside the network by hostname -I** **Example:** * Machine 1: ``` $ hostname -I 192.168.0.15 ``` * Machine 2: ``` $ hostname -I 192.168.0.16 ``` **2. ping each other** * Machine 1: ``` $ ping 192.168.0.16 PING 192.168.0.16 (192.168.0.16) 56(84) bytes of data. 64 bytes from 192.168.0.16: icmp_seq=1 ttl=64 time=128 ms 64 bytes from 192.168.0.16: icmp_seq=2 ttl=64 time=136 ms ``` * Machine 2: ``` $ ping 192.168.0.15 PING 192.168.0.15 (192.168.0.15) 56(84) bytes of data. 64 bytes from 192.168.0.15: icmp_seq=1 ttl=64 time=128 ms 64 bytes from 192.168.0.15: icmp_seq=2 ttl=64 time=136 ms ``` **3. source ROS2** ``` source /opt/ros/foxy/setup.bash #all machines ``` **4. export ROS_DOMAIN_ID** ``` export ROS_DOMAIN_ID=1 ```  **5. ros run** **Talker <-> Listener** * Machine 1: ``` $ ros2 run demo_nodes_cpp talker Publishing: 'Hello World: 398' Publishing: 'Hello World: 399' Publishing: 'Hello World: 400' Publishing: 'Hello World: 401' Publishing: 'Hello World: 402' Publishing: 'Hello World: 403' Publishing: 'Hello World: 404' Publishing: 'Hello World: 405' ``` * Machine 2: ``` $ ros2 run demo_nodes_cpp listener I heard: [Hello World: 401] I heard: [Hello World: 402] I heard: [Hello World: 403] I heard: [Hello World: 404] I heard: [Hello World: 405] I heard: [Hello World: 406] I heard: [Hello World: 407] I heard: [Hello World: 408] I heard: [Hello World: 409] ``` **Turtle** * Machine 1: ``` $ ros2 run turtlesim turtlesim_node ``` * Machine 2: ``` $ ros2 run turtlesim turtle_teleop_key ``` Result: {%youtube YS7iIVrWx_E %} ### Test disussion: #### Simple test discussion * 這個東西主要是以wifi為主的傳遞訊息。 * Domain ID 可以一直export, Talker 跟 listener 會無限增加 #### ## idea for project 2 intel nuc **Idea 1:** ping, then ros run the map file on the second pc sensor ros run on the first pc **Idea 2:** git all the file down to the second pc then ros run map file on the second pc ### tutorial **Nodes Communication Using Topics** https://www.youtube.com/watch?v=qHr82IPJ-18 **Nodes Communication Using Services & Actions** https://www.youtube.com/watch?v=qFVnDFLZJWQ ### remote control nuc xrdp teamviewer remmia
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up