改纤维
This commit is contained in:
parent
bced810ccb
commit
1712a3da8c
@ -157,6 +157,22 @@
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>255</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134218668</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>startup_stm32h723xx.s</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\CtrBoard_H7_ALL\startup_stm32h723xx.s\255</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>0</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>128</Address>
|
||||
@ -171,7 +187,7 @@
|
||||
<Expression>0x00000080</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>0</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
@ -186,22 +202,6 @@
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>0x00000086</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>255</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>startup_stm32h723xx.s</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
152
User/device/ai.c
Normal file
152
User/device/ai.c
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
AI
|
||||
*/
|
||||
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include "ai.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "bsp\delay.h"
|
||||
#include "bsp\uart.h"
|
||||
#include "component\crc16.h"
|
||||
#include "component\crc8.h"
|
||||
#include "component\user_math.h"
|
||||
#include "component\filter.h"
|
||||
|
||||
|
||||
/* Private define ----------------------------------------------------------- */
|
||||
#define AI_LEN_RX_BUFF (sizeof(Protocol_DownPackage_t))
|
||||
|
||||
/* Private macro ------------------------------------------------------------ */
|
||||
/* Private typedef ---------------------------------------------------------- */
|
||||
/* Private variables -------------------------------------------------------- */
|
||||
static volatile uint32_t drop_message = 0;
|
||||
|
||||
static uint8_t rxbuf[AI_LEN_RX_BUFF];
|
||||
|
||||
static bool inited = false;
|
||||
|
||||
static osThreadId_t thread_alert;
|
||||
|
||||
/* Private function -------------------------------------------------------- */
|
||||
|
||||
static void Ai_RxCpltCallback(void) {
|
||||
osThreadFlagsSet(thread_alert, SIGNAL_AI_RAW_REDY);
|
||||
}
|
||||
|
||||
static void Ai_IdleLineCallback(void) {
|
||||
osThreadFlagsSet(thread_alert, SIGNAL_AI_RAW_REDY);
|
||||
}
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
int8_t AI_Init(AI_t *ai) {
|
||||
UNUSED(ai);
|
||||
ASSERT(ai);
|
||||
if (inited) return DEVICE_ERR_INITED;
|
||||
VERIFY((thread_alert = osThreadGetId()) != NULL);
|
||||
|
||||
BSP_UART_RegisterCallback(BSP_UART_AI, BSP_UART_RX_CPLT_CB,
|
||||
Ai_RxCpltCallback);
|
||||
BSP_UART_RegisterCallback(BSP_UART_AI, BSP_UART_IDLE_LINE_CB,
|
||||
Ai_IdleLineCallback);
|
||||
|
||||
inited = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t AI_Restart(void) {
|
||||
__HAL_UART_DISABLE(BSP_UART_GetHandle(BSP_UART_AI));
|
||||
__HAL_UART_ENABLE(BSP_UART_GetHandle(BSP_UART_AI));
|
||||
return DEVICE_OK;
|
||||
}
|
||||
|
||||
int8_t AI_StartReceiving(AI_t *ai) {
|
||||
UNUSED(ai);
|
||||
if (HAL_UART_Receive_DMA(BSP_UART_GetHandle(BSP_UART_AI), rxbuf,
|
||||
AI_LEN_RX_BUFF) == HAL_OK)
|
||||
return DEVICE_OK;
|
||||
return DEVICE_ERR;
|
||||
}
|
||||
|
||||
bool AI_WaitDmaCplt(void) {
|
||||
return (osThreadFlagsWait(SIGNAL_AI_RAW_REDY, osFlagsWaitAll, 0) ==
|
||||
SIGNAL_AI_RAW_REDY);
|
||||
}
|
||||
|
||||
int8_t AI_ParseHost(AI_t *ai) {
|
||||
if (!CRC16_Verify((const uint8_t *)&(rxbuf), sizeof(ai->from_host)))
|
||||
goto error;
|
||||
ai->ai_online = true;
|
||||
memcpy(&(ai->from_host), rxbuf, sizeof(ai->from_host));
|
||||
memset(rxbuf, 0, AI_LEN_RX_BUFF);
|
||||
return DEVICE_OK;
|
||||
|
||||
error:
|
||||
drop_message++;
|
||||
return DEVICE_ERR;
|
||||
}
|
||||
|
||||
void AI_PackCmd(AI_t *ai, CMD_Host_t *cmd_host) {
|
||||
cmd_host->gimbal_delta.yaw = ai->from_host.data.gimbal.yaw;
|
||||
cmd_host->gimbal_delta.pit = ai->from_host.data.gimbal.pit;
|
||||
cmd_host->fire = (ai->from_host.data.notice & AI_NOTICE_FIRE);
|
||||
cmd_host->chassis_move_vec.vx = ai->from_host.data.chassis_move_vec.vx;
|
||||
cmd_host->chassis_move_vec.vy = ai->from_host.data.chassis_move_vec.vy;
|
||||
cmd_host->chassis_move_vec.wz = ai->from_host.data.chassis_move_vec.wz;
|
||||
}
|
||||
|
||||
int8_t AI_HandleOffline(AI_t *ai, CMD_Host_t *cmd_host) {
|
||||
if (ai == NULL) return DEVICE_ERR_NULL;
|
||||
if (cmd_host == NULL) return DEVICE_ERR_NULL;
|
||||
ai->ai_online = false;
|
||||
memset(&(ai->from_host), 0, sizeof(ai->from_host));
|
||||
memset(cmd_host, 0, sizeof(*cmd_host));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t AI_PackMCU(AI_t *ai, const AHRS_Quaternion_t *quat) {
|
||||
ai->to_host.mcu.id = AI_ID_MCU;
|
||||
memcpy((void *)&(ai->to_host.mcu.package.data.quat), (const void *)quat,
|
||||
sizeof(*quat));
|
||||
ai->to_host.mcu.package.data.notice = 0;
|
||||
if (ai->status == AI_STATUS_AUTOAIM)
|
||||
ai->to_host.mcu.package.data.notice |= AI_NOTICE_AUTOAIM;
|
||||
else if (ai->status == AI_STATUS_HITSWITCH)
|
||||
ai->to_host.mcu.package.data.notice |= AI_NOTICE_HITBUFF;
|
||||
else if (ai->status == AI_STATUS_AUTOMATIC)
|
||||
ai->to_host.mcu.package.data.notice |= AI_NOTICE_AUTOMATIC;
|
||||
|
||||
ai->to_host.mcu.package.crc16 = CRC16_Calc(
|
||||
(const uint8_t *)&(ai->to_host.mcu.package),
|
||||
sizeof(ai->to_host.mcu.package) - sizeof(uint16_t), CRC16_INIT);
|
||||
return DEVICE_OK;
|
||||
}
|
||||
|
||||
int8_t AI_PackRef(AI_t *ai, const Referee_ForAI_t *ref) {
|
||||
(void)ref;
|
||||
ai->to_host.ref.id = AI_ID_REF;
|
||||
ai->to_host.ref.package.crc16 = CRC16_Calc(
|
||||
(const uint8_t *)&(ai->to_host.ref.package),
|
||||
sizeof(ai->to_host.ref.package) - sizeof(uint16_t), CRC16_INIT);
|
||||
return DEVICE_OK;
|
||||
}
|
||||
|
||||
int8_t AI_StartSend(AI_t *ai, bool ref_update) {
|
||||
if (ref_update) {
|
||||
if (HAL_UART_Transmit_DMA(
|
||||
BSP_UART_GetHandle(BSP_UART_AI), (uint8_t *)&(ai->to_host),
|
||||
sizeof(ai->to_host.ref) + sizeof(ai->to_host.mcu)) == HAL_OK)
|
||||
return DEVICE_OK;
|
||||
else
|
||||
return DEVICE_ERR;
|
||||
} else {
|
||||
if (HAL_UART_Transmit_DMA(BSP_UART_GetHandle(BSP_UART_AI),
|
||||
(uint8_t *)&(ai->to_host.mcu),
|
||||
sizeof(ai->to_host.mcu)) == HAL_OK)
|
||||
return DEVICE_OK;
|
||||
else
|
||||
return DEVICE_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
69
User/device/ai.h
Normal file
69
User/device/ai.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
AI
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
#include <cmsis_os2.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "component\ahrs.h"
|
||||
#include "component\cmd.h"
|
||||
#include "component\user_math.h"
|
||||
#include "component\filter.h"
|
||||
#include "device\device.h"
|
||||
#include "device\referee.h"
|
||||
#include "protocol.h"
|
||||
|
||||
/* Exported constants ------------------------------------------------------- */
|
||||
/* Exported macro ----------------------------------------------------------- */
|
||||
/* Exported types ----------------------------------------------------------- */
|
||||
|
||||
typedef struct __packed {
|
||||
uint8_t id;
|
||||
Protocol_UpPackageReferee_t package;
|
||||
} AI_UpPackageReferee_t;
|
||||
|
||||
typedef struct __packed {
|
||||
uint8_t id;
|
||||
Protocol_UpPackageMCU_t package;
|
||||
} AI_UpPackageMCU_t;
|
||||
|
||||
typedef struct __packed {
|
||||
osThreadId_t thread_alert;
|
||||
|
||||
Protocol_DownPackage_t from_host;
|
||||
|
||||
struct {
|
||||
AI_UpPackageReferee_t ref;
|
||||
AI_UpPackageMCU_t mcu;
|
||||
} to_host;
|
||||
|
||||
CMD_AI_Status_t status;
|
||||
bool ai_online;
|
||||
} AI_t;
|
||||
|
||||
/* Exported functions prototypes -------------------------------------------- */
|
||||
int8_t AI_Init(AI_t *ai);
|
||||
int8_t AI_Restart(void);
|
||||
|
||||
int8_t AI_StartReceiving(AI_t *ai);
|
||||
bool AI_WaitDmaCplt(void);
|
||||
int8_t AI_ParseHost(AI_t *ai);
|
||||
int8_t AI_HandleOffline(AI_t *ai, CMD_Host_t *cmd_host);
|
||||
int8_t AI_PackMCU(AI_t *ai, const AHRS_Quaternion_t *quat);
|
||||
int8_t AI_PackRef(AI_t *ai, const Referee_ForAI_t *ref);
|
||||
int8_t AI_StartSend(AI_t *ai, bool option);
|
||||
void AI_PackCmd(AI_t *ai, CMD_Host_t *cmd_host);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -20,10 +20,10 @@
|
||||
#define WHEEL_RADIUS 0.068f /* 轮子半径 (m) */
|
||||
#define MAX_ACCELERATION 2.0f /* 最大加速度 (m/s²) */
|
||||
#define WHEEL_GEAR_RATIO 8.0f /* 轮毂电机扭矩 */
|
||||
#define BASE_LEG_LENGTH 0.12f /* 基础腿长 (m) */
|
||||
#define BASE_LEG_LENGTH 0.16f /* 基础腿长 (m) */
|
||||
#define LEG_LENGTH_RANGE 0.22f /* 腿长调节范围 (m) */
|
||||
#define MIN_LEG_LENGTH 0.10f /* 最小腿长 (m) */
|
||||
#define MAX_LEG_LENGTH 0.42f /* 最大腿长 (m) */
|
||||
#define MAX_LEG_LENGTH 0.34f /* 最大腿长 (m) */
|
||||
#define NON_CONTACT_THETA 0.16f /* 离地时的摆角目标 (rad) */
|
||||
#define LEFT_BASE_FORCE 60.0f /* 左腿基础支撑力 (N) */
|
||||
#define RIGHT_BASE_FORCE 60.0f /* 右腿基础支撑力 (N) */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user