Skip to content

Commit

Permalink
Add CI (#2)
Browse files Browse the repository at this point in the history
* Initial Pio Github CI

* Fix Pio environment name

* Add clang-format check

* clang-format: check only cpp and hpp files

* Reformat with clang-format
  • Loading branch information
bjsowa authored Aug 3, 2023
1 parent e331814 commit f064cb5
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 9 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PlatformIO CI

on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
clang-format-check:
name: Clang-format formatting check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check.
uses: jidicula/[email protected]
with:
clang-format-version: '14'
include-regex: ^.*\.(cpp|hpp)$

build:
name: PlatformIO build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Run PlatformIO
run: pio run -e genericSTM32F401RC
12 changes: 9 additions & 3 deletions Inc/firmware/hal_compat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ inline void gpio_toggle(const GPIO& gpio) {
HAL_GPIO_TogglePin(gpio.port, gpio.pin);
}

inline uint32_t time() { return HAL_GetTick(); }
inline uint32_t time() {
return HAL_GetTick();
}

inline void reset() { NVIC_SystemReset(); }
inline void reset() {
NVIC_SystemReset();
}

inline void delay(uint32_t delay_ms) { HAL_Delay(delay_ms); }
inline void delay(uint32_t delay_ms) {
HAL_Delay(delay_ms);
}
4 changes: 3 additions & 1 deletion Lib/icm42605/ICM42605.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

ICM42605::ICM42605(I2C_HandleTypeDef* i2c_bus) : _i2c_bus(i2c_bus) {}

uint8_t ICM42605::getChipID() { return readByte(ICM42605_WHO_AM_I); }
uint8_t ICM42605::getChipID() {
return readByte(ICM42605_WHO_AM_I);
}

float ICM42605::getAres(uint8_t Ascale) {
switch (Ascale) {
Expand Down
3 changes: 2 additions & 1 deletion Src/firmware/imu_reveiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ void ImuReceiver::update() {
temp = static_cast<float>(ICM42605Data[0]) * TEMP_RESOLUTION + TEMP_OFFSET;
ax = static_cast<float>(ICM42605Data[2]) * ares_ * GRAVITATIONAL_ACCELERATION;
ay = static_cast<float>(ICM42605Data[1]) * ares_ * GRAVITATIONAL_ACCELERATION;
az = -static_cast<float>(ICM42605Data[3]) * ares_ * GRAVITATIONAL_ACCELERATION;
az =
-static_cast<float>(ICM42605Data[3]) * ares_ * GRAVITATIONAL_ACCELERATION;
gx = static_cast<float>(ICM42605Data[5]) * gres_ * DEGREE_TO_RADIAN;
gy = static_cast<float>(ICM42605Data[4]) * gres_ * DEGREE_TO_RADIAN;
gz = -static_cast<float>(ICM42605Data[6]) * gres_ * DEGREE_TO_RADIAN;
Expand Down
4 changes: 3 additions & 1 deletion Src/firmware/motor_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ void MotorController::setPWMDutyCycle(float pwm_duty) {
}
}

float MotorController::getPWMDutyCycle() { return pwm_duty_; }
float MotorController::getPWMDutyCycle() {
return pwm_duty_;
}

int32_t MotorController::getEncoderCnt() {
uint16_t ticks_timer = *config_.enc_cnt;
Expand Down
7 changes: 4 additions & 3 deletions Src/firmware/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
static constexpr int TIMEOUT = 1000;

void Parameters::load(ros::NodeHandle &nh) {
nh.getParam("firmware/wheels/encoder_resolution", &wheel_encoder_resolution, 1,
TIMEOUT);
nh.getParam("firmware/wheels/encoder_resolution", &wheel_encoder_resolution,
1, TIMEOUT);
nh.getParam("firmware/wheels/torque_constant", &wheel_torque_constant, 1,
TIMEOUT);
nh.getParam("firmware/wheels/pid/p", &wheel_pid_p, 1, TIMEOUT);
nh.getParam("firmware/wheels/pid/i", &wheel_pid_i, 1, TIMEOUT);
nh.getParam("firmware/wheels/pid/d", &wheel_pid_d, 1, TIMEOUT);
nh.getParam("firmware/wheels/pwm_duty_limit", &wheel_pwm_duty_limit, 1, TIMEOUT);
nh.getParam("firmware/wheels/pwm_duty_limit", &wheel_pwm_duty_limit, 1,
TIMEOUT);

nh.getParam("firmware/diff_drive/wheel_radius", &dd_wheel_radius, 1, TIMEOUT);
nh.getParam("firmware/diff_drive/wheel_separation", &dd_wheel_separation, 1,
Expand Down

0 comments on commit f064cb5

Please sign in to comment.