Note: This tutorial assumes that you have completed the previous tutorials: Network setup for controlling multiple robots from a remote machine. |
Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Launch and control multiple robots from a remote machine
Description: This tutorial explain how to launch and control multiple robots from a remote computerTutorial Level: INTERMEDIATE
Next Tutorial: Network setup for controlling multiple robots from a remote machine
Preliminary Setup
Install the ric meta-package
The base station computer should have the entire ric meta-package built. You should also run and answer 'y' (yes) to all steps of the setup.sh file (follow the Robot installation tutorial).
Network setup
Follow the Network setup for controlling multiple robots from a remote machine tutorial.
Launching the robots
For the following examples we assume we have two komodo robots with id's 1 and 2 with IP addresses 192.168.0.101 and 192.168.0.102 respectively. The base station computer IP address is 192.168.0.100. One can use any other IP addresses.
First, we will edit the ric/ric_base_station/launch/komodo_base_station.launch file to match the above komodo robots addresses:
1 <machine name="komodo1" address="192.168.0.101" user="komodo" password="a" env-loader="~/catkin_ws/src/ric/ric_robot/config/ric_env.sh" default="true"/>
2
3 <group ns="komodo_1">
4 <include file="$(find ric_base_station)/launch/remote_komodo.launch">
5 <arg name="id" value="1" />
6 </include>
7 </group>
8
9
10 <machine name="komodo2" address="192.168.0.102" user="komodo" password="a" env-loader="~/catkin_ws/src/ric/ric_robot/config/ric_env.sh" default="true"/>
11
12 <group ns="komodo_2">
13 <include file="$(find ric_base_station)/launch/remote_komodo.launch">
14 <arg name="id" value="2" />
15 </include>
16 </group>
Make sure that the <machine/> parameters are all correct according to your network setup and to the specific robot computer username and password. Note that from the factory the default username is "komodo" and password is "a". .
In order to select exactly what will be launched on the komodo robots, see the ric/ric_base_station/launch/remote_komodo.launch file.
In a terminal window, set the following parameters according to the base station IP address:
$ export ROS_MASTER_URI="http://192.168.0.100:11311" $ export ROS_IP="192.168.0.100" $ export ROSLAUNCH_SSH_UNKNOWN=1 $ roscore
You will have to type the first two export commands in each new terminal window.
To watch the start-up messages, run rqt_console in a new terminal:
$ rqt_console
Finally, in a new terminal, launch the base_station launch file:
$ roslaunch ric_base_station komodo_base_station.launch
If you have any problems during the launch, check your network setup.
Now you can control all the komodo robots, try printing the current topics to check that everything is ok:
$ rostopic list
Controlling the robots
One can use the multi_robot_control node to control multiple robots from a single joystick.
The ric/ric_base_station/launch/multi_robot_control.launch is used to launch the required parameters and start the node.
You will have to figure out your joystick port and the id numbers of joystick axes and buttons. To do so, type:
$ ls /dev/input
and find the joystick port name (usually /dev/input/js0).
Now run:
$ sudo jstest /dev/input/js0
Play with joystick sticks and buttons and write down the numbers of the axes which you would like to control the drive and the axes to control the pan-tilt system. You should also choose a button for switching between robots (joy_scroll_btn), a button to switch between slow and normal drive speeds (joy_slow_btn) and a button for centering the pan-titlt system (joy_center_btn).
Edit the multi_robot_control.launch to match the joystick port.
Now, edit the ric/ric_base_station/config/multi_robot_control.yaml file to mach your required axes and buttons.
Launching the multi_robot_control.launch file can be done manually:
$ roslaunch ric_base_station multi_robot_control.launch
or as a part of the komodo_base_station.launch:
<include file="$(find ric_base_station)/launch/multi_robot_control.launch"/>
Now you can manually drive and operate the pan-tilt system of all the robots.
You can watch the robots cameras and sensors using rqt.
Have fun!