Skip to content

Upload motion control scripts

The HomeR's motion control is relying on a series of MicroPython scripts running on the Pico board. Please follow the steps below to get the Pico ready for driving HomeR and sensing its motion status.

Note

If you haven't, please set up the Pico before move on.

Hardware List

  • A Raspberry Pi Pico 2 development board (Pico).
  • A Computer (Desktop/Laptop/RPi)
  • A Micro-USB cable.
  • (Optional) The relay PCB: HomeR Thalamus

0. Preparation

Install dependencies and grant the user the permission to access Pico

sudo apt install python3-pip
pip install rshell --break-system-packages
sudo usermod -aG dialout $USER

1. Set Up homer_pico on Pico

  1. Download and navigate to the repository.

    cd ~  # navigate to $HOME directory
    git clone https://github.com/linzhanguca/homer_pico.git
    cd homer_pico
    
  2. Upload differential drive control and motion monitor scripts

    rshell cp -r upython_scripts/drivetrain /pyboard/
    rshell cp -r upython_scripts/perception /pyboard/
    
  3. Set up automatic communication using pico_messenger.py.

    rshell cp upython_scripts/pico_messenger.py /pyboard/main.py
    

    Note

    A hard reset (unplug Pico then plug it back) is required to activate main.py.

  4. Verify communication

    python3 tests/computer_messenger.py
    
    Both wheels will start to ramp the speed up and down then repeat with opposite direction. !!! bug "Communication Failure" In case the computer failed to spin the wheels, you may want to unplug the Pico and plug it back in.

2. Motion control scripts

The HomeR's motion control is a modular design made up by the following scripts. It is highly recommended to test functionality of each module by the order.

Lift Wheels

It is very important that the motorized wheels are not contacting anything during the tests. Lift up the robot by putting it on top of something (e.g. a box). Check the wires and cables so that they are free from getting tangled.

2.1. base_motor.py

This script contains the BaseMotor class. It is featured methods/functions to invoke, stop and drive a brushed DC motor using a "Phase/Enable" type of motor driver chip (DRV8874). The usage examples and testing code is located under the line: if __name__ == "__main__":. Run this script to ramp up and down the speed of a motor in both forward and backward directions.

2.2. encoded_motor.py

This script extends the BaseMotor as the EncodedMotor class. It adds methods/functions to count the signal changes sensed by a quadrature encoder attached to the motor. Run this script to read the encoder counts while the motor speed is ramping up and down.

2.3. sentient_wheel.py

This script extends the EncodedMotor as the SentientWheel class. It takes the characteristics of the wheel attached to the motor into account. Run this script to read the wheel's linear and angular velocity as it is ramping up and down.

2.4. regulated_wheel.py

This script extends the SentientWheel as the RegulatedWheel class. It adds a PID controller to regulate the motor's velocity. Run this script to set a target linear velocity for the wheel. The PID controller will assess the gap between the measured velocity and target velocity to adjust control signals.

2.5. diff_drive_controller.py

This scripts instantiates two RegulatedWheels to construct the DiffDriveController class. It regulates individual wheel's velocity based on

3. Motion sense scripts

Coming soon.