Introduction

In this part of the tutorials, it will be demonstrated how ROS can be used to remotely control the mobile robot via PC.

Remote control of the mobile robot

To remotely control the mobile robot, we have to run several ROS nodes: The first node is ROS master node. The second node is a standard ROS node called teleop_twist_keyboard. This node is constantly checking which keys are pressed on a PC keyboard and based on the keys pressed, publishes twist messages on /cmd_vel topic. Twist message defines what should be the linear and rotational speeds of a mobile robot. Other two nodes, i.e. _socked_node_ and message_info_center_ from the pakcage _rosserial_server_, are needed to enable communication between the ROS and the microcontroller on the mobile robot.

Instructions

Step 1. Switch ON the mobile robot and do the initial setup (WiFI settings, ROS Master IP, etc. Follow the initial setup instructions and instructions on how to connect the mobile robot to ROS under the section MOBILE ROBOT DOCUMENTATION/Getting-started).

Step 2. Run the master node along with other essential components:

roscore

Step 3. If the teleop_twist_keyboard package is not already installed on your PC, use the following command to install the teleop_twist_keyboard package:

sudo apt-get install ros-melodic-teleop-twist-keyboard

Step 4. In the second terminal, launch the teleop_twist_keyboard node:

rosrun teleop_twist_keyboard teleop_twist_keyboard

Step 5. In another two terminals launch the nodes socket_node and message_info_service.py:

rosrun rosserial_server socket_node
rosrun rosserial_python message_info_service.py

Alternatively, if you e.g. don't have a real mobile robot, you can do these tasks also with a simulated one. To do this with a simulated robot, you need to launch the simulation:

cd .../rosbot_ros

source devel/setup.bash

roslaunch rosbot simulation.launch

and in the second terminal:

rosrun teleop_twist_keyboard teleop_twist_keyboard

Step 6. Click on the terminal where you have launched the node teleop_twist_keyboard and now you can remotely control the mobile robot by pressing keys on a PC's keyboard (to find out which keys you need to press read the instructions printed out in that terminal).

Task

In a similar way, try to set up a system for controlling the mobile robot via a PC's mouse using the ROS package mouse_teleop. Help: When starting the mouse_teleop node, you must change topic name on which mouse_teleop node will publish Twist messages (the command to run mouse_teleop node with a changed topic name to cmd_vel is rosrun mouse_teleop mouse_teleop.py mouse_vel:=cmd_vel ).

Additional task

Create a new package remote_control inside workospace rosbot_ros:

cd .../rosbot_ros/src

catkin_create_pkg remote_control std_msgs roscpp

In package remote_control create a single launch file that will launch all nodes needed for the teleoperation of the mobile robot via the PC's keyboard and mouse.