DukeRobotics / robosub-ros

ROS system to control a robot for the RoboSub Competition.
https://duke-robotics.com
28 stars 25 forks source link

Duke Robotics Club - RoboSub ROS

Build Docker Pulls

We are a Duke University club competing in the RoboSub Competition. Check out our website.

Our codebase is split into two repositories:

  1. This repo contains all of the code required for running and testing our robots.
  2. The documentation repo contains introductory projects, tutorials, and miscellaneous docs.

Our code is Dockerized, making it straightforward to set up and run. See Running Our Docker Images.

Once the containers are up and running, go to Running Our Code.

Software Stack

Our stack is split into two workspaces -- onboard and landside -- each with corresponding Docker containers of the same name. Onboard consists of the code that runs on the robot's internal computer. Landside consists of the code that should be run on your local machine. The corresponding containers are connected via a local network and are configured to share ROS messages. For an in-depth explanation of the containers, see docker.

Our codebase is powered by the Robot Operating System (ROS), and written primarily in Python.

The following components make up our software stack:

Flow

The general flow of information between components is shown in the diagram below, from top to bottom:

        sensors (IMU, DVL, etc.)                cameras
            \                                     / \
             \                                   /   \
              v                                 /     v
            Data Pub                           /   Camera View
                \                             /
 Simulation ---> \          Acoustics        /
                  v             |            v
                Sensor Fusion   |      Computer Vision
                    \           |         /
                     \          |        /
                      v         v       v
                         Task Planning
                               |
                               |
                               v
              Joystick ---> Controls
                               |
                               | ---> Simulation
                               v
                         Offboard Comms
                               |
                               |
                               v
                    thrusters, actuators, etc.

Running Our Docker Images

Required Software

  1. Download and install the appropriate Docker client.

  2. If you want graphics forwarding over SSH:

Pool Testing

Use these instructions when running code on the robot itself.

  1. Connect your computer to the robot via Ethernet. Then SSH into the robot's onboard computer.
    ssh robot@192.168.1.1
  2. There, make sure the latest code from this repo is pulled. Then, run the onboard container if it's not already running.
    docker run -td --privileged --net=host -e ROBOT_NAME=oogway -v /home/robot/robosub-ros:/root/dev/robosub-ros -v /dev:/dev dukerobotics/robosub-ros:onboard
  3. Clone this repo on your local computer. In the newly-created directory (robosub-ros), run the landside container. If on Windows, use PowerShell.
    docker run -td -p 2201:2201 -v ${PWD}:/root/dev/robosub-ros dukerobotics/robosub-ros:landside
  4. SSH into the onboard container. Password is robotics.
    ssh -p 2200 root@192.168.1.1
  5. SSH into the landside container. Password is robotics.
    ssh -XY -p 2201 root@localhost
  6. Now go to Running Our Code.

Local Testing

Use these instructions to test code on your computer by simulating the robot's execution. For all docker compose commands, replace <robot name here> with the robot name (cthulhu or oogway).

  1. To run the containers, clone this repo. In the newly-created directory (robosub-ros), execute

    docker-compose -f docker-compose-<robot name here>.yml up -d

    This will pull the images if you don't have them, create a new network that simulates the network we use on our robot, mount the code, and start the containers.

    To update the images, or to just pull them without running them, use docker-compose -f docker-compose-<robot name here>.yml pull.

  2. SSH into the onboard container. Password is robotics.

    ssh -p 2200 root@localhost
  3. In a new tab, SSH into the landside container. Password is robotics.

    ssh -XY -p 2201 root@localhost
  4. Now go to Running Our Code. Also set up our simulation.

  5. To stop and delete both containers and their network, in the robosub-ros directory, execute

    docker-compose -f docker-compose-<robot name here>.yml down

Running Our Code

:warning: All commands should be run inside of a Docker container.

Building and Sourcing

The following needs to be done once at the beginning, and then later only when making larger structural changes to the workspace (such as adding a package).

Executing Build Script

We use a custom build script that simplifies the process of building and overlaying catkin workspaces.

To build our workspaces for ROS, in the ~/dev/robosub-ros directory, execute

./build.sh <workspace>

where <workspace> is the workspace to build, either onboard or landside.

Sourcing Setup File

Once the build script has finished executing, source the setup file using

source <workspace>/catkin_ws/devel/setup.bash

where <workspace> is the workspace you just built. This will also be the last line that is printed from the build script, so you can also just copy and execute that.

You should now be ready to use our packages and ROS.

Running Launch Files

Here are some common launch configurations for both pool and local testing.

Cleaning Build

To clean the build outputs from a workspace (build, devel, and logs folders), in the ~/dev/robosub-ros directory, execute

./build.sh clean <workspace>

where <workspace> is either onboard or landside. If you would like to clean all workspaces, then you may simply execute

./build.sh clean

Contributing

To contribute to this repository, see CONTRIBUTING.md.