Skip to content

Commit

Permalink
Merge branch '8-auto-aim-integration' into 10-referee-system-communic…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
jia-xie committed Mar 23, 2024
2 parents c736fae + 0d5a21e commit 4ea5c86
Show file tree
Hide file tree
Showing 24 changed files with 592 additions and 135 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build Project
on:
push:
paths:
- 'src/**'
- 'lib/**'
pull_request:
paths:
- 'src/**'
- 'lib/**'

jobs:
build:
name: Build
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'recursive' # Ensure submodules are checked out

- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
update: true
install: mingw-w64-x86_64-arm-none-eabi-gcc make

- name: Build project
run: |
make -j24 V=1
shell: msys2 {0}
27 changes: 24 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "cmsis-dap-debug",
"name": "cmsis-dap-debug (Windows)",
"cwd": "${workspaceRoot}",
"executable": "${workspaceRoot}\\build\\control-base.elf",
"request": "launch",
Expand All @@ -17,7 +17,27 @@
"liveWatch": {
"enabled": true,
"samplesPerSecond": 4
}
},
"preLaunchTask": "build (Windows)" // build before debug
},
{
"name": "stlink-debug (Windows)",
"cwd": "${workspaceRoot}",
"executable": "${workspaceRoot}\\build\\control-base.elf",
"request": "launch",
"type": "cortex-debug",
"svdFile": "STM32F407.svd",
"servertype": "openocd", //GDB server
"configFiles": [
"${workspaceRoot}/config/openocd_stlink.cfg" // config
],
//"runToEntryPoint": "main", // stop at main
//"rtos": "FreeRTOS",
"liveWatch": {
"enabled": true,
"samplesPerSecond": 4
},
"preLaunchTask": "build (Windows)" // build before debug
},
{
"name": "cmsis-dap-debug (Darwin)",
Expand All @@ -35,7 +55,8 @@
"liveWatch": {
"enabled": true,
"samplesPerSecond": 4
}
},
"preLaunchTask": "build (Darwin)" // build before debug
}
]
}
13 changes: 11 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "build (Darwin)",
"type": "shell",
"command": "make",
"command": "make -j24 V=1",
"args": [],
"group": {
"kind": "build",
Expand Down Expand Up @@ -56,7 +56,16 @@
{
"label": "download dap (Windows)",
"type": "shell",
"command": "mingw32-make download_dap",
"command": "mingw32-make -j24 V=1; mingw32-make download_dap",
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "download stlink (Windows)",
"type": "shell",
"command": "mingw32-make -j24 V=1; mingw32-make download_stlink",
"group": {
"kind": "build",
"isDefault": false
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ src/bsp/src/bsp_pwm.c \
src/bsp/src/bsp_spi.c \
src/bsp/src/bsp_serial.c \
src/bsp/src/bsp_crc.c \
src/bsp/src/bsp_uart.c \
src/devices/src/BMI088driver.c \
src/devices/src/BMI088Middleware.c \
src/devices/src/dji_motor.c \
Expand All @@ -100,6 +101,7 @@ src/devices/src/mf_motor.c \
src/devices/src/remote.c \
src/devices/src/imu_task.c \
src/devices/src/referee_system.c \
src/devices/src/jetson_orin.c \
src/app/src/motor_task.c \
src/app/src/chassis_task.c \
src/app/src/gimbal_task.c \
Expand Down Expand Up @@ -245,5 +247,8 @@ clean:
-include $(wildcard $(BUILD_DIR)/*.d)

download_dap:
openocd -f openocd_cmsis_dap.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).bin 0x08000000" -c reset -c shutdown
openocd -f config/openocd_cmsis_dap.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).bin 0x08000000" -c reset -c shutdown

download_stlink:
openocd -f config/openocd_stlink.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).bin 0x08000000" -c reset -c shutdown
# *** EOF ***
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## About The Library
![Build Project](https://github.com/RoboMaster-Club/control-base/actions/workflows/build.yml/badge.svg)

# About The Library
This is a shareable hardware library for robomaster embedded system. It contains board support packages, device-drivers, and algorithms for control systems.
## How To

## Setup Guide
Clone repo, initialize submodule (STM32-CubeMX project)
``` shell
git clone https://github.com/RoboMaster-Club/control-base.git
Expand Down
2 changes: 1 addition & 1 deletion config/openocd_stlink.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# choose stlink as debugger
source [find interface/stlink.cfg]

transport select swd
transport select hla_swd

source [find target/stm32f4x.cfg]
2 changes: 1 addition & 1 deletion lib/typec-board-base
52 changes: 32 additions & 20 deletions src/algo/inc/user_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,39 @@

#define PI (3.1415926f)

#define __MAX_LIMIT(val, min, max) do\
{\
val =(val > max ? max : val);\
val = (val < min ? min : val);\
}\
while(0);
#define __MAX_LIMIT(val, min, max) \
do \
{ \
val = (val > max ? max : val); \
val = (val < min ? min : val); \
} while (0);

#define DEG_TO_RAD 3.14159f / 180.0f

#define __MAP(x, in_min, in_max, out_min, out_max) do\
{ \
if (x > in_max) { x -= in_max; } \
else if (x < -in_max) {x += in_max;} \
x = ((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);\
} \
while(0);

#define __MAP_ANGLE_TO_UNIT_CIRCLE(x) do\
{\
while (error >= PI) { error -= 2 * PI; }\
while (error < -PI) { error += 2 * PI; }\
}\
while(0);
#define __MAP(x, in_min, in_max, out_min, out_max) \
do \
{ \
if (x > in_max) \
{ \
x -= in_max; \
} \
else if (x < -in_max) \
{ \
x += in_max; \
} \
x = ((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min); \
} while (0);

#define __MAP_ANGLE_TO_UNIT_CIRCLE(x) \
do \
{ \
while (error >= PI) \
{ \
error -= 2 * PI; \
} \
while (error < -PI) \
{ \
error += 2 * PI; \
} \
} while (0);
#endif
Loading

0 comments on commit 4ea5c86

Please sign in to comment.