Skip to content

Real Robot Local Deployment

Tom Howard edited this page Apr 6, 2022 · 10 revisions

'Local' Deployment

On this page we discuss how to get started with the robots. To start with, we'll work with ROS 'locally', that is: creating and deploying ROS Packages and Nodes directly on the robot operating system.

Quick Links

Launching ROS

The ROS Master always runs on the robot, regardless of whether we are deploying nodes locally or remotely. In either case, the steps in this section are essential, otherwise the ROS Master will not be running, the robot's core functionality won't be active, and it therefore won't be able to do anything!

There are a number of initial steps that need to be carried out in order to start up the robot and get ROS running.

Step 1: Identify your robot

Robots are named as follows:

dia-waffleX

... where X indicates the 'Robot Number' (a number between 1 and 50). Make sure you know which robot you are working with, or check the label printed on top of it!

Step 2: Log in to the robot's operating system wirelessly using ssh.

Note: We'll assume that you are working with one of our Robot Laptops when doing this, but it is also possible to do this from other machines too. If you are doing this on a Robot Laptop make sure it's connected to the DIA-LAB WiFi network!

  1. Open up a terminal instance, which we will refer to as REMOTE 1. Then, enter the following to establish a connection to your robot via ssh:

     [REMOTE 1] $ ssh robot@dia-waffleX
    

    ... replacing X with the number of the robot that you are working with. Enter the password when requested (we'll tell you what this is in the lab).

  2. The terminal prompt should change as follows:

     robot@dia-waffleX:~$  
    

    This indicates that you are now logged in to the robot's operating system (hostname: dia-waffleX, user: robot).

    Because this terminal instance is now running on the robot, we'll refer to this as ROBOT 1 instead.

  3. From here, launch tmux, which allows us to create multiple terminal instances inside the single ssh session that we've just established:

     [ROBOT 1] $ tmux
    

    Any text in the terminal should now clear, and a green banner should appear across the bottom of the terminal window:

You can find a (very quick) guide on how to use tmux here.

Step 3: Launching ROS

Now, we need to launch the ROS Master and all the core packages on the robot that provide its basic functionality. We can do this using a single launch file located within a ROS package called turtlebot3_bringup. To do this, enter the following command in ROBOT 1:

[ROBOT 1] $ roslaunch turtlebot3_bringup turtlebot3_robot.launch

Pro Tip: Alternatively, you could use one of our handy bash aliases for this command instead.

Once you see a message containing the text:

[INFO] [#####] Calibration End  

... then the robot core packages are up and running.

Job done: ROS is now running, and you are ready to work with the robot!

Note: Leave the ROBOT 1 terminal instance alone now and definitely don't shut down these processes (using Ctrl+C), otherwise ROS won't be active anymore, and your robot won't do anything!

Accessing the Robot using VS Code

The instructions that follow assume that you are working on one of our Robot Laptops. See the section below for further details on how to work with other devices.

Launching an ssh session

  1. Click the green icon in the bottom left-hand corner of the VS Code screen:

  2. A menu should appear at the top of the screen, select Connect to Host....

  3. Enter the details of the robot that you are trying to connect to, exactly the same way as you would when trying to establish an ssh connection from a terminal: robot@dia-waffleX

    ... replacing X with the number of the robot, as printed on its body.

    Hit Enter and a new VS Code instance should launch.

  4. In the new VS Code Instance the following message might then appear:

    ... hit Enter or click the "Continue" button.

  5. Enter the password for the robot user account when prompted.

  6. If the connection was successful, the green "Remote" icon in the bottom left-hand corner of the VS Code screen should now look something like this:

Accessing the Robot's Filesystem

  1. Access the robot's filesystem in VS Code by:

    1. Clicking the "Explorer" icon in the left-hand toolbar (or use the Ctrl+Shift+E keyboard shortcut),
    2. Clicking the blue "Open Folder" button,
    3. Clicking "OK" to select the default /home/robot/ filesystem location (the "home" folder).

  2. Finally, a trust pop-up may appear. Click the checkbox to "Trust the authors of all files in the parent folder 'home'" and then click the blue "Yes, I trust the authors" button.

Working in the Terminal

You can launch any number of terminal instances on the robot from within VS Code by going to the "Terminal" menu at the top of the screen and selecting "New Terminal".

From here you can navigate the robot's filesystem, run commands and launch ROS applications exactly as you have done within WSL-ROS.

Remember: Before you try to launch any of your own ROS nodes on the robot, you will need to make sure ROS and the core robot packages are all up and running!

Connecting to the robot from another device

It's also possible to do all the above from another device such as a Diamond Computer Room Workstation, or your own machine, provided:

When establishing the connection, you may be asked to "Select the platform of the remote host", and should select "Linux" here.

Note: You won't be able to establish a ROS Network between the robot and any device other than a Robot Laptop (but you can at least interact with the filesystem and run commands on the robot etc.)

Local Deployment Exercises

Here are some exercises that you could have a go at now, based on some of the things that we have done in simulation through Weeks 1-6 of this Wiki.

Exercise 1: Creating a ROS package on the robot's filesystem

As you'll know by now, before we can create any of our own ROS nodes we need to create a ROS package, and we must do this inside a Catkin Workspace. Fortunately, a Catkin Workspace already exists on the robot's filesystem here:

/home/robot/catkin_ws/

Remember though, that you should create your package in its src directory.

  1. To do all this, you'll first need to create a new terminal instance on the robot, which can be achieved in one of two ways (select whichever you prefer, you don't need to do both):

    1. Either, return to the tmux instance that you used to launched ROS (on the robot) earlier (ROBOT 1). From here, use the Ctrl+B, C key combination to create a new tmux window (see here for some tips on using Tmux).
    2. Or, create a new terminal instance from a VS Code Remote - SSH session running on the robot.

    We'll call this new terminal instance ROBOT 2.

  2. In ROBOT 2 navigate to the Catkin Workspace src directory on the robot's filesystem:

     [ROBOT 2] $ cd ~/catkin_ws/src/
    
  3. Use the catkin_create_pkg tool (as you have done in simulation) to create a new ROS package on the robot:

     [ROBOT 2] $ catkin_create_pkg {your package name} rospy
    

    ... replacing {your package name} as appropriate.

  4. Remember that catkin build will not work on the robots, so you'll need to use the following command to run catkin_make instead:

     [ROBOT 2] $ cd ~/catkin_ws && catkin_make
    
  5. You can then re-source the environment using our handy alias:

     [ROBOT 2] $ src
    

Exercise 2: Deploying the move_circle.py Node

Have a go at writing a ROS node (in Python) to control your robot now. Why not try recreating the move_circle.py node that you developed in Week 2?

  1. Make sure that the robot core packages are still running in the ROBOT 1 tmux instance.

  2. Navigate to the src directory of the package that you created in the previous exercise (if you're not already there):

     [ROBOT 2] $ roscd {your package name}/src
    
  3. Create a new Python file (using touch) and make it executable (using chmod)

  4. Start programming! Remember that you can do this in VS Code via a Remote - SSH session.

  5. When you're ready, you can launch your node using the rosrun command (remember: rosrun {your package name} {script name}). Alternatively, you could create a launch file to launch your node using roslaunch...

Exercise 3: Odometry-based navigation

The first exercise in the Week 3 Lab required you to develop an odometry-based controller for your simulated robot, with the aim of making the robot follow a square path. Have a go at implementing this on a real robot now.

  1. Create a new Python file on the robot, inside the src directory of the package that you created previously.

  2. Start programming your node:

    1. Perhaps you already created a good move_square.py node in the WSL-ROS environment during the Week 3 lab?

    2. If not, take a look at this worked example (University of Sheffield only).

    3. Tom also demonstrated a waypoint-based approach during COM2009 Lecture 9, have a look at that one too if you want to (COM2009 students only).

    4. Or, use the move_square template from Week 3 and create a new odometry-based controller yourself!

Local Deployment Summary

The robots run headless (i.e. without a display!) and therefore cannot run any graphical applications. You therefore can't run any processes that require RViz, Gazebo or anything rqt-based. Any nodes requiring this sort of functionality should be executed remotely on the Robot Laptops instead, which is discussed in the next section.

When you can though, it may be more reliable/efficient to run nodes locally (i.e. on the robot) rather than remotely (on the laptop) for certain tasks such as:

  1. Open-loop velocity control (such as that discussed in Exercise 2).
  2. Closed-loop (odometry-based) velocity control (such as that discussed in Exercise 3).
  3. Closed-loop velocity control with LiDAR-based obstacle avoidance.
  4. On-board object detection that doesn't use any of the cv2 image display functions (e.g. cv2.imshow())

On the next page, we'll discuss how to introduce an additional device onto the ROS network (i.e. a laptop) and take advantage of the ROS visualisation tools that allow us to see what our robot "sees"...

Wrapping Up

When you're finished working with a robot, remember that it needs to be shut down properly.

  1. First, close down any active processes that are running on the robot by checking through all of your open ROBOT terminals and stopping these processes using Ctrl+C.

  2. Then, shut down the robot by entering the following command in ROBOT 1:

     [ROBOT 1] $ off
    

    Enter the password when asked then wait for the "Connection to dia-waffleX closed" message.

Real Robot Lab Instructions:
← Getting Started [Previous] | [Next] 'Remote' Deployment →

Clone this wiki locally