7.6nuc通信正常
This commit is contained in:
parent
b7e4d04550
commit
4bc5997670
@ -183,22 +183,22 @@
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>\\R2\../User/task/chassis_task.c\chassis.sick_cali.sickparam</ItemText>
|
||||
<ItemText>cmd,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>cmd,0x0A</ItemText>
|
||||
<ItemText>nucbuf,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>7</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>nucbuf,0x0A</ItemText>
|
||||
<ItemText>cmd_fromnuc</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>8</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>cmd_fromnuc</ItemText>
|
||||
<ItemText>NUC_send,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<Tracepoint>
|
||||
|
Binary file not shown.
@ -99,7 +99,7 @@ int8_t Chassis_Control(Chassis_t *c, CMD_t *ctrl, CAN_Output_t *out) {
|
||||
|
||||
/*初始数据*/
|
||||
|
||||
c->NUC_send.send[0] = 0;
|
||||
c->to_nuc.send = 0;
|
||||
c->sick_cali.is_reach = 0;
|
||||
|
||||
c->vofa_send[0]= KalmanFilter(&c->extKalman[0] , c->sick_cali.sick_dis[0]);
|
||||
@ -111,6 +111,7 @@ int8_t Chassis_Control(Chassis_t *c, CMD_t *ctrl, CAN_Output_t *out) {
|
||||
|
||||
switch (c->chassis_ctrl.ctrl) {
|
||||
case RCcontrol:
|
||||
c->to_nuc.send = 0;
|
||||
switch (c->chassis_ctrl.mode) {
|
||||
case Normal:
|
||||
c->move_vec.Vw = ctrl->Vw * 8000;
|
||||
@ -129,7 +130,7 @@ int8_t Chassis_Control(Chassis_t *c, CMD_t *ctrl, CAN_Output_t *out) {
|
||||
case Chassis_Adjust_Sick:
|
||||
|
||||
sick_calibration(c, ctrl, out);
|
||||
c->NUC_send.send[0] = (c->sick_cali.is_reach == 1) ? 1 : 0;
|
||||
// c->to_nuc.send = (c->sick_cali.is_reach == 1) ? 1 : 0;
|
||||
break;
|
||||
|
||||
}
|
||||
@ -138,13 +139,13 @@ int8_t Chassis_Control(Chassis_t *c, CMD_t *ctrl, CAN_Output_t *out) {
|
||||
case AUTO:
|
||||
switch (c->chassis_ctrl.mode) {
|
||||
case AUTO_MID360:
|
||||
c->move_vec.Vw = ctrl->cmd_MID360.posw * 1000;
|
||||
c->move_vec.Vy = -ctrl->cmd_MID360.posy * 1000;
|
||||
c->move_vec.Vx = -ctrl->cmd_MID360.posx * 1000;
|
||||
abs_limit_fp(&c->move_vec.Vx, 5000.0f);
|
||||
abs_limit_fp(&c->move_vec.Vy, 5000.0f);
|
||||
abs_limit_fp(&c->move_vec.Vw, 5000.0f);
|
||||
// c->NUC_send.send[0] = 1;
|
||||
// c->move_vec.Vw = ctrl->cmd_MID360.posw * 1000;
|
||||
// c->move_vec.Vy = -ctrl->cmd_MID360.posy * 1000;
|
||||
// c->move_vec.Vx = -ctrl->cmd_MID360.posx * 1000;
|
||||
// abs_limit_fp(&c->move_vec.Vx, 5000.0f);
|
||||
// abs_limit_fp(&c->move_vec.Vy, 5000.0f);
|
||||
// abs_limit_fp(&c->move_vec.Vw, 5000.0f);
|
||||
|
||||
break;
|
||||
case AUTO_MID360_Pitch:
|
||||
c->move_vec.Vw = ctrl->cmd_MID360.posw * 1000;
|
||||
@ -154,10 +155,8 @@ int8_t Chassis_Control(Chassis_t *c, CMD_t *ctrl, CAN_Output_t *out) {
|
||||
abs_limit_fp(&c->move_vec.Vy, 5000.0f);
|
||||
abs_limit_fp(&c->move_vec.Vw, 5000.0f);
|
||||
break;
|
||||
case AUTO_MID360_Adjust:
|
||||
c->move_vec.Vw = ctrl->Vw * 6000;
|
||||
c->move_vec.Vx = ctrl->Vy * 6000;
|
||||
c->move_vec.Vy = ctrl->Vx * 6000;
|
||||
case REPOSITION:
|
||||
c->to_nuc.send = 1;
|
||||
|
||||
break;
|
||||
|
||||
|
@ -103,12 +103,6 @@ typedef struct
|
||||
fp32 Vw;
|
||||
fp32 mul;//油门倍率
|
||||
}ChassisMove_Vec;
|
||||
typedef struct
|
||||
{
|
||||
|
||||
fp32 send[4];
|
||||
|
||||
}NUC_send_t;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@ -184,7 +178,10 @@ typedef struct{
|
||||
int is_reach;
|
||||
}sick_cali;
|
||||
|
||||
NUC_send_t NUC_send;
|
||||
struct {
|
||||
fp32 send;
|
||||
}to_nuc;
|
||||
|
||||
|
||||
|
||||
}Chassis_t;
|
||||
|
@ -88,14 +88,15 @@ static const ConfigParam_t param ={
|
||||
.go_init = -50, //仅用在go上电,初始位置
|
||||
.go_release_pos=-200,
|
||||
.Pitch_angle =66,
|
||||
|
||||
.go_up_speed =12,
|
||||
.go_down_speed =6,
|
||||
},
|
||||
.PassCfg={
|
||||
.go_wait =-10,
|
||||
.go_release_pos =-150,
|
||||
.Pitch_angle=66,
|
||||
.go_up_speed =12,
|
||||
.go_down_speed =5,
|
||||
.go_down_speed =6,
|
||||
},
|
||||
.MID360Cfg={
|
||||
|
||||
|
@ -313,6 +313,10 @@ int8_t Pitch_Process(UP_t *u, CAN_Output_t *out,CMD_t *c)
|
||||
up_motor_target_t *target=&u->motor_target ;
|
||||
LaunchContext_t *LaunchContext = &u->LaunchContext;
|
||||
// 可根据实际需要传入不同的起始和末位置,起始:当前位置
|
||||
LaunchContext->LaunchCfg.go_up_speed= cfg->go_up_speed;
|
||||
LaunchContext->LaunchCfg.go_down_speed= cfg->go_down_speed
|
||||
;
|
||||
|
||||
Pitch_Launch_Sequence(u, LaunchContext, u->motorfeedback.go_data.Pos, cfg->go_release_pos, out);
|
||||
|
||||
|
||||
|
@ -73,6 +73,8 @@ typedef struct {
|
||||
fp32 go_init; // GO电机触发位置,初始位置,后续更改用于发射的位置
|
||||
fp32 Pitch_angle; //俯仰角度,以oid为准
|
||||
fp32 go_release_pos;//go松开,发射位置
|
||||
fp32 go_up_speed;
|
||||
fp32 go_down_speed;
|
||||
|
||||
} PitchCfg_t;
|
||||
|
||||
|
@ -159,7 +159,7 @@ int8_t CMD_DR16(CMD_t *cmd,const CMD_RC_t *rc) {
|
||||
|
||||
if(rc->dr16.sw_r ==CMD_SW_MID) cmd ->CMD_mode =AUTO_MID360; //左中,右中,无模式
|
||||
|
||||
if(rc->dr16.sw_r ==CMD_SW_DOWN) cmd ->CMD_mode =Normal; //左中,右下,视觉
|
||||
if(rc->dr16.sw_r ==CMD_SW_DOWN) cmd ->CMD_mode =REPOSITION; //左中,右下,视觉
|
||||
|
||||
}
|
||||
else if(rc->dr16.sw_l==CMD_SW_DOWN)
|
||||
@ -193,7 +193,7 @@ int8_t CMD_LD(CMD_t *cmd,const CMD_RC_t *rc){
|
||||
if(cmd ->CMD_CtrlType ==AUTO){
|
||||
|
||||
/*自动下的*/
|
||||
if (rc->LD.key_C ==CMD_SW_UP) cmd ->CMD_mode =AUTO_MID360_Adjust;
|
||||
if (rc->LD.key_C ==CMD_SW_UP) cmd ->CMD_mode =Normal;
|
||||
else {
|
||||
|
||||
if(rc->LD.key_E ==CMD_SW_DOWN ) cmd ->CMD_mode =Normal;
|
||||
|
@ -26,7 +26,7 @@ typedef enum{
|
||||
|
||||
AUTO_MID360,
|
||||
AUTO_MID360_Pitch,
|
||||
AUTO_MID360_Adjust,//雷达调整
|
||||
REPOSITION,//雷达调整
|
||||
|
||||
UP_Adjust,//上层调整
|
||||
Chassis_Adjust_Sick,
|
||||
|
@ -40,33 +40,6 @@ int8_t NUC_StartReceiving()
|
||||
return DEVICE_OK;
|
||||
return DEVICE_ERR;
|
||||
}
|
||||
int8_t NUC_StartSending(fp32 *data)
|
||||
{
|
||||
|
||||
union
|
||||
{
|
||||
float x[1];
|
||||
char data[4];
|
||||
} instance;
|
||||
|
||||
// for (int i = 0; i < 1; i++) {
|
||||
instance.x[0] = data[0];
|
||||
// }
|
||||
|
||||
SendBuffer[0] = 0xFC; // 帧头
|
||||
SendBuffer[1] = 0x01; // 控制帧
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
SendBuffer[i] = instance.data[i - 2];
|
||||
}
|
||||
SendBuffer[6] = 0xFD; // 帧尾
|
||||
|
||||
if (HAL_UART_Transmit_DMA(BSP_UART_GetHandle(BSP_UART_NUC),
|
||||
(uint8_t *)SendBuffer,
|
||||
sizeof(SendBuffer)) == HAL_OK)
|
||||
return DEVICE_OK;
|
||||
return DEVICE_ERR;
|
||||
}
|
||||
int8_t NUC_Restart(void)
|
||||
{
|
||||
__HAL_UART_DISABLE(BSP_UART_GetHandle(BSP_UART_NUC));
|
||||
@ -179,7 +152,7 @@ int8_t NUC_HandleOffline(CMD_NUC_t *cmd, NUC_t *nuc)
|
||||
if (cmd == NULL)
|
||||
return DEVICE_ERR_NULL;
|
||||
nuc->unc_online = false; // 设置为离线状态
|
||||
// memset(cmd, 0, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -197,28 +170,34 @@ int8_t NUC_PackIMU(NUC_t *nuc, const AHRS_Quaternion_t *quat, const AHRS_Accl_t
|
||||
int8_t NUC_PackCMD(NUC_t *nuc, const NUC_send_t *send){
|
||||
nuc->to_nuc.cmd.head = HEAD;
|
||||
nuc->to_nuc.cmd.id = IMU_ID;
|
||||
nuc->to_nuc.cmd.type = TYPE;
|
||||
nuc->to_nuc.cmd.end = TAIL;
|
||||
// memcpy((void *)&(nuc->to_nuc.cmd.package.status), (const void *)send,sizeof(*send));
|
||||
memcpy((void *)&(nuc->to_nuc.cmd.package.status), (const void *)send,sizeof(*send));
|
||||
/*在这里添加你们的控制命令*/
|
||||
return DEVICE_OK;
|
||||
}
|
||||
|
||||
int8_t NUC_StartSend(NUC_t *nuc, bool cmd_update){
|
||||
if (cmd_update) {
|
||||
// if (HAL_UART_Transmit_DMA(
|
||||
// BSP_UART_GetHandle(BSP_UART_NUC), (uint8_t *)&(nuc->to_nuc.cmd),
|
||||
// sizeof(nuc->to_nuc.cmd) + sizeof(nuc->to_nuc.imu)) == HAL_OK)
|
||||
/*仅发送cmd数据*/
|
||||
if (HAL_UART_Transmit_DMA(
|
||||
BSP_UART_GetHandle(BSP_UART_NUC), (uint8_t *)&(nuc->to_nuc.cmd),
|
||||
sizeof(nuc->to_nuc.cmd) + sizeof(nuc->to_nuc.imu)) == HAL_OK)
|
||||
return DEVICE_OK;
|
||||
else
|
||||
return DEVICE_ERR;
|
||||
} else {
|
||||
if (HAL_UART_Transmit_DMA(BSP_UART_GetHandle(BSP_UART_NUC),
|
||||
(uint8_t *)&(nuc->to_nuc.imu),
|
||||
sizeof(nuc->to_nuc.imu)) == HAL_OK)
|
||||
sizeof(nuc->to_nuc.cmd) ) == HAL_OK)
|
||||
|
||||
|
||||
return DEVICE_OK;
|
||||
else
|
||||
return DEVICE_ERR;
|
||||
}
|
||||
// else {
|
||||
// if (HAL_UART_Transmit_DMA(BSP_UART_GetHandle(BSP_UART_NUC),
|
||||
// (uint8_t *)&(nuc->to_nuc.imu),
|
||||
// sizeof(nuc->to_nuc.imu)) == HAL_OK)
|
||||
// return DEVICE_OK;
|
||||
// else
|
||||
// return DEVICE_ERR;
|
||||
// }
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,11 @@
|
||||
#include "Algorithm/ahrs.h"
|
||||
#include "Module/Chassis.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
fp32 send;
|
||||
|
||||
}NUC_send_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t id;
|
||||
@ -25,7 +30,6 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
uint8_t head;
|
||||
uint8_t type; // 0x01 控制帧
|
||||
uint8_t id;
|
||||
Protocol_UpDataCMD_t package;
|
||||
uint8_t end;
|
||||
@ -51,7 +55,6 @@ typedef struct {
|
||||
|
||||
int8_t NUC_Init(NUC_t *nuc);
|
||||
int8_t NUC_StartReceiving(void);
|
||||
int8_t NUC_StartSending(fp32 *data) ;
|
||||
bool_t NUC_WaitDmaCplt(void);
|
||||
int8_t NUC_RawParse(CMD_NUC_t *n, NUC_t *nuc);
|
||||
int8_t NUC_HandleOffline(CMD_NUC_t *cmd, NUC_t *nuc);
|
||||
|
@ -88,7 +88,7 @@ void Task_Chassis(void *argument)
|
||||
osMessageQueueReset(task_runtime.msgq.can.output.chassis3508);//清空队列
|
||||
osMessageQueuePut(task_runtime.msgq.can.output.chassis3508, &out.motor_CHASSIS3508, 0, 0); //发送数据
|
||||
osMessageQueueReset(task_runtime.msgq.cmd.raw.nuc_send);//清空队列
|
||||
osMessageQueuePut(task_runtime.msgq.cmd.raw.nuc_send, &chassis.NUC_send, 0, 0); //发送数据
|
||||
osMessageQueuePut(task_runtime.msgq.cmd.raw.nuc_send, &chassis.to_nuc, 0, 0); //发送数据
|
||||
vofa_send[0] = chassis.vofa_send[0];
|
||||
vofa_send[1] = chassis.vofa_send[1];
|
||||
vofa_send[2] = chassis.vofa_send[2];
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "task\user_task.h"
|
||||
#include "can_use.h"
|
||||
#include "cmd.h"
|
||||
|
||||
#include "nuc.h"
|
||||
/* Private typedef ---------------------------------------------------------- */
|
||||
/* Private define ----------------------------------------------------------- */
|
||||
/* Private macro ------------------------------------------------------------ */
|
||||
|
@ -21,6 +21,8 @@ NUC_send_t NUC_send;
|
||||
#endif
|
||||
fp32 send[4]={11.0f,45.0,1.f,4.0f};
|
||||
int a=0;
|
||||
|
||||
|
||||
void Task_nuc(void *argument){
|
||||
(void)argument; /**/
|
||||
|
||||
@ -35,9 +37,6 @@ void Task_nuc(void *argument){
|
||||
{
|
||||
#ifdef DEBUG
|
||||
task_runtime.stack_water_mark.nuc= osThreadGetStackSpace(osThreadGetId());
|
||||
task_runtime .freq.nuc = TASK_FREQ_NUC;
|
||||
task_runtime.last_up_time.nuc= tick;
|
||||
|
||||
#endif
|
||||
a++;
|
||||
NUC_StartReceiving();
|
||||
@ -63,14 +62,14 @@ void Task_nuc(void *argument){
|
||||
bool cmd_update = (osMessageQueueGet(task_runtime.msgq.cmd.raw.nuc_send,
|
||||
&(NUC_send), NULL, 0) == osOK);
|
||||
|
||||
NUC_PackIMU(&nuc_raw, &quat, &accl, &gyro);
|
||||
// NUC_PackIMU(&nuc_raw, &quat, &accl, &gyro);
|
||||
if (cmd_update) {
|
||||
NUC_PackCMD(&nuc_raw,&NUC_send);
|
||||
}
|
||||
|
||||
|
||||
NUC_StartSend(&nuc_raw,cmd_update);
|
||||
|
||||
}
|
||||
|
||||
tick += delay_tick; /* 计算下一个唤醒时刄1ķ*/
|
||||
osDelayUntil(tick);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user