Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add v3 build #41

Merged
merged 4 commits into from
Jul 1, 2024
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
12 changes: 9 additions & 3 deletions .github/workflows/dronecan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ jobs:
stm32f103:
strategy:
matrix:
os: [ubuntu-22.04, windows-latest]
include:
- os: ubuntu-22.04
platform: v2
- os: ubuntu-22.04
platform: v3
- os: windows-latest
platform: v2
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
Expand All @@ -30,10 +36,10 @@ jobs:
shell: bash

- name: Build DroneCAN binary
run: make dronecan
run: make dronecan_${{ matrix.platform }}

- name: Upload .bin file
if: matrix.os == 'ubuntu-22.04'
if: matrix.os == 'ubuntu-22.04' && matrix.platform == 'v2'
uses: actions/upload-artifact@v3
with:
name: dronecan_firmware.bin
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ elseif(USE_PLATFORM_NODE_V2)
elseif(USE_PLATFORM_NODE_V3)
set(LIBPARAMS_PLATFORM stm32g0b1)
set(CAN_PLATFORM fdcan)
set(APP_PLATFORM stm32f103)
set(APP_PLATFORM stm32g0b1)
include(${CMAKE_DIR}/stm32g0b1.cmake)
else()
message(SEND_ERROR "Platform Error: Either v2 (stm32f103), v3 (stm32g0) or SITL (Linux) should be specified.")
Expand Down
2 changes: 1 addition & 1 deletion Libs/Cyphal
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,30 @@ generate_dsdl:
else \
echo "[INFO] Cyphal DSDL: already generated. Skip."; \
fi
cyphal: checks generate_dsdl clean
cyphal: cyphal_v2
cyphal_v2: checks generate_dsdl clean
mkdir -p ${BUILD_OBJ_DIR}
cd ${BUILD_OBJ_DIR} && cmake -DCAN_PROTOCOL=cyphal -DUSE_PLATFORM_NODE_V2=ON -G "Unix Makefiles" ../.. && make
sitl_cyphal: checks generate_dsdl clean
mkdir -p ${BUILD_OBJ_DIR}
cd ${BUILD_OBJ_DIR} && cmake -DCAN_PROTOCOL=cyphal -DUSE_PLATFORM_UBUNTU=ON -G "Unix Makefiles" ../.. && make
cyphal_v3: checks generate_dsdl clean
mkdir -p ${BUILD_OBJ_DIR}
cd ${BUILD_OBJ_DIR} && cmake -DCAN_PROTOCOL=cyphal -DUSE_PLATFORM_NODE_V3=ON -G "Unix Makefiles" ../.. && make

# Dronecan:
dronecan: checks clean
dronecan: dronecan_v2
dronecan_v2: checks clean
mkdir -p ${BUILD_OBJ_DIR}
cd ${BUILD_OBJ_DIR} && cmake -DCAN_PROTOCOL=dronecan -DUSE_PLATFORM_NODE_V2=ON -G "Unix Makefiles" ../.. && make
sitl_dronecan: checks clean
mkdir -p ${BUILD_OBJ_DIR}
cd ${BUILD_OBJ_DIR} && cmake -DCAN_PROTOCOL=dronecan -DUSE_PLATFORM_UBUNTU=ON -G "Unix Makefiles" ../.. && make
dronecan_v3: checks clean
# --branch dc90159
if [ ! -d "build/ioc-v3" ]; then git clone --depth 1 https://github.com/RaccoonLabHardware/v3-software-template.git build/ioc-v3; fi
mkdir -p ${BUILD_OBJ_DIR}
cd ${BUILD_OBJ_DIR} && cmake -DCAN_PROTOCOL=dronecan -DUSE_PLATFORM_NODE_V3=ON -G "Unix Makefiles" ../.. && make

# Common:
checks:
Expand Down
56 changes: 41 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,65 @@

# Mini v2 Cyphal/DroneCAN application template

This repo introduces a simple ready-to-use Cyphal/DroneCAN application template for [RL Mini v2](https://docs.raccoonlab.co/guide/can_pwm/can_pwm_mini_v2.html) node.
This repo introduces a simple ready-to-use Cyphal/DroneCAN application template for [RL Mini v2](https://docs.raccoonlab.co/guide/can_pwm/can_pwm_mini_v2.html) and [RL Mini v3](https://docs.raccoonlab.co/guide/can_pwm/mini_v3.html) nodes.

Please, refer Wiki for details:
- [Cyphal template application](https://github.com/RaccoonlabDev/mini_v2_node/wiki/Cyphal-application),
- [DroneCAN template application](https://github.com/RaccoonlabDev/mini_v2_node/wiki/DroneCAN-application).

### 1. Key features

- Minimal recommended Cyphal features are supported out of the box (bootloader and DNA are coming next),
- Minimal recommended Cyphal features are supported out of the box,
- You can run the software in SITL mode (don't need to have any hardware),
- Cyphal firmware binary is only 35.2 KB.

### 2. Brief hardware info
Not suported yet / In Roadmap:
- Both Cyphal/CAN and DroneCAN protocols in a single firmware
- Bootloader
- Dynamics Node Allocation (DNA)
- MPU-9250 IMU (node v3)
- Redundant CAN interface (node v3)
- CAN terminator resistors control (node v3)

| Top view | Bottom view | Pinout | STM32CubeMX |
| --- | ------ |-|-|
| <img src="https://docs.raccoonlab.co/assets/img/view_top.6b0ef99e.png" alt="drawing" width="200"> | <img src="https://docs.raccoonlab.co/assets/img/view_bottom.ee41f6d5.png" alt="drawing" width="200"> | <img src="https://docs.raccoonlab.co/assets/img/pinout.c14a3021.png" alt="drawing" width="200"> | <img src="https://raw.githubusercontent.com/RaccoonLabHardware/mini_v2_stm32cubemx_project/main/Assets/stm32cubemx.png" alt="drawing" width="200"> |
### 2. Supported boards

### 3. Brief Cyphal capabilities
The software supports RL v2 nodes (stm32f103, 128 KBytes flash) and v3 nodes (stm32g0b1, 512 KBytes flash).

By default the application is as simple as possible. It just blinks the RGB LED, subscribes to the setpoint topic to control a single PWM (PWM1) and publishes a feedback with the latest applied setpoint. It doesn't have any safety features like TTL, but you are free to extend it as you want.
| Name | View | Pinout | STM32CubeMX |
| ---- | ---- | ------ | ----------- |
| Mini v2 | <img src="https://docs.raccoonlab.co/assets/img/view_top.6b0ef99e.png" alt="drawing" width="150"> | <img src="https://docs.raccoonlab.co/assets/img/pinout.c14a3021.png" alt="drawing" width="150"> | <img src="https://raw.githubusercontent.com/RaccoonLabHardware/mini_v2_stm32cubemx_project/main/Assets/stm32cubemx.png" alt="drawing" width="200"> |
| Mini v3 | <img src="https://docs.raccoonlab.co/assets/img/t-view-bottom.7eadba26.png" alt="drawing" width="150"> | <img src="https://docs.raccoonlab.co/assets/img/pinout.e7b1d6b7.png" alt="drawing" width="150"> | <img src="https://github.com/RaccoonLabHardware/v3-software-template/blob/main/Assets/stm32cubemx.png" alt="drawing" width="200"> |

The default capabilities of the node are shown on the picture below:
### 3. Brief Cyphal/DroneCAN capabilities

<img src="https://raw.githubusercontent.com/wiki/RaccoonlabDev/mini_v2_node/assets/yukon.png" alt="drawing">
You can build the software either for Cyphal/CAN or DroneCAN. By default both applications are as simple as possible. They:
- subscribe on setpoint topics and control PWM1-4 channels,
- measure 5v and Vin voltage, temperature, current (if supported) and publish as circuit status and actuator feedback,
- blink the RGB LED to indicate the current state.

### 4. Brief DroneCAN capabilities
In the table below you can see interfaces of the applications.

The application subscribes on a message configured in `pwm.cmd_type`. It supports: [esc.RawCommand](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#rawcommand), [actuator.ArrayCommand](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#arraycommand), [hardpoint.Command](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#command-1). It controls the PWM and sends back [esc.Status](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#status-2), [actuator.Status](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#status), [hardpoint.Status](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#status-3) as feedback. It also sends [power.CircuitStatus](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#circuitstatus) with the circuit state (5v voltage, vin voltage, current) and [device.Temperature](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#temperature) with stm32 internal measured temperature.
| Cyphal/CAN | DroneCAN |
| ---------- | -------- |
| Subscribe on: </br> - setpoint ([reg.udral.service.actuator.common.sp.Vector31](https://github.com/OpenCyphal/public_regulated_data_types/blob/master/reg/udral/service/actuator/common/sp/Vector31.0.1.dsdl)) </br> </br> </br> Publish: </br> - feedback ([reg.udral.service.actuator.common.Feedback](https://github.com/OpenCyphal/public_regulated_data_types/blob/master/reg/udral/service/actuator/common/Feedback.0.1.dsdl)) </br> - crct.5v ([uavcan.si.unit.voltage.Scalar](https://github.com/OpenCyphal/public_regulated_data_types/blob/master/uavcan/si/unit/voltage/Scalar.1.0.dsdl)) </br> - crct.vin ([uavcan.si.unit.voltage.Scalar](https://github.com/OpenCyphal/public_regulated_data_types/blob/master/uavcan/si/unit/voltage/Scalar.1.0.dsdl)) </br> - crct.temp ([uavcan.si.unit.temperature.Scalar](https://github.com/OpenCyphal/public_regulated_data_types/blob/master/uavcan/si/unit/temperature/Scalar.1.0.dsdl)) </br> . | Subscribe on: </br> - [uavcan.equipment.esc.RawCommand](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#rawcommand) </br> - [uavcan.equipment.actuator.ArrayComman](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#arraycommand) </br> - [uavcan.equipment.hardpoint.Command](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#command-1) </br> Publish: </br > - [uavcan.equipment.esc.Status](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#status-2) </br > - [uavcan.equipment.actuator.Status](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#status) </br > - [uavcan.equipment.hardpoint.Status](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#status-3) </br > - [uavcan.equipment.power.CircuitStatus](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#circuitstatus) </br> - [uavcan.equipment.device.Temperature](https://dronecan.github.io/Specification/7._List_of_standard_data_types/#temperature) |
| <img src="https://raw.githubusercontent.com/wiki/RaccoonlabDev/mini_v2_node/assets/yukon.png" alt="drawing" width=450> | <img src="https://raw.githubusercontent.com/wiki/RaccoonlabDev/mini_v2_node/assets/dronecan_interface.png" alt="drawing" width=152> <img src="https://raw.githubusercontent.com/wiki/RaccoonlabDev/mini_v2_node/assets/dronecan_params.png" alt="drawing" width=147> |

|||
|-|-|
| <img src="https://raw.githubusercontent.com/wiki/RaccoonlabDev/mini_v2_node/assets/dronecan_interface.png" alt="drawing" width=305> | <img src="https://raw.githubusercontent.com/wiki/RaccoonlabDev/mini_v2_node/assets/dronecan_params.png" alt="drawing" width=295> |
### 4. Use cases

1. Control 1-4 motors without feedback or servos with current feedback (if hardware supports)

<img src="https://docs.raccoonlab.co/assets/img/mini_v2_with_servo.4761fdf2.png" alt="drawing" width="400">

2. Control 1-2 motors with UART/ADC feedback

<img src="https://docs.raccoonlab.co/assets/img/mini_v2_with_esc_flame.0ffb552f.png" alt="drawing" width="400">

3. Cyphal/DroneCAN adapter for I2C/UART sensor

<img src="https://docs.raccoonlab.co/assets/img/lw20_i2c.82bad2a4.png" alt="drawing" width="400">

4. Control a servo with current feedback (if hardware supports) and angular position feedback (from [AS5600 I2C sensor](https://docs.raccoonlab.co/guide/as5600/))
5. Control a PWM cargo gripper

### 5. Q&A

Expand Down
52 changes: 52 additions & 0 deletions Src/platform/stm32g0b1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (C) 2023-2024 Dmitry Ponomarev <[email protected]>
# Distributed under the terms of the GPL v3 license, available in the file LICENSE.

# Pathes
cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH PLATFORM_DIR)
cmake_path(GET PLATFORM_DIR PARENT_PATH SRC_DIR)
cmake_path(GET SRC_DIR PARENT_PATH ROOT_DIR)

set(EXECUTABLE ${PROJECT_NAME}.out)
add_executable(${EXECUTABLE}
${APPLICATION_SOURCES}
${BUILD_SRC_DIR}/params.cpp
${ROOT_DIR}/Src/common/algorithms.cpp
${ROOT_DIR}/Src/common/module.cpp

${PLATFORM_DIR}/stm32f103/adc.cpp
${PLATFORM_DIR}/ubuntu/pwm.cpp
${PLATFORM_DIR}/stm32f103/iwdg.cpp
${PLATFORM_DIR}/stm32f103/led.cpp
${PLATFORM_DIR}/stm32f103/temperature_sensor.cpp
${PLATFORM_DIR}/stm32f103/platform_specific.cpp

${coreSources}
${driversSources}
${startupFile}
)

target_include_directories(${EXECUTABLE} PRIVATE
${BUILD_SRC_DIR}
${APPLICATION_HEADERS}
${ROOT_DIR}/Src/common

${stm32cubeMxProjectPath}/Core/Inc
${stm32cubeMxProjectPath}/Drivers/CMSIS/Include

${stm32cubeMxProjectPath}/Drivers/CMSIS/Device/ST/STM32F1xx/Include
${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc
${stm32cubeMxProjectPath}/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy

${stm32cubeMxProjectPath}/Drivers/CMSIS/Device/ST/STM32G0xx/Include
${stm32cubeMxProjectPath}/Drivers/STM32G0xx_HAL_Driver/Inc
${stm32cubeMxProjectPath}/Drivers/STM32G0xx_HAL_Driver/Inc/Legacy
)

# Post-build
add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND ${CMAKE_SIZE} ${EXECUTABLE}
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE} ${BUILD_OBJ_DIR}/${PROJECT_NAME}.hex
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE} ${BUILD_OBJ_DIR}/${PROJECT_NAME}.bin
COMMAND ${CMAKE_OBJCOPY} -I binary -O elf32-little ${EXECUTABLE} ${BUILD_OBJ_DIR}/${PROJECT_NAME}.elf
)
7 changes: 7 additions & 0 deletions cmake/stm32g0b1.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@

set(TARGET_ARCHITECTURE cortex-m0plus)
set(CPU STM32G0B1xx)
set(stm32cubeMxProjectPath ${ROOT_DIR}/build/ioc-v3)
FILE(GLOB ldFile ${stm32cubeMxProjectPath}/*_FLASH.ld)
FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*)
FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/*/*/*.c)
FILE(GLOB startupFile ${stm32cubeMxProjectPath}/*.s
${stm32cubeMxProjectPath}/Core/Startup/*.s
)
include(${CMAKE_CURRENT_LIST_DIR}/Toolchain-arm-none-eabi.cmake)
Loading