This repository contains the STM32CubeIde project with the firmware to control a 4WD rover. The software and pinout has been customized to the STM32 F767ZITX microcontroller, but using STM32CubeMx it can be easily ported to other STM32 targets that support CUBEMx HAL.
History - Why 'Next Generation'?
This version is an improvement over previous implementations:
- v1. An initial implementation with Arduino Due / Raspberry Pi. This included the ROS software running in a Raspberry PI and a x86 for GroundControl:
- v2. A migration to Nucleo-f767zi with MBedOs with a lightweight Python client.
- v3. This version:
- Better task/code modularization with FreeRTOS.
- Portability across STM32 boards.
- Benefit from STM32CubeHal to choose the best peripheral configuration (hardware PWM and tick count, etc.).
Requirements
- Hardware:
- Nucleo-f767zi.
- Sensors:
- Actuators:
- 4WD Chassis kit
- 4x DC Motors wtih gear reduction + wheels.
- 1x Battery holder x2 18650 (8.4v).
- 2x 18650 batteries.
- Software:
- STM32CubeIde
- Python 3+ (tested in Conda base enviroment).
The hardware setup section describes the pin assignment.
Procedure
- Import project in STM32CubeIde and download to Nucleo.
- Communicate with the firmware with the Python notebooks or with the Playstation 4 controller.
Finding a good workflow for using HAL and FreeRTOS in STM32CubeIde is still under a stage of learning, trial, and error.
Trying to get the best of both worlds, the code organization attempts to:
- Benefit from STM32CubeMx code generation for HAL and FreeRTOS, which involves regenerating periodically the
main.c
file and other files inCore
. Note that at the time of this writing, STM32CubeMx does not support C++ so some workarounds are required to call C++ methods from C boilerplate. Also, FreeRTOS API is in C. - Separate application logic from HAL/FreeRTOS resource creation.
Core
├── Inc
│ ├── FreeRTOSConfig.h
│ ├── main.h
│ ├── stm32f7xx_hal_conf.h
│ └── stm32f7xx_it.h
├── Src
│ ├── freertos.c
│ ├── main.c
│ ├── stm32f7xx_hal_msp.c
│ ├── stm32f7xx_hal_timebase_tim.c
│ ├── stm32f7xx_it.c
│ ├── syscalls.c
│ ├── sysmem.c
│ └── system_stm32f7xx.c
└── Startup
└── startup_stm32f767zitx.s
Application/
├── Inc
│ ├── ApplicationConfig.h
│ ├── Application.h
│ ├── Protocol
│ │ ├── decoder.hpp
│ │ ├── encoder.hpp
│ │ └── protocol.hpp
│ ├── Services
│ │ ├── CommandReceiver.h
│ │ └── TelemetrySender.h
│ ├── Telecommands.h
│ └── Telemetry.h
└── Src
├── Application.cpp
├── Protocol
│ └── protocol.cpp
└── Services
├── CommandReceiver
│ └── CommandReceiver.cpp
└── TelemetrySender
└── TelemetrySender.cpp
- Python code and notebooks are provided to interact with the Rover.
Refer to Raspberry Pi software setup section for instructions on how to teleoperate the rover and receive live video.