GithubHelp home page GithubHelp logo

mte380's Introduction

mte380

Background

This repository holds the software developed for MTE380, our third-year design project course. In this iteration of the course, the primary objective was to develop a robot to successfully navigate a 2m x 2m course comprised of various types of terrain.

Watch it in action here!

Hardware

The microcontroller used on the robot is a STM32 NUCLEO-F446RE.

The following sensors were used to determine the robot's position in the course:

  • Three VL53L0X time-of-flight (ToF) sensors, one forward-facing and two left-facing.
  • An ICM20948 9-DoF inertial measurement unit (IMU) to detect the robot's rotation.
  • A downward-facing photoresistor to measure the colour of the terrain below.

The robot was moved by controlling four brushed DC micro metal gearmotors using two L298N motor controllers.

Software

Robot Microcontroller

The embedded C written to govern the robot's movement can be found in mte380/stm32. To run it, a recent STM32CubeIDE install is required. Importing mte380/stm32 into STM32CubeIDE should be possible, but will likely require some troubleshooting.

The robot code consists of the following modules:

Module Filename Function
main main.c Driver initialization and superloop calling course correction and position determination functions.
IMU Tracking imu_tracking.c Functionality to calculate the robot's rotation about the x-axis by numerically integrating each rotational veloicty reading. Used to determine whether the robot's chassis is parallel to the ground, which can affect ToF readings.
Motor Controller Driver l298n_motor_controller.c Motor controller driver.
Logger logger.c Creates a large buffer to store logs to and outputs logs over serial when requested.
Movement movement.c Governs acceleration, enging braking, and turning.
Photoresistor Driver photoresistor.c Uses an ADC to estimate the photoresistor's resistance and evaluate the type of surface the robot is above.
Positioning position.c Reads from the side ToFs and uses them to make slight corrections to keep the robot heading straight. Reads from the front ToF to assess when to stop and turn.
Position Tracking position_tracking.c Very similar to imu_tracking.c. Tracks readings from the front-facing ToF to attempt to discard erroneous readings. Currently unused.

Scripts

Some basic python scripts to read logs over serial and graph the data generated by logger.c can be found at mte380/scripts. Below is an example graph generated by the scripting software:

Section_0 Section_1 Section_2 Section_3

UART Forwarding

To be able to read the logs generated by logger.c and feed, it was necessary to have a way to connect UART to a computer after previously disconnecting the NUCLEO's ST-Link. Due to how the onboard ST-Link works, a reconnection will trigger a reset of the micro and loss of the logs. The workaround for this is to flash the code found in uart_forward to a second STM32 NUCLEO-F401RE, and connect UART6 on that board to UART6 on the onboard robot microcontroller. The logs generated by the robot are read by the F401RE and sent to the computer running the scripts over serial, avoiding the reset.

Credits

The driver used for the VL53L0X ToF sensor can be found here. It is designed primarily for taking single measurements with polling, but we are using the ToF sensor in continuous ranging mode.

The driver used for the ICM20948 IMU can be found here.

These drivers are licensed under their own respective license terms rather than those of this repository.

mte380's People

Contributors

hewittmcg avatar ehuq avatar yg3010 avatar a37jones avatar nzalewsk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

mte380's Issues

Add linter

STM32CubeIDE sucks for code styling/indentation consistency

ToF sensor continuous ranging with interrupts

We can save a lot of time by using interrupts and continuous ranging with the ToF sensors to avoid the current blocking polling architecture.

Psuedocode for main() after this change:

main:
  if flag_side_front and flag_side_rear:
    read from front and rear ToF sensors, do course correction

  if flag_forward:
    check if wall and turn if needed

  read IMU values (if implemented)

More accurate course correction

General improvements to the course correction P-loop and related functionality. Considerations include:

  • Refactor some of the calculations that are repeated or mostly repeated
  • Add tracking for each leg of the course and where we should be stopping, how far we should be from the wall etc
  • Instead of just blindly correcting, attempt to correct to the centre of the path that we should be following
  • Potentially use a PD-loop
  • Depending on how far off the path we are, possibly slow down so that we can correct without going way off track
  • Correct immediately after turning to avoid getting way off course before course correction kicks in

Data logging

Log data so we can view it after the run is over, probably use a Python script to graph things like mag readings over time etc

Use engine braking to stop

Currently, to stop we just turn all motors off and coast. We can likely improve our stopping distance by briefly driving all motors in reverse.

TOF Data averaging

We should be storing some of the TOF data for the side sensors and keep an average reading to try and identify erroneous data if it exists

Motor controller driver improvements

  • Track speed of each motor and add function to return it when needed
  • Change to control motors entirely using the set speed function (i.e. negative values represent going backwards)

Get printf working

We can't printf over UART, but it would be very helpful in debugging.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.