给nuc发数据
This commit is contained in:
parent
8ffef38518
commit
553de3fa5e
@ -103,7 +103,7 @@
|
|||||||
<bEvRecOn>1</bEvRecOn>
|
<bEvRecOn>1</bEvRecOn>
|
||||||
<bSchkAxf>0</bSchkAxf>
|
<bSchkAxf>0</bSchkAxf>
|
||||||
<bTchkAxf>0</bTchkAxf>
|
<bTchkAxf>0</bTchkAxf>
|
||||||
<nTsel>3</nTsel>
|
<nTsel>6</nTsel>
|
||||||
<sDll></sDll>
|
<sDll></sDll>
|
||||||
<sDllPa></sDllPa>
|
<sDllPa></sDllPa>
|
||||||
<sDlgDll></sDlgDll>
|
<sDlgDll></sDlgDll>
|
||||||
@ -114,7 +114,7 @@
|
|||||||
<tDlgDll></tDlgDll>
|
<tDlgDll></tDlgDll>
|
||||||
<tDlgPa></tDlgPa>
|
<tDlgPa></tDlgPa>
|
||||||
<tIfile></tIfile>
|
<tIfile></tIfile>
|
||||||
<pMon>BIN\CMSIS_AGDI.dll</pMon>
|
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
|
||||||
</DebugOpt>
|
</DebugOpt>
|
||||||
<TargetDriverDllRegistry>
|
<TargetDriverDllRegistry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
@ -140,7 +140,7 @@
|
|||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>DLGUARM</Key>
|
<Key>DLGUARM</Key>
|
||||||
<Name></Name>
|
<Name>(105=-1,-1,-1,-1,0)</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
@ -310,6 +310,26 @@
|
|||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>imu_temp</ItemText>
|
<ItemText>imu_temp</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>31</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>cmd</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>32</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>NUC_send</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>33</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>BMI088_t</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>34</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>bmi088</ItemText>
|
||||||
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<Tracepoint>
|
<Tracepoint>
|
||||||
<THDelay>0</THDelay>
|
<THDelay>0</THDelay>
|
||||||
|
Binary file not shown.
@ -4,294 +4,180 @@
|
|||||||
#include "bsp_buzzer.h"
|
#include "bsp_buzzer.h"
|
||||||
#include "bsp_delay.h"
|
#include "bsp_delay.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
机器人坐标系,向前x,右y,上yaw
|
||||||
|
不同于nuc (前x,左y,上yaw)
|
||||||
|
x
|
||||||
|
|
|
||||||
/*机器人坐标系,向前x,右y,上yaw
|
--y
|
||||||
不同于nuc (前x,左y,上yaw) */
|
|
||||||
/*
|
|
||||||
x
|
|
||||||
|
|
|
||||||
--y
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int8_t Chassis_SetCtrl(Chassis_t *c,CMD_t *ctrl){
|
static int8_t Chassis_SetCtrl(Chassis_t *c, CMD_t *ctrl) {
|
||||||
if (c == NULL) return CHASSIS_ERR_NULL; /*主结构体不能为空 */
|
if (c == NULL) return CHASSIS_ERR_NULL;
|
||||||
if (ctrl->CMD_CtrlType== c->chassis_ctrl.ctrl && ctrl->CMD_mode == c->chassis_ctrl.mode) return CHASSIS_OK; /*模式未改变直接返回*/
|
if (ctrl->CMD_CtrlType == c->chassis_ctrl.ctrl && ctrl->CMD_mode == c->chassis_ctrl.mode)
|
||||||
c->chassis_ctrl.ctrl =ctrl->CMD_CtrlType ;
|
return CHASSIS_OK;
|
||||||
c->chassis_ctrl.mode =ctrl->CMD_mode ;
|
c->chassis_ctrl.ctrl = ctrl->CMD_CtrlType;
|
||||||
|
c->chassis_ctrl.mode = ctrl->CMD_mode;
|
||||||
return CHASSIS_OK;
|
return CHASSIS_OK;
|
||||||
} //设置控制模式
|
}
|
||||||
|
|
||||||
|
|
||||||
/*该函数用来更新can任务获得的电机反馈值*/
|
|
||||||
|
|
||||||
int8_t Chassis_UpdateFeedback(Chassis_t *c, const CAN_t *can) {
|
int8_t Chassis_UpdateFeedback(Chassis_t *c, const CAN_t *can) {
|
||||||
if (c == NULL) return CHASSIS_ERR_NULL;
|
if (c == NULL) return CHASSIS_ERR_NULL;
|
||||||
if (can == NULL) return CHASSIS_ERR_NULL;
|
if (can == NULL) return CHASSIS_ERR_NULL;
|
||||||
for (uint8_t i = 0; i < 4; i++)
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
{
|
c->motorfeedback.rotor_rpm3508[i] = can->motor.chassis_motor3508.as_array[i].rotor_speed;
|
||||||
c->motorfeedback.rotor_rpm3508[i] = can->motor.chassis_motor3508.as_array[i].rotor_speed;
|
c->motorfeedback.rotor_current3508[i] = can->motor.chassis_motor3508.as_array[i].torque_current;
|
||||||
c->motorfeedback.rotor_current3508[i] = can->motor.chassis_motor3508.as_array[i].torque_current;
|
}
|
||||||
}
|
return CHASSIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return CHASSIS_OK;
|
int8_t Chassis_init(Chassis_t *c, const Chassis_Param_t *param, float target_freq) {
|
||||||
|
if (c == NULL) return CHASSIS_ERR_NULL;
|
||||||
|
c->param = param;
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
PID_init(&(c->pid.chassis_3508VecPID[i]), PID_POSITION_D, &(c->param->M3508_param));
|
||||||
|
}
|
||||||
|
PID_init(&(c->pid.chassis_PICKWzPID_HIGN), PID_POSITION, &(c->param->chassis_PICKWzPID_HIGN_param));
|
||||||
|
PID_init(&(c->pid.chassis_PICKWzPID_LOW), PID_POSITION, &(c->param->chassis_PICKWzPID_LOW_param));
|
||||||
|
PID_init(&(c->pid.sick_CaliforYPID), PID_POSITION, &(c->param->Sick_CaliYparam));
|
||||||
|
PID_init(&(c->pid.sick_CaliforXPID), PID_POSITION, &(c->param->Sick_CaliXparam));
|
||||||
|
|
||||||
|
LowPassFilter2p_Init(&(c->filled[0]), target_freq, 80.0f); // 角加速度滤波
|
||||||
|
LowPassFilter2p_Init(&(c->filled[1]), target_freq, 80.0f); // w滤波
|
||||||
|
LowPassFilter2p_Init(&(c->filled[2]), target_freq, 80.0f); // y滤波
|
||||||
|
LowPassFilter2p_Init(&(c->filled[3]), target_freq, 80.0f); // x滤波
|
||||||
|
|
||||||
|
return CHASSIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
fp32 gyro_kp = 1.0f;
|
||||||
|
fp32 PIAN = 0;
|
||||||
|
|
||||||
|
void Chassis_speed_calculate(Chassis_t *c, fp32 Vx, fp32 Vy, fp32 Vw) {
|
||||||
|
fp64 Nor_Vx, Nor_Vy;
|
||||||
|
normalize_vector(Vx, Vy, &Nor_Vx, &Nor_Vy);
|
||||||
|
|
||||||
|
c->hopemotorout.OmniSpeedOut[0] = -Nor_Vx + Nor_Vy + Vw; // 右前
|
||||||
|
c->hopemotorout.OmniSpeedOut[1] = -Nor_Vx - Nor_Vy + Vw; // 右后
|
||||||
|
c->hopemotorout.OmniSpeedOut[2] = Nor_Vx - Nor_Vy + Vw; // 左后
|
||||||
|
c->hopemotorout.OmniSpeedOut[3] = Nor_Vx + Nor_Vy + Vw; // 左前
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t Chassis_Control(Chassis_t *c, CMD_t *ctrl, CAN_Output_t *out) {
|
||||||
|
if (c == NULL) return CHASSIS_ERR_NULL;
|
||||||
|
if (ctrl == NULL) return CHASSIS_ERR_NULL;
|
||||||
|
|
||||||
|
Chassis_SetCtrl(c, ctrl);
|
||||||
|
|
||||||
|
// IMU加滤波修正
|
||||||
|
c->pos088.bmi088.filtered_gyro.z = LowPassFilter2p_Apply(&(c->filled[0]), c->pos088.bmi088.gyro.z);
|
||||||
|
|
||||||
|
switch (c->chassis_ctrl.ctrl) {
|
||||||
|
case RCcontrol: // 手动控制
|
||||||
|
/*
|
||||||
|
在cmd里对数据进行处理 包括方向和油门
|
||||||
|
6000为全向轮的倍率,遥控器坐标系和机器人坐标系不同
|
||||||
|
*/
|
||||||
|
c->NUC_send .send [0]=0;
|
||||||
|
c->NUC_send .send [1]=0;
|
||||||
|
c->NUC_send .send [2]=10;
|
||||||
|
c->NUC_send .send [3]=100;
|
||||||
|
|
||||||
|
switch (c->chassis_ctrl.mode) {
|
||||||
|
case Normal:
|
||||||
|
c->move_vec.Vw = ctrl->Vw * 6000;
|
||||||
|
c->move_vec.Vx = ctrl->Vy * 6000;
|
||||||
|
c->move_vec.Vy = ctrl->Vx * 6000;
|
||||||
|
break;
|
||||||
|
case Pitch:
|
||||||
|
c->move_vec.Vw = 0;
|
||||||
|
c->move_vec.Vx = 0;
|
||||||
|
c->move_vec.Vy = 0;
|
||||||
|
break;
|
||||||
|
case UP_Adjust:
|
||||||
|
c->move_vec.Vw = ctrl->Vw * 6000;
|
||||||
|
c->move_vec.Vx = 0;
|
||||||
|
c->move_vec.Vy = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
c->move_vec.Vw = 0;
|
||||||
|
c->move_vec.Vx = 0;
|
||||||
|
c->move_vec.Vy = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUTO: // 自动模式
|
||||||
|
switch (c->chassis_ctrl.mode) {
|
||||||
|
|
||||||
|
case AUTO_NAVI: // 自动雷达
|
||||||
|
// 全向轮方向, 注意xy方向
|
||||||
|
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, 2000.0f);
|
||||||
|
abs_limit_fp(&c->move_vec.Vy, 2000.0f);
|
||||||
|
abs_limit_fp(&c->move_vec.Vw, 2000.0f);
|
||||||
|
|
||||||
|
c->NUC_send .send [0]=0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUTO_NAVI_Pitch:
|
||||||
|
c->move_vec.Vw = 0;
|
||||||
|
c->move_vec.Vy = 0;
|
||||||
|
c->move_vec.Vx = 0;
|
||||||
|
|
||||||
|
c->NUC_send .send [0]=1;
|
||||||
|
break;
|
||||||
|
case AUTO_NAVI_Adjust:
|
||||||
|
c->move_vec.Vw = ctrl->Vw * 6000;
|
||||||
|
c->move_vec.Vx = ctrl->Vy * 6000;
|
||||||
|
c->move_vec.Vy = ctrl->Vx * 6000;
|
||||||
|
|
||||||
|
c->NUC_send .send [0]=1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
c->move_vec.Vw = 0;
|
||||||
|
c->move_vec.Vx = 0;
|
||||||
|
c->move_vec.Vy = 0;
|
||||||
|
c->NUC_send .send [0]=0;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
c->move_vec.Vw = 0;
|
||||||
|
c->move_vec.Vx = 0;
|
||||||
|
c->move_vec.Vy = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 电机速度限幅
|
||||||
|
abs_limit_fp(&c->move_vec.Vx, 6000.0f);
|
||||||
|
abs_limit_fp(&c->move_vec.Vy, 6000.0f);
|
||||||
|
abs_limit_fp(&c->move_vec.Vw, 6000.0f);
|
||||||
|
|
||||||
|
Chassis_speed_calculate(c, c->move_vec.Vx, c->move_vec.Vy, c->move_vec.Vw);
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
|
c->final_out.final_3508out[i] = PID_calc(&(c->pid.chassis_3508VecPID[i]),
|
||||||
|
c->motorfeedback.rotor_rpm3508[i],
|
||||||
|
c->hopemotorout.OmniSpeedOut[i]);
|
||||||
|
out->motor_CHASSIS3508.as_array[i] = c->final_out.final_3508out[i];
|
||||||
|
}
|
||||||
|
c->NUC_send .send [1]=1;
|
||||||
|
return CHASSIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int8_t Chassis_init(Chassis_t *c,const Chassis_Param_t *param,float target_freq)
|
|
||||||
{
|
|
||||||
if (c == NULL) return CHASSIS_ERR_NULL;
|
|
||||||
|
|
||||||
c->param = param; /*初始化参数 */
|
|
||||||
|
|
||||||
for(int i =0 ; i < 4 ; i++)
|
|
||||||
{
|
|
||||||
PID_init(&(c->pid.chassis_3508VecPID[i]),PID_POSITION_D,&(c->param->M3508_param)); //带D项滤波
|
|
||||||
}
|
|
||||||
|
|
||||||
PID_init(&(c->pid.chassis_PICKWzPID_HIGN),PID_POSITION,&(c->param->chassis_PICKWzPID_HIGN_param));
|
|
||||||
|
|
||||||
PID_init(&(c->pid.chassis_PICKWzPID_LOW),PID_POSITION,&(c->param->chassis_PICKWzPID_LOW_param));
|
|
||||||
|
|
||||||
|
|
||||||
PID_init(&(c->pid.sick_CaliforYPID),PID_POSITION,&(c->param->Sick_CaliYparam));
|
|
||||||
|
|
||||||
PID_init(&(c->pid.sick_CaliforXPID),PID_POSITION,&(c->param->Sick_CaliXparam));
|
|
||||||
|
|
||||||
LowPassFilter2p_Init(&(c->filled[0]),target_freq,80.0f); //给角加速度做滤波
|
|
||||||
|
|
||||||
|
|
||||||
LowPassFilter2p_Init(&(c->filled[1]),target_freq,80.0f); //给w 做滤波
|
|
||||||
|
|
||||||
LowPassFilter2p_Init(&(c->filled[2]),target_freq,80.0f); //给y做滤波
|
|
||||||
|
|
||||||
LowPassFilter2p_Init(&(c->filled[3]),target_freq,80.0f); //给x 做滤波
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
return CHASSIS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp32 gyro_kp=1.0f;
|
|
||||||
fp32 PIAN=0;
|
|
||||||
void Chassis_speed_calculate(Chassis_t *c,fp32 Vx,fp32 Vy,fp32 Vw) //底盘逆运动学的解算,
|
|
||||||
{
|
|
||||||
fp64 Nor_Vx,Nor_Vy;//归一化后的数据
|
|
||||||
normalize_vector(Vx,Vy,&Nor_Vx,&Nor_Vy);
|
|
||||||
|
|
||||||
// c->hopemotorout.OmniSpeedOut[0] = -Vx+Vy+Vw;//右前
|
|
||||||
// c->hopemotorout.OmniSpeedOut[1] = -Vx-Vy+Vw;//右后
|
|
||||||
// c->hopemotorout.OmniSpeedOut[2] = Vx-Vy+Vw;//左后
|
|
||||||
// c->hopemotorout.OmniSpeedOut[3] = Vx+Vy+Vw;//左前
|
|
||||||
// c->hopemotorout.OmniSpeedOut[0] = -Nor_Vx+Nor_Vy+Vw + c->pos088 .bmi088.gyro.z;//右前
|
|
||||||
// c->hopemotorout.OmniSpeedOut[1] = -Nor_Vx-Nor_Vy+Vw + c->pos088 .bmi088.gyro.z;//右后
|
|
||||||
// c->hopemotorout.OmniSpeedOut[2] = Nor_Vx-Nor_Vy+Vw + c->pos088 .bmi088.gyro.z;//左后
|
|
||||||
// c->hopemotorout.OmniSpeedOut[3] = Nor_Vx+Nor_Vy+Vw + c->pos088 .bmi088.gyro.z;//左前
|
|
||||||
c->hopemotorout.OmniSpeedOut[0] = -Nor_Vx+Nor_Vy+Vw ;//右前
|
|
||||||
c->hopemotorout.OmniSpeedOut[1] = -Nor_Vx-Nor_Vy+Vw ;//右后
|
|
||||||
c->hopemotorout.OmniSpeedOut[2] = Nor_Vx-Nor_Vy+Vw ;//左后
|
|
||||||
c->hopemotorout.OmniSpeedOut[3] = Nor_Vx+Nor_Vy+Vw ;//左前
|
|
||||||
|
|
||||||
// if(!Vw){
|
|
||||||
// PIAN = jiuzheng(c->pos088 .imu_eulr .yaw );
|
|
||||||
// }
|
|
||||||
// c->hopemotorout.OmniSpeedOut[0] += PIAN ;//右前
|
|
||||||
// c->hopemotorout.OmniSpeedOut[1] += PIAN ;//右后
|
|
||||||
// c->hopemotorout.OmniSpeedOut[2] += PIAN ;//左后
|
|
||||||
// c->hopemotorout.OmniSpeedOut[3] += PIAN ;//左前
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int8_t Chassis_Control(Chassis_t *c,CMD_t *ctrl,CAN_Output_t *out)
|
|
||||||
{
|
|
||||||
if(c ==NULL) return CHASSIS_ERR_NULL;
|
|
||||||
if(ctrl ==NULL) return CHASSIS_ERR_NULL;
|
|
||||||
|
|
||||||
|
|
||||||
Chassis_SetCtrl(c,ctrl);
|
|
||||||
|
|
||||||
//此处对imu加滤波做修正
|
|
||||||
c->pos088.bmi088.filtered_gyro.z =LowPassFilter2p_Apply(&(c->filled[0]),c->pos088.bmi088.gyro.z);
|
|
||||||
|
|
||||||
switch (c->chassis_ctrl .ctrl)
|
|
||||||
{
|
|
||||||
case RCcontrol: //手动控制
|
|
||||||
|
|
||||||
/*
|
|
||||||
在cmd里对数据进行处理 包括方向和油门
|
|
||||||
6000为全向轮的倍率,遥控器坐标系和机器人坐标系不同*/
|
|
||||||
if(c->chassis_ctrl .mode == Pitch){
|
|
||||||
c->move_vec.Vw = 0;
|
|
||||||
c->move_vec.Vx = 0;
|
|
||||||
c->move_vec.Vy = 0;
|
|
||||||
}
|
|
||||||
else if(c->chassis_ctrl .mode == UP_Adjust)
|
|
||||||
{
|
|
||||||
c->move_vec.Vw = ctrl->Vw*6000;
|
|
||||||
c->move_vec.Vx = 0;
|
|
||||||
c->move_vec.Vy = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c->move_vec.Vw = ctrl->Vw*6000;
|
|
||||||
c->move_vec.Vx = ctrl->Vy*6000;
|
|
||||||
c->move_vec.Vy = ctrl->Vx*6000;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AUTO : //在自动模式下
|
|
||||||
|
|
||||||
switch(c->chassis_ctrl.mode ){
|
|
||||||
|
|
||||||
|
|
||||||
case AUTO_NAVI: //自动雷达
|
|
||||||
// //这套是全向轮的方向,一定要注意这里的xy方向
|
|
||||||
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 ;
|
|
||||||
// c->move_vec.Vw =LowPassFilter2p_Apply(&(c->filled[1]),c->move_vec.Vw);
|
|
||||||
// c->move_vec.Vy =LowPassFilter2p_Apply(&(c->filled[2]),c->move_vec.Vy);
|
|
||||||
// c->move_vec.Vx =LowPassFilter2p_Apply(&(c->filled[3]),c->move_vec.Vx);
|
|
||||||
//
|
|
||||||
// c->move_vec.Vw =PID_calc(&(c->pid.chassis_NaviWzPID),c->pos088.bmi088.gyro.z,c->move_vec.Vw);
|
|
||||||
// c->move_vec.Vx =PID_calc(&(c->pid.chassis_NaviVxPID),c->pos088.bmi088.accl.y,c->move_vec.Vx);
|
|
||||||
// c->move_vec.Vy =PID_calc(&(c->pid.chassis_NaviVyPID),c->pos088.bmi088.accl.x,c->move_vec.Vy);
|
|
||||||
// //电机速度限幅
|
|
||||||
|
|
||||||
abs_limit_fp(&c->move_vec.Vx,2000.0f);
|
|
||||||
|
|
||||||
abs_limit_fp(&c->move_vec.Vy,2000.0f);
|
|
||||||
|
|
||||||
abs_limit_fp(&c->move_vec.Vw,2000.0f);
|
|
||||||
|
|
||||||
if(ctrl->status[5] ==1)
|
|
||||||
{
|
|
||||||
c->move_vec.Vw = c->move_vec.Vw * 0.8f;
|
|
||||||
c->move_vec.Vx = c->move_vec.Vx * 0.5f;
|
|
||||||
c->move_vec.Vy = c->move_vec.Vy * 0.5f;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AUTO_NAVI_Pitch: //自动视觉
|
|
||||||
|
|
||||||
c->move_vec.Vw =0;
|
|
||||||
c->move_vec.Vy =0;
|
|
||||||
c->move_vec.Vx =0 ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if(abs_value(ctrl ->cmd_pick .posx )>20)
|
|
||||||
// {
|
|
||||||
// c->move_vec.Vw =PID_calc(&(c->pid.chassis_PICKWzPID_HIGN),(c->move_vec .Vw) ,0);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// else if(abs_value(ctrl ->cmd_pick .posx )<0.1)
|
|
||||||
// {
|
|
||||||
// c->move_vec.Vw =0;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// c->move_vec.Vw =PID_calc(&(c->pid.chassis_PICKWzPID_LOW),(c->move_vec .Vw) ,0);
|
|
||||||
|
|
||||||
// c->move_vec.Vw =LowPassFilter2p_Apply(&(c->filled[1]),c->move_vec.Vw);
|
|
||||||
|
|
||||||
//
|
|
||||||
// c->vofa_send[0]=c->move_vec.Vw;
|
|
||||||
// c->vofa_send[1]=-ctrl->cmd_pick .posx;
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
break ;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//电机速度限幅
|
|
||||||
|
|
||||||
abs_limit_fp(&c->move_vec.Vx,6000.0f);
|
|
||||||
|
|
||||||
abs_limit_fp(&c->move_vec.Vy,6000.0f);
|
|
||||||
|
|
||||||
abs_limit_fp(&c->move_vec.Vw,6000.0f);
|
|
||||||
|
|
||||||
Chassis_speed_calculate(c,c->move_vec.Vx,c->move_vec.Vy,c->move_vec.Vw);
|
|
||||||
|
|
||||||
|
|
||||||
for (uint8_t i = 0 ; i <4 ; i++)
|
|
||||||
{
|
|
||||||
c->final_out.final_3508out[i] = PID_calc(&(c->pid.chassis_3508VecPID[i]),c->motorfeedback.rotor_rpm3508[i],c->hopemotorout.OmniSpeedOut[i]);
|
|
||||||
|
|
||||||
out->motor_CHASSIS3508 .as_array[i] = c->final_out.final_3508out[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// c->vofa_send[0]=c->pos088.bmi088.gyro.z;
|
|
||||||
|
|
||||||
// c->vofa_send[1]=c->motorfeedback .rotor_rpm3508 [0];
|
|
||||||
// c->vofa_send[2]=c->motorfeedback .rotor_rpm3508 [1];
|
|
||||||
// c->vofa_send[3]=c->motorfeedback .rotor_rpm3508 [2];
|
|
||||||
// c->vofa_send[4]=c->motorfeedback .rotor_rpm3508 [3];
|
|
||||||
//
|
|
||||||
// c->vofa_send[0]=c->hopemotorout .OmniSpeedOut [0];
|
|
||||||
// c->vofa_send[1]=c->hopemotorout .OmniSpeedOut [0];
|
|
||||||
//// c->vofa_send[2]=c->hopemotorout .OmniSpeedOut [2];
|
|
||||||
// c->vofa_send[3]=c->hopemotorout .OmniSpeedOut [3];
|
|
||||||
|
|
||||||
//// c->vofa_send[4]=c->motorfeedback .rotor_rpm3508 [0];
|
|
||||||
// c->vofa_send[0]=c->motorfeedback .rotor_rpm3508 [0];
|
|
||||||
//// c->vofa_send[6]=c->motorfeedback .rotor_rpm3508 [2];
|
|
||||||
// c->vofa_send[2]=c->motorfeedback .rotor_rpm3508 [3];
|
|
||||||
//
|
|
||||||
// c->vofa_send[5]=c->pos088 .imu_eulr .yaw ;
|
|
||||||
|
|
||||||
return CHASSIS_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
pid_type_def pid;
|
|
||||||
|
|
||||||
pid_param_t pid_param={
|
|
||||||
.p = 0.50f,
|
|
||||||
.i = 0.0f,
|
|
||||||
.d = 0.0f,
|
|
||||||
.i_limit = 50.0f,
|
|
||||||
.out_limit = 100.0f
|
|
||||||
};
|
|
||||||
fp32 jiuzheng(fp32 yaw)
|
|
||||||
{
|
|
||||||
static fp32 pian_yaw=0;
|
|
||||||
static fp32 shang_yaw=0;
|
|
||||||
static int is=0;
|
|
||||||
|
|
||||||
|
|
||||||
if(is==0)
|
|
||||||
{
|
|
||||||
PID_init (&pid,PID_POSITION ,&pid_param);
|
|
||||||
is=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pian_yaw+= (yaw - shang_yaw);
|
|
||||||
shang_yaw=yaw ;
|
|
||||||
|
|
||||||
return PID_calc(&pid,pian_yaw,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -90,7 +90,11 @@ typedef struct
|
|||||||
fp32 Vw;
|
fp32 Vw;
|
||||||
fp32 mul;//油门倍率
|
fp32 mul;//油门倍率
|
||||||
}ChassisMove_Vec;
|
}ChassisMove_Vec;
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
fp32 send[4];
|
||||||
|
|
||||||
|
}NUC_send_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -160,6 +164,7 @@ typedef struct{
|
|||||||
|
|
||||||
int32_t sick_dis[4]; //获取到的sick激光值
|
int32_t sick_dis[4]; //获取到的sick激光值
|
||||||
|
|
||||||
|
NUC_send_t NUC_send;
|
||||||
|
|
||||||
|
|
||||||
}Chassis_t;
|
}Chassis_t;
|
||||||
|
@ -191,11 +191,14 @@ int8_t CMD_LD(CMD_t *cmd,const CMD_RC_t *rc){
|
|||||||
if(cmd ->CMD_CtrlType ==AUTO){
|
if(cmd ->CMD_CtrlType ==AUTO){
|
||||||
|
|
||||||
/*自动下的*/
|
/*自动下的*/
|
||||||
|
if (rc->LD.key_C ==CMD_SW_UP) cmd ->CMD_mode =AUTO_NAVI_Adjust;
|
||||||
|
else {
|
||||||
|
|
||||||
if(rc->LD.key_E ==CMD_SW_DOWN ) cmd ->CMD_mode =Normal;
|
if(rc->LD.key_E ==CMD_SW_DOWN ) cmd ->CMD_mode =Normal;
|
||||||
else if(rc->LD.key_E ==CMD_SW_UP) cmd ->CMD_mode =AUTO_NAVI_Pitch;
|
else if(rc->LD.key_E ==CMD_SW_UP) cmd ->CMD_mode =AUTO_NAVI_Pitch;
|
||||||
else if(rc->LD .key_E ==CMD_SW_MID ) cmd ->CMD_mode =AUTO_NAVI;
|
else if(rc->LD .key_E ==CMD_SW_MID ) cmd ->CMD_mode =AUTO_NAVI;
|
||||||
else cmd ->CMD_mode =Normal ;
|
else cmd ->CMD_mode =Normal ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(cmd ->CMD_CtrlType ==RCcontrol){
|
else if(cmd ->CMD_CtrlType ==RCcontrol){
|
||||||
/*手动下的*/
|
/*手动下的*/
|
||||||
|
@ -25,6 +25,7 @@ typedef enum{
|
|||||||
|
|
||||||
AUTO_NAVI,
|
AUTO_NAVI,
|
||||||
AUTO_NAVI_Pitch,
|
AUTO_NAVI_Pitch,
|
||||||
|
AUTO_NAVI_Adjust,//雷达调整
|
||||||
|
|
||||||
UP_Adjust,//上层调整
|
UP_Adjust,//上层调整
|
||||||
|
|
||||||
|
@ -85,13 +85,14 @@ void Task_Chassis(void *argument)
|
|||||||
|
|
||||||
osMessageQueueReset(task_runtime.msgq.can.output.chassis3508);//清空队列
|
osMessageQueueReset(task_runtime.msgq.can.output.chassis3508);//清空队列
|
||||||
osMessageQueuePut(task_runtime.msgq.can.output.chassis3508, &out.motor_CHASSIS3508, 0, 0); //发送数据
|
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); //发送数据
|
||||||
vofa_send[0] = chassis.vofa_send[0];
|
vofa_send[0] = chassis.vofa_send[0];
|
||||||
vofa_send[1] = chassis.vofa_send[1];
|
vofa_send[1] = chassis.vofa_send[1];
|
||||||
vofa_send[2] = chassis.vofa_send[2];
|
vofa_send[2] = chassis.vofa_send[2];
|
||||||
vofa_send[3] = chassis.vofa_send[3];
|
vofa_send[3] = chassis.vofa_send[3];
|
||||||
vofa_send[4] = chassis.vofa_send[4];
|
vofa_send[4] = chassis.vofa_send[4];
|
||||||
vofa_send[5] = chassis.vofa_send[5];
|
vofa_send[5] = chassis.vofa_send[5];
|
||||||
vofa_send[6] = chassis.vofa_send[6];
|
vofa_send[6] = chassis.vofa_send[6];
|
||||||
vofa_send[7] = chassis.vofa_send[7];
|
vofa_send[7] = chassis.vofa_send[7];
|
||||||
|
|
||||||
|
@ -85,7 +85,9 @@ void Task_Init(void *argument) {
|
|||||||
|
|
||||||
task_runtime.msgq.cmd.raw.nuc =
|
task_runtime.msgq.cmd.raw.nuc =
|
||||||
osMessageQueueNew(3u,sizeof(CMD_NUC_t), NULL);
|
osMessageQueueNew(3u,sizeof(CMD_NUC_t), NULL);
|
||||||
|
task_runtime.msgq.cmd.raw.nuc_send =
|
||||||
|
osMessageQueueNew(3u,sizeof(NUC_send_t), NULL);
|
||||||
|
|
||||||
osKernelUnlock();
|
osKernelUnlock();
|
||||||
osThreadTerminate(osThreadGetId()); /* 结束自身 */
|
osThreadTerminate(osThreadGetId()); /* 结束自身 */
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,15 @@
|
|||||||
|
|
||||||
NUC_t nuc_raw;
|
NUC_t nuc_raw;
|
||||||
CMD_NUC_t cmd_fromnuc;
|
CMD_NUC_t cmd_fromnuc;
|
||||||
|
|
||||||
|
NUC_send_t NUC_send;
|
||||||
#else
|
#else
|
||||||
static NUC_t nuc_raw;
|
static NUC_t nuc_raw;
|
||||||
static CMD_NUC_t cmd_fromnuc;
|
static CMD_NUC_t cmd_fromnuc;
|
||||||
|
NUC_send_t NUC_send;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
fp32 send[4]={11.0f,45.0,1.f,4.0f};
|
//fp32 send[4]={11.0f,45.0,1.f,4.0f};
|
||||||
void Task_nuc(void *argument){
|
void Task_nuc(void *argument){
|
||||||
(void)argument; /**/
|
(void)argument; /**/
|
||||||
|
|
||||||
@ -29,7 +31,7 @@ void Task_nuc(void *argument){
|
|||||||
task_runtime.stack_water_mark.nuc= osThreadGetStackSpace(osThreadGetId());
|
task_runtime.stack_water_mark.nuc= osThreadGetStackSpace(osThreadGetId());
|
||||||
#endif
|
#endif
|
||||||
NUC_StartReceiving();
|
NUC_StartReceiving();
|
||||||
NUC_StartSending(send);
|
NUC_StartSending(NUC_send.send);
|
||||||
if (NUC_WaitDmaCplt()){
|
if (NUC_WaitDmaCplt()){
|
||||||
NUC_RawParse(&cmd_fromnuc);
|
NUC_RawParse(&cmd_fromnuc);
|
||||||
}
|
}
|
||||||
@ -38,7 +40,8 @@ void Task_nuc(void *argument){
|
|||||||
}
|
}
|
||||||
osMessageQueueReset(task_runtime.msgq.cmd.raw.nuc);
|
osMessageQueueReset(task_runtime.msgq.cmd.raw.nuc);
|
||||||
osMessageQueuePut(task_runtime.msgq.cmd.raw.nuc,&(cmd_fromnuc),0,0);
|
osMessageQueuePut(task_runtime.msgq.cmd.raw.nuc,&(cmd_fromnuc),0,0);
|
||||||
|
osMessageQueueGet(task_runtime.msgq.cmd.raw.nuc_send, &NUC_send, NULL, 0);
|
||||||
|
|
||||||
|
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刄1ķ*/
|
tick += delay_tick; /* 计算下一个唤醒时刄1ķ*/
|
||||||
osDelayUntil(tick);
|
osDelayUntil(tick);
|
||||||
|
@ -58,17 +58,15 @@ typedef struct {
|
|||||||
struct {
|
struct {
|
||||||
struct {
|
struct {
|
||||||
osMessageQueueId_t rc;
|
osMessageQueueId_t rc;
|
||||||
osMessageQueueId_t nuc;
|
osMessageQueueId_t nuc; //
|
||||||
osMessageQueueId_t eulr;/*姿态结算得到的欧拉角*/
|
osMessageQueueId_t eulr;/*姿态结算得到的欧拉角*/
|
||||||
|
osMessageQueueId_t nuc_send; //给nuc发
|
||||||
|
|
||||||
}raw;
|
}raw;
|
||||||
|
|
||||||
/*控制分离*/
|
/*控制分离*/
|
||||||
osMessageQueueId_t UP_cmd_ctrl_t;
|
osMessageQueueId_t UP_cmd_ctrl_t;
|
||||||
osMessageQueueId_t CHASSIS_cmd_ctrl_t;
|
osMessageQueueId_t CHASSIS_cmd_ctrl_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
osMessageQueueId_t status;
|
osMessageQueueId_t status;
|
||||||
} cmd;
|
} cmd;
|
||||||
|
Loading…
Reference in New Issue
Block a user