In my opinion, the most powerful place of ROS is its communication mechanism, not only the communication between the process is convenient, even the communication between different devices is also very convenient, just add a few lines of code, you can realize the Topi C sharing, remote control and other functions between multiple computers. Let's do it together!
This assumes that we have two computers: computer A is the host side, and computer B is the control side. Finally to implement on a computer run Roscore, and run the Turtlesim program, and then run the keyboard on the B computer control program, control Turtlesim Small turtle movement.
First, check the IP and Hostname of PC A and PC B
To view IP, in console input:
Ifconfig
If the computer is connected to the cable network, then the result is displayed, Etho part of the inet addr is the computer's IP address;
If the computer is connected to wireless, the wlp3s0 part of inet addr is the IP address .
To View Hostname, in console input:
Hostname
Second, modify the contents of the Hosts file
Use the following instructions to open the Hosts file on Pc A and PC B, respectively:
sudo gedit/etc/hosts
Add the following bold instructions to the Hosts file on pc a :
127.0.0.1 localhost127.0. 1.1 [hostname_a][ip_a] [hostname_a][ip_b] [Hostname_b]* * *
In the same vein, in the Hosts file on the B side of the computer, add the following bold instructions:
127.0.0.1 localhost127.0. 1.1 [Hostname_b][ip_b] [hostname_b][ip_a] [hostname_a]* * *
Finally, modify the. bashrc file
Use the following instructions to open the. bashrc file on pc A and PC B, respectively
sudo gedit ~/.BASHRC
In the last line of the. bashrc file opened on pc a and B end , add the following code:
Export ros_master_uri=http://[hostname_a]:11311
[note] This assumes that PC A is a host, and if you change it to PC B as the host, you only need to change [hostname_a] in this step to [Hostname_b].
Finally, run the Little Turtle program
Computer A-side:
Start with ROS first:
$ roscore
Then Ctrl + T opens the new console and runs: $ rosrun turtlesim turtlesim_node
Computer B-side:
$ rosrun Turtlesim Turtle_teleop_key
Now, you can use computer B to control the Little turtle in computer A ~\ (≧▽≦)/~.
ROS (Robotic operating systems) communicate between multiple computers