Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/frontend_CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Frontend CI

on:
push:
branches:
- '**'
paths:
- 'frontend/**'
- '.github/workflows/frontend_CI.yml'
pull_request:
branches:
- '**'
paths:
- 'frontend/**'
- '.github/workflows/frontend_CI.yml'

jobs:
typecheck-and-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install dependencies
run: npm ci

- name: Type check
run: npm run typecheck

- name: Build
run: npm run build
52 changes: 52 additions & 0 deletions .github/workflows/motor_microcontroller_CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Motor Microcontroller CI

on:
workflow_dispatch:
push:
branches:
- "**"
paths:
- "firmware/motor_microcontroller/**"
pull_request:
branches:
- "**"
paths:
- "firmware/motor_microcontroller/**"

jobs:
build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install PlatformIO Core
run: |
curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
python3 get-platformio.py
mkdir -p /usr/local/bin
ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio
ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio
ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb
- name: Copy custom ROS interfaces
run: |
mkdir -p firmware/motor_microcontroller/extra_packages
cp -r src/autogiro_interfaces firmware/motor_microcontroller/extra_packages/
- name: Build PlatformIO Project
run: pio run -e pico -e ROS
working-directory: firmware/motor_microcontroller
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
name: motor_firmware.uf2
path: firmware/motor_microcontroller/.pio/build/ROS/firmware.uf2
if-no-files-found: warn
52 changes: 52 additions & 0 deletions .github/workflows/sensor_microcontroller_CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Sensor Microcontroller CI

on:
workflow_dispatch:
push:
branches:
- "**"
paths:
- "firmware/sensor_microcontroller/**"
pull_request:
branches:
- "**"
paths:
- "firmware/sensor_microcontroller/**"

jobs:
build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install PlatformIO Core
run: |
curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
python3 get-platformio.py
mkdir -p /usr/local/bin
ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio
ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio
ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb
- name: Copy custom ROS interfaces
run: |
mkdir -p firmware/sensor_microcontroller/extra_packages
cp -r src/autogiro_interfaces firmware/sensor_microcontroller/extra_packages/
- name: Build PlatformIO Project
run: pio run -e regular -e ROS
working-directory: firmware/sensor_microcontroller
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
name: sensor_firmware.uf2
path: firmware/sensor_microcontroller/.pio/build/ROS/firmware.uf2
if-no-files-found: warn
8 changes: 8 additions & 0 deletions firmware/motor_microcontroller/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.idea
.vscode
.DS_Store
5 changes: 5 additions & 0 deletions firmware/motor_microcontroller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[![PlatformIO CI](https://github.com/WheelchairSeniorDesign/MotorMicrocontroller/actions/workflows/Platformio_CI.yml/badge.svg)](https://github.com/WheelchairSeniorDesign/MotorMicrocontroller/actions/workflows/Platformio_CI.yml)

# MotorMicrocontroller

Brake, Enable, Direction (per each motor), DAC clock, DAC data
27 changes: 27 additions & 0 deletions firmware/motor_microcontroller/include/BatteryFunctions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Created by Laxman on 4/9/25.
//

#ifndef BATTERYFUNCTIONS_H
#define BATTERYFUNCTIONS_H

#include <Arduino.h>
#include "hardware/adc.h"

// ADC pin and configuration
#define ADC_PIN 28
#define VREF 3.3
#define ADC_MAX 4095.0
#define OPAMP_GAIN 10.1
#define VOLTAGE_DIVIDER_RATIO 0.01205

// Battery voltage range
#define BATTERY_VOLTAGE_MAX 27.0
#define BATTERY_VOLTAGE_MIN 21.0

void initBatterySensor();
float readBatteryVoltage();
int8_t calculateBatteryPercentage(float battery_voltage);

#endif // BATTERYFUNCTIONS_H

39 changes: 39 additions & 0 deletions firmware/motor_microcontroller/include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
19 changes: 19 additions & 0 deletions firmware/motor_microcontroller/include/RefSpeed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Created by Robbie on 12/8/24.
//

#ifndef MOTORMICROCONTROLLER_REFSPEED_H
#define MOTORMICROCONTROLLER_REFSPEED_H

#include <Arduino.h>

/**
* Struct representing the reference speed and direction.
*/
struct refSpeed {
int8_t leftSpeed{}; ///< Speed of the left wheel.
int8_t rightSpeed{}; ///< Speed of the right wheel.
};


#endif //MOTORMICROCONTROLLER_REFSPEED_H
11 changes: 11 additions & 0 deletions firmware/motor_microcontroller/include/globals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Created by Robbie on 5/14/25.
//

#ifndef GLOBALS_H
#define GLOBALS_H

extern float speedR;
extern float speedL;

#endif //GLOBALS_H
36 changes: 36 additions & 0 deletions firmware/motor_microcontroller/include/microRosFunctions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Created by leslier on 12/8/2024.
//

#ifndef MOTORMICROCONTROLLER_MICROROSFUNCTIONS_H
#define MOTORMICROCONTROLLER_MICROROSFUNCTIONS_H

#include <Arduino.h>
#include "RefSpeed.h"

extern bool eBrake;


bool create_entities();

void destroy_entities();

void microRosTick();

/**
* Transmits the message over ROS. Not in use right now
* @param /
*/
//void transmitMsg();


/**
* Function to get the reference speed from the ROS topic.
* @return The reference speed using the refSpeed struct.
*/
refSpeed getRefSpeed();


void transmitDac(int16_t leftDacValue, int16_t rightDacValue);

#endif //MOTORMICROCONTROLLER_MICROROSFUNCTIONS_H
46 changes: 46 additions & 0 deletions firmware/motor_microcontroller/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
42 changes: 42 additions & 0 deletions firmware/motor_microcontroller/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:pico]
platform = raspberrypi
board = pico
framework = arduino
lib_deps =
adafruit/Adafruit MCP4725@^2.0.2

[env:ROS]
platform = raspberrypi
board = pico
framework = arduino
lib_deps =
adafruit/Adafruit MCP4725@^2.0.2
https://github.com/micro-ROS/micro_ros_platformio
build_flags =
-D ROS

board_microros_distro = humble
board_microros_transport = serial

[env:ROS-debug]
platform = raspberrypi
board = pico
framework = arduino
lib_deps =
adafruit/Adafruit MCP4725@^2.0.2
https://github.com/micro-ROS/micro_ros_platformio

build_flags =
-D ROS_DEBUG
board_microros_distro = humble
board_microros_transport = serial
Loading