diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4573676 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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/clang-format-action@v4.11.0 + 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 diff --git a/Inc/firmware/hal_compat.hpp b/Inc/firmware/hal_compat.hpp index 4f35a89..24c313d 100644 --- a/Inc/firmware/hal_compat.hpp +++ b/Inc/firmware/hal_compat.hpp @@ -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); } \ No newline at end of file +inline void delay(uint32_t delay_ms) { + HAL_Delay(delay_ms); +} \ No newline at end of file diff --git a/Lib/icm42605/ICM42605.cpp b/Lib/icm42605/ICM42605.cpp index e46fccf..9a22ce3 100644 --- a/Lib/icm42605/ICM42605.cpp +++ b/Lib/icm42605/ICM42605.cpp @@ -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) { diff --git a/Src/firmware/imu_reveiver.cpp b/Src/firmware/imu_reveiver.cpp index fbce89d..9f84951 100644 --- a/Src/firmware/imu_reveiver.cpp +++ b/Src/firmware/imu_reveiver.cpp @@ -24,7 +24,8 @@ void ImuReceiver::update() { temp = static_cast(ICM42605Data[0]) * TEMP_RESOLUTION + TEMP_OFFSET; ax = static_cast(ICM42605Data[2]) * ares_ * GRAVITATIONAL_ACCELERATION; ay = static_cast(ICM42605Data[1]) * ares_ * GRAVITATIONAL_ACCELERATION; - az = -static_cast(ICM42605Data[3]) * ares_ * GRAVITATIONAL_ACCELERATION; + az = + -static_cast(ICM42605Data[3]) * ares_ * GRAVITATIONAL_ACCELERATION; gx = static_cast(ICM42605Data[5]) * gres_ * DEGREE_TO_RADIAN; gy = static_cast(ICM42605Data[4]) * gres_ * DEGREE_TO_RADIAN; gz = -static_cast(ICM42605Data[6]) * gres_ * DEGREE_TO_RADIAN; diff --git a/Src/firmware/motor_controller.cpp b/Src/firmware/motor_controller.cpp index 88b7907..22519f4 100644 --- a/Src/firmware/motor_controller.cpp +++ b/Src/firmware/motor_controller.cpp @@ -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; diff --git a/Src/firmware/parameters.cpp b/Src/firmware/parameters.cpp index 8ab0f20..1b6f7b9 100644 --- a/Src/firmware/parameters.cpp +++ b/Src/firmware/parameters.cpp @@ -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,