Skip to content

opatiny/ms-software

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Algernon micromouse software

This repository contains all of the software that was written for my custom micromouse robot. It is a PlatformIO project, based on an esp32-s3-devkitc-1 board and using the Arduino framework.

To access all of the hardware files, as well as more documentation on this project, checkout the following repository: opatiny/micromouse. The debug web page code is also in a separate repository: opatiny/ms-webpage

Code structure

This project uses FreeRTOS, a real time operating system for microcontroller. This allows us to have multiple tasks that are running concurrently. In our case, we have 15 different tasks. This project is initially based on the hackuarium/esp32-s3 repository, which gave us a code base to work with. The tasks that were taken from that repository are in the lib/Hack folder, whereas our fully custom tasks are in src/tasks. Some of the tasks that were copied still had to be modified for our own application. All of the utilities that we developed were also place in the lib folder in lib/utilities

Here is the list of all the tasks that are running on our robot, as well as what they are responsible for.

Tasks reused from hackuarium/esp32-s3

  • taskBlink: Lowest priority task, which makes an LED blink at all times. Allows to see if the device crashes.
  • taskEventSourceSender: Allows to post messages for different topics over WiFi.
  • taskGY521: Accelerometer task.
  • taskSerial: Handles the "serial parameters", a custom system to store variables in the EEPROM and read and write to them using the serial interface. More about in the next section.
  • taskWebServer: Allows to open an HTTP connection over WiFi and continuously send data.
  • taskWifi: Responsible for managing the connection of the device to an existing WiFi rooter.
  • taskWire: Manages the I2C devices, allows to scan the I2C buses to detect the connected devices.

Custom tasks

  • taskButton: Handles the push button.
  • taskBuzzer: Controls the buzzer, allows to make various sounds depending on the mode, which can be modified in any other task.
  • taskCalibrateSpeed: Task for an automatic speed calibration of the wheels. This allows to establish the feedforward controller for the wheels speed.
  • taskEncodersX4: Handles the encoders data, counts the encoder pulses and computes the motors' speeds.
  • taskOdometry: Allows to track the robot's position and orientation.
  • taskRgbLed: Control of the RBG LED brightness and color.
  • taskRobotMove: Manages the robot's speed. They are different control modes. Either the motors' duty cycle is set for each wheel, or a desired rpm speed is set for both wheels at the same time. Finally, the robot's speed can be controlled directly, using speed regulators.
  • taskVL53L1X: Handles the 5 distance sensors.
  • taskVoltage: Measurement of the battery voltage.

All of the tasks are called in the main program: src/main.cpp, which allows to easily enable or disable them as needed.

More documentation

The docs folder of this repository contains more md files with useful information:

  • setupAndTasks.md: Explanation about how to set up platformio, as well as how some of the tasks were implemented.
  • unitTesting.md: Documentation on how to do basic cpp unit testing of functions.
  • serialParameters.md: Documentation about the serial interface of the robot.

Final debug web page screenshots