Skip to content

Run Robots

r4a repository contains the following run files:

    • Only run analytical model
    • Only run hardware
    • run Hardware, MoCap, and analytical model

We mainly use the 3. for data collection.

Run Analytical Model

  1. Open ""
  2. Run the code (Click a Run button in IDE, or in terminal python -m
  3. After initialization, you start seeing outputs in your terminal with live plots.
model gif
Analytical model with a random keyboad inputs

Analytical model with a random keyboad inputs

  1. You can drive your robot with arrow keys
  2. After the run, you will see an interactive plot which let you replay the motion.


Under /run_outputs/ you should see output files automatically generated. They are timestamped.

Run Hardware

  1. Connect to your robot WiFi: ESP_xxxxx on your PC.
  2. Run ""
  3. The code will establish connection automatically
  4. Then you can run your robot around


Without motion capture system, we cannot get the state of the robot. Hence no graph is generated.

You can still see a CSV file if created that saves your inputs.

Long wait, Connection errors

It will try to connect to the robot over wifi till 30sec timeout.

Some OS may disconnect from ESP wifi since it doesn't have the internet. Please check if you are connected again.

Run Hardware, MoCap, and Analytical Model

  1. Connect webcam to your PC
  2. Open ""
  3. Update your CAMERA_ID
    # TODO: Update your camera ID (usually 0, 1, 2)
    CAMERA_ID = 0    # change it to your camera ID
  4. Connect to your robot WiFi: ESP_xxxxx on your PC.
  5. Run the code. This will take more time to initialize since it will handle three robots (hardware, mocap, model).
  6. You can now drive your robot. You should see a live stream from Mocap and graph from Mocap and analytical model.
  7. After the run all outputs are saved under /run_outputs/
List of all outputs

You should see the following outputs after run:

  • Mocap stream saved in a .AVI file
  • Mocap and model graphs saved in GIF files
  • Mocap and model interactive graphs opened in your web browser
  • Mocap and model interactive graphs saved in .html files
  • Mocap, model, hardware inputs, state, saved in .csv files

These outputs should be saved even if you terminate the code abnormally (i.e. ++ctrl+C++)


MOTOR_SPEED = 6.5 # rad/sec
Will let you change the motor angular speed used in the model. Depending on the state of the robot, you may want to tune this value.

What's Next?

Now you are ready to do experiments. Let's try them out!