Working with Physical Turtlebots


These are instructions for running ROS code on a physical Turtlebot4 in the John Crerar Library.

Handy Links


Overview


Each Turtlebot4 has two main components (1) an iRobot Create base and (2) a RaspberryPi. The RaspberryPi is connected to and controls the robot's sensors and arm and is the main interface between the user PC and the Create base. We have configured the Turtlebot4 robots with the Discovery Server network protocol.

Connecting to Turtlebot4


1. Turn On the Robot and Wait for Boot Completion

To start the robot boot process, pick up the Turtlebot4 robot by its base and place it on a charger. The robot should power on automatically. WAIT for the robot to finish its boot process before trying to connect - it should take about 2.5 minutes and the robot will make a "chime" noise once the boot process is complete.

2. WiFi Network Connection for Your PC

You will need to ensure your computer is connected to the correct wifi network:

3. Environment Variable Setup

Next, you'll have to setup some environment variables to establish communication between your PC and the specific robot you wish to control: ROS_DOMAIN_ID, ROS_DISCOVERY_SERVER, and ROS_LOCALHOST_ONLY.

  1. Robot number: Specify which robot you want to connect to:
    $ set_robot_num [robot-num]
    The set_robot_num bash function is one that we wrote to automatically set the ROS_DISCOVERY_SERVER to the IP address of the desired robot and to set ROS_DOMAIN_ID to the number of the robot.
    Note: A few things to keep in mind with set_robot_num:
    • Checking current robot ID: If you want to check the current robot number you have saved in your environment variable settings you can run:
      $ echo $ROS_DOMAIN_ID
    • Saved default: Your computer will save the last robot number you connected to, so be careful to check and reset the robot number each time you start working with a new robot. If you're curious, you can find the currently saved settings in ~/intro_robo_ws/src/intro_robo/intro_robo_utils/discover_server_env_variables.sh which is sourced in your .bashrc file.
    Each time you work with a new robot, you'll need to run this command again. If you ever want to check
  2. ROS_LOCALHOST_ONLY: If you're working with Gazebo and the simulated Turtlebot4, you'll want to set ROS_LOCALHOST_ONLY=1, otherwise, if you're using the physical Turtlebot4 robot, you'll want ROS_LOCALHOST_ONLY=0. You can change this variable by editing your .bashrc file:
    $ nano ~/.bashrc
    After editing it to set ROS_LOCALHOST_ONLY to your desired value, source the .bashrc so your changes take effect:
    $ source ~/.bashrc

4. Check Turtlebot4 Create Base Connectivity

In order to work properly, your Turtlebot4 it needs to have established a connection between its RaspberryPi and Create base. To check to make sure everything is working correctly, check the 5 LEDs on the robot. All 5 LEDs should be green. If the COMM and BATT lights are off, you'll need to reboot the RaspberryPi to properly establish a connection with the Create base.

Working Create Connection (All LEDs On)
TB4 all LEDs on

If all 5 LEDs are green, you're all set and can continue to the next step!

Create Disconnected (COMM and BATT LEDs Off)
TB4 COMM BATT LEDs off

If the COMM and BATT LEDs are off, you'll need to reboot the RaspberryPi to re-establish a connection with the Create base. First SSH into the robot (password: turtlebot4)

$ ssh ubuntu@$ROBOT_IP
Then, in the same terminal, run the command:
$ sudo reboot
Finally, wait for the RaspberryPi to reboot, after which all 5 LEDs should be green.

5. Test Your Connection

There are a few different ways to test your computer's connection to your specific Turtlebot4. Here are a few options:

Remote Control Teleoperation of Turtlebot4


TODO

Operating the OpenManipulatorX Arm


Turtlebot4 with arm

Unlike the Turtlebot4, the OpenManipulatorX arm does not automatically start publishing and subscribing to ROS2 topics as soon as it turns on. You'll have to run the bringup code for the arm and start up MoveIt! every time you want to work with it. Follow the steps below:

  1. Check Battery: Ensure that a fully charged battery is plugged into the U2D2 board on the top plate of the robot.
  2. Position the Arm: Position the arm as shown in the picture below to enable the arm to initialize properly. If you fail to do this, you may find that any movement command you send to the arm will fail.
    initial OpenManipulatorX arm position
  3. [Terminal #1] SSH into the robot (password: turtlebot4), check USB port number, and run bringup:
    $ set_robot_num [robot_num]
    $ ssh ubuntu@$ROBOT_IP
    $ sudo dmesg | grep ttyUSB
    After running sudo dmesg | grep ttyUSB look for which USB port the FTDI USB Serial Device is connected to, it should be either ttyUSB0 or ttyUSB1. Now run the bringup command for the arm by specifying the USB port you identified in the prior step.
    $ bringup_arm port_name:=/dev/ttyUSB1 
    Note: bringup_arm is an alias for the command ros2 launch open_manipulator_x_bringup hardware.launch.py.
  4. [Terminal #2] SSH into the robot and start MoveIt!: In a separate second terminal, ssh into the robot and start MoveIt!.
    $ ssh ubuntu@$ROBOT_IP
    $ start_moveit 
    Note: start_moveit is an alias for the command ros2 launch open_manipulator_x_moveit_config move_group.launch.py.
  5. [Terminal #3] Control the robot from your PC: You have several options here:
    • For the OpenManipulatorX GUI:
      $ ros2 launch open_manipulator_x_gui open_manipulator_x_gui.launch.py
    • For running code:
      $ ros2 run [package-name] [file-name]