Skip to content

Run Robots

r4a repository contains the following run files:

  1. run_analytical_model.py
    • Only run analytical model
  2. run_hardware.py
    • Only run hardware
  3. run_hardware_mocap.py
    • run Hardware, MoCap, and analytical model

We mainly use the 3. run_hardware_mocap.py for data collection.


Run Analytical Model

  1. Open "run_analytical_model.py"
  2. Run the code (Click a Run button in IDE, or in terminal python -m run_analytical_model.py)
  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.

Note

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 "run_hardware.py"
  3. The code will establish connection automatically
  4. Then you can run your robot around

Info

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 "run_hardware_mocap.py"
  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++)

Info

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!

Activities