A raspberry pi zero, the Main Computer, calculates state, balance and dynamics. A pi pico is the low level motor controller and sensor reader.
Download the repo to a raspberry pi zero (or another SBC).
Requirements:
- C++ 17
- cmake 3.23+
- Eigen 3.4.8
- python 3.11
- main computer requires pyserial
- base python dependencies handled by uv
- rapidxml
- googletest 1.17 (installed by cmake)
- wiringPi (
apt-get install libwiringpi-devto build on ubuntu) - MPU6050 pico code: https://github.com/NirajPatelRobots/pico-examples
To develop for pico on a non-pi computer: https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf
-
To develop for pico on the Zero, go to https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf Chapter 1 "Quick Pico Setup"
-
In the microcontroller/ directory, build the pico program:
mkdir microcontroller/build export PICO_SDK_PATH=~/pico/pico-sdk/ cp ~/pico/pico-sdk/external/pico_sdk_import.cmake microcontroller/ cd microcontroller/build cmake .. make -
Unplug the pico, then hold down the BOOTSEL button on the pico. Plug in the pico and keep the button held down until the green light on the zero stabilizes.
-
Check the pico is connected, then load the built .uf2 file onto the pico:
sudo picotool info -a sudo picotool load <name>.uf2 -v -x
To read output from printf, use USB. Can change to UART in CMakeLists.txt.
minicom -b 115200 -o -D /dev/ttyACM0 to listen to the output. To exit minicom, use CTRL-A followed by X.
In the simplewalker/build folder of the repository, run
cmake .. # once, to set up cmake
make simplewalker
cd ..
build/simplewalker
to make and run the main program.
The built executables are simplewalker, test_localization, unittests, and collect_sensor_cal_data.
collect_sensor_cal_data saves files in data/stationary_calibration_[number].log.
Copy these to the base computer and run sensorAnalysis.py on them to get sensor calibration values.
- To collect motor calibration data, run
python3 runMotorCalibration.pyon the main computer (SBC). - Copy that data to the Base computer with
rsync -zic pi@raspberrypi:/home/pi/simplewalker/data/*.motortest ./data/. - To run the calibration and get motor parameters, run
uv run --extra calibration calibrate/calibrate.py [file_glob] - To run the interactive calibration with a UI, run
uv run --extra interactive_calibration calibrate/interactive_calibrate.py - To run the motor calibration as a notebook, run
uv run -w jupyter -w ipympl --extra interactive_calibration jupyter lab
Build Simplewalker and Build Simplewalker Microcontroller jobs do what it sounds like they do.
Build Simplewalker also runs unit tests and test_localization, which is printed to job results.
Calibrate Motor runs motor calibration on checked-in motor test data and prints results to job results.
Niraj made this