Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46ff0ff445 | |||
|
|
7aef65bf92 | ||
|
|
f05b2c120b |
@@ -410,7 +410,12 @@
|
|||||||
<Ww>
|
<Ww>
|
||||||
<count>9</count>
|
<count>9</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>ref</ItemText>
|
<ItemText>gimbal</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>10</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>cmd</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<MemoryWindow4>
|
<MemoryWindow4>
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>STM32F407IGHx</Device>
|
<Device>STM32F407IGHx</Device>
|
||||||
<Vendor>STMicroelectronics</Vendor>
|
<Vendor>STMicroelectronics</Vendor>
|
||||||
<PackID>Keil.STM32F4xx_DFP.2.15.0</PackID>
|
<PackID>Keil.STM32F4xx_DFP.2.17.1</PackID>
|
||||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||||
<Cpu>IRAM(0x20000000-0x2001FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
<Cpu>IRAM(0x20000000-0x2001FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
||||||
<FlashUtilSpec></FlashUtilSpec>
|
<FlashUtilSpec></FlashUtilSpec>
|
||||||
<StartupFile></StartupFile>
|
<StartupFile></StartupFile>
|
||||||
@@ -1732,8 +1732,8 @@
|
|||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>STM32F407IGHx</Device>
|
<Device>STM32F407IGHx</Device>
|
||||||
<Vendor>STMicroelectronics</Vendor>
|
<Vendor>STMicroelectronics</Vendor>
|
||||||
<PackID>Keil.STM32F4xx_DFP.2.15.0</PackID>
|
<PackID>Keil.STM32F4xx_DFP.2.17.1</PackID>
|
||||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||||
<Cpu>IRAM(0x20000000-0x2001FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
<Cpu>IRAM(0x20000000-0x2001FFFF) IRAM2(0x10000000-0x1000FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")</Cpu>
|
||||||
<FlashUtilSpec></FlashUtilSpec>
|
<FlashUtilSpec></FlashUtilSpec>
|
||||||
<StartupFile></StartupFile>
|
<StartupFile></StartupFile>
|
||||||
|
|||||||
Binary file not shown.
19244
MDK-ARM/DevC/DevC.hex
19244
MDK-ARM/DevC/DevC.hex
File diff suppressed because it is too large
Load Diff
@@ -250,7 +250,7 @@ static void CMD_RcLogic(const CMD_RC_t *rc, CMD_t *cmd, float dt_sec) {
|
|||||||
cmd->chassis.ctrl_vec.vx = rc->ch_l_x;
|
cmd->chassis.ctrl_vec.vx = rc->ch_l_x;
|
||||||
cmd->chassis.ctrl_vec.vy = rc->ch_l_y;
|
cmd->chassis.ctrl_vec.vy = rc->ch_l_y;
|
||||||
cmd->gimbal.delta_eulr.yaw = rc->ch_r_x * dt_sec * cmd->param->sens_rc;
|
cmd->gimbal.delta_eulr.yaw = rc->ch_r_x * dt_sec * cmd->param->sens_rc;
|
||||||
cmd->gimbal.delta_eulr.pit = rc->ch_r_y * dt_sec * cmd->param->sens_rc;
|
cmd->gimbal.delta_eulr.pit = -rc->ch_r_y * dt_sec * cmd->param->sens_rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ inline float CalculateRpm(float bullet_speed, float fric_radius, bool is17mm) {
|
|||||||
} else {
|
} else {
|
||||||
if (bullet_speed == 10.0f) return 4450.f;
|
if (bullet_speed == 10.0f) return 4450.f;
|
||||||
if (bullet_speed == 16.0f) return 5800.f;
|
if (bullet_speed == 16.0f) return 5800.f;
|
||||||
|
if (bullet_speed == 15.0f) return 5350.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 不为裁判系统设定值时,计算转速 */
|
/* 不为裁判系统设定值时,计算转速 */
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ static osThreadId_t thread_alert;
|
|||||||
static CAN_t *gcan;
|
static CAN_t *gcan;
|
||||||
static bool inited = false;
|
static bool inited = false;
|
||||||
|
|
||||||
volatile pm01_od_t pm01_od;
|
|
||||||
|
|
||||||
/* Private function -------------------------------------------------------- */
|
/* Private function -------------------------------------------------------- */
|
||||||
static void CAN_Motor_Decode(CAN_MotorFeedback_t *feedback,
|
static void CAN_Motor_Decode(CAN_MotorFeedback_t *feedback,
|
||||||
const uint8_t *raw)
|
const uint8_t *raw)
|
||||||
@@ -263,8 +261,8 @@ int8_t CAN_Motor_Control(CAN_MotorGroup_t group, CAN_Output_t *output,
|
|||||||
&(can->mailbox.shoot));
|
&(can->mailbox.shoot));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return DEVICE_OK;
|
return DEVICE_OK;
|
||||||
}
|
}
|
||||||
@@ -310,60 +308,6 @@ int8_t CAN_StoreMsg(CAN_t *can, CAN_RawRx_t *can_rx)
|
|||||||
can->recive_flag |= 1 << 10;
|
can->recive_flag |= 1 << 10;
|
||||||
CAN_Tof_Decode(&(can->tof), can_rx->rx_data);
|
CAN_Tof_Decode(&(can->tof), can_rx->rx_data);
|
||||||
break;
|
break;
|
||||||
//超电
|
|
||||||
case 0x600:
|
|
||||||
pm01_od.ccr = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
|
||||||
can->cap.cap_od.ccr = pm01_od.ccr;
|
|
||||||
break;
|
|
||||||
case 0x601:
|
|
||||||
pm01_od.p_set = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
|
||||||
can->cap.cap_od.p_set = pm01_od.p_set;
|
|
||||||
break;
|
|
||||||
case 0x602:
|
|
||||||
pm01_od.v_set = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
|
||||||
can->cap.cap_od.v_set = pm01_od.v_set;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x603:
|
|
||||||
pm01_od.i_set = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
|
||||||
can->cap.cap_od.i_set = pm01_od.i_set;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x610:
|
|
||||||
pm01_od.sta_code.all = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
|
||||||
can->cap.cap_od.sta_code.all = pm01_od.sta_code.all;
|
|
||||||
pm01_od.err_code = (uint16_t)can_rx->rx_data[2] << 8 | can_rx->rx_data[3];
|
|
||||||
can->cap.cap_od.err_code = pm01_od.err_code;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x611:
|
|
||||||
pm01_od.p_in = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
|
||||||
can->cap.cap_od.p_in = pm01_od.p_in;
|
|
||||||
pm01_od.v_in = (uint16_t)can_rx->rx_data[2] << 8 | can_rx->rx_data[3];
|
|
||||||
can->cap.cap_od.v_in = pm01_od.v_in;
|
|
||||||
pm01_od.i_in = (uint16_t)can_rx->rx_data[4] << 8 | can_rx->rx_data[5];
|
|
||||||
can->cap.cap_od.i_in = pm01_od.i_in;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x612:
|
|
||||||
pm01_od.p_out = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
|
||||||
can->cap.cap_od.p_out = pm01_od.p_out;
|
|
||||||
pm01_od.v_out = (uint16_t)can_rx->rx_data[2] << 8 | can_rx->rx_data[3];
|
|
||||||
can->cap.cap_od.v_out = pm01_od.v_out;
|
|
||||||
pm01_od.i_out = (uint16_t)can_rx->rx_data[4] << 8 | can_rx->rx_data[5];
|
|
||||||
can->cap.cap_od.i_out = pm01_od.i_out;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x613:
|
|
||||||
pm01_od.temp = (uint16_t)can_rx->rx_data[0] << 8 | can_rx->rx_data[1];
|
|
||||||
can->cap.cap_od.temp = pm01_od.temp;
|
|
||||||
pm01_od.total_time = (uint16_t)can_rx->rx_data[2] << 8 | can_rx->rx_data[3];
|
|
||||||
can->cap.cap_od.total_time = pm01_od.total_time;
|
|
||||||
pm01_od.run_time = (uint16_t)can_rx->rx_data[4] << 8 | can_rx->rx_data[5];
|
|
||||||
can->cap.cap_od.run_time = pm01_od.run_time;
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -385,7 +329,6 @@ int8_t CAN_ClearFlag(CAN_t *can, uint32_t flag)
|
|||||||
return DEVICE_OK;
|
return DEVICE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//不用这里
|
|
||||||
int8_t CAN_Cap_Control(CAN_CapOutput_t *output, CAN_t *can)
|
int8_t CAN_Cap_Control(CAN_CapOutput_t *output, CAN_t *can)
|
||||||
{
|
{
|
||||||
float power_limit = output->power_limit;
|
float power_limit = output->power_limit;
|
||||||
@@ -405,200 +348,6 @@ int8_t CAN_Cap_Control(CAN_CapOutput_t *output, CAN_t *can)
|
|||||||
return DEVICE_OK;
|
return DEVICE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加的电容控制 int型函数
|
|
||||||
//超电控制
|
|
||||||
/**
|
|
||||||
* @brief 控制命令发送
|
|
||||||
* @param[in] new_cmd 0x00: 停机
|
|
||||||
0x01: 运行,不打开输出负载开关(只给超级电容充电)
|
|
||||||
0x02: 运行,打开输出负载开关(正常运行使用该指令)
|
|
||||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
int8_t CAN_Cap_cmd_send(CAN_CapOutput_t *output, CAN_t *can)
|
|
||||||
{
|
|
||||||
|
|
||||||
uint16_t cmd = output->new_cmd;
|
|
||||||
// uint16_t cmd = 2;
|
|
||||||
|
|
||||||
raw_tx.tx_header.StdId = 0x600;
|
|
||||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
|
||||||
raw_tx.tx_header.RTR = CAN_RTR_DATA;
|
|
||||||
raw_tx.tx_header.DLC = 0x04;
|
|
||||||
raw_tx.tx_data[0] = (uint8_t)(cmd >> 8 );
|
|
||||||
raw_tx.tx_data[1] = (uint8_t)(cmd & 0xFF);
|
|
||||||
raw_tx.tx_data[2] = 0x00;
|
|
||||||
raw_tx.tx_data[3] = (0x00 == 0x01); //反正demo里设置的是0x00,不管了
|
|
||||||
|
|
||||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
|
||||||
raw_tx.tx_data, &(can->mailbox.cap));
|
|
||||||
return DEVICE_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 设置功率
|
|
||||||
* @param[in] new_power:新的功率值
|
|
||||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
int8_t CAN_Cap_power_send(CAN_CapOutput_t *output, CAN_t *can)
|
|
||||||
{
|
|
||||||
uint16_t cmd = output->new_power;
|
|
||||||
//uint16_t cmd = 5000;
|
|
||||||
|
|
||||||
raw_tx.tx_header.StdId = 0x601;
|
|
||||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
|
||||||
raw_tx.tx_header.RTR = CAN_RTR_DATA;
|
|
||||||
raw_tx.tx_header.DLC = 0x04;
|
|
||||||
raw_tx.tx_data[0] = (uint8_t)(cmd >> 8 );
|
|
||||||
raw_tx.tx_data[1] = (uint8_t)(cmd & 0xFF);
|
|
||||||
raw_tx.tx_data[2] = 0x00;
|
|
||||||
raw_tx.tx_data[3] = (0x00 == 0x01); //save_flg
|
|
||||||
|
|
||||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
|
||||||
raw_tx.tx_data, &(can->mailbox.cap));
|
|
||||||
return DEVICE_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 设置输出电压
|
|
||||||
* @param[in] new_volt:新的电压值
|
|
||||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
int8_t CAN_Cap_voltage_send(CAN_CapOutput_t *output, CAN_t *can)
|
|
||||||
{
|
|
||||||
uint16_t cmd = output->new_voltage;
|
|
||||||
// uint16_t cmd = 2400;
|
|
||||||
|
|
||||||
raw_tx.tx_header.StdId = 0x602;
|
|
||||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
|
||||||
raw_tx.tx_header.RTR = CAN_RTR_DATA;
|
|
||||||
raw_tx.tx_header.DLC = 0x04;
|
|
||||||
raw_tx.tx_data[0] = (uint8_t)(cmd >> 8 );
|
|
||||||
raw_tx.tx_data[1] = (uint8_t)(cmd & 0xFF);
|
|
||||||
raw_tx.tx_data[2] = 0x00;
|
|
||||||
raw_tx.tx_data[3] = (0x00 == 0x01); //save_flg
|
|
||||||
|
|
||||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
|
||||||
raw_tx.tx_data, &(can->mailbox.cap));
|
|
||||||
return DEVICE_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief 设置输出电流
|
|
||||||
* @param[in] new_volt:新的电流值
|
|
||||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
int8_t CAN_Cap_current_send(CAN_CapOutput_t *output, CAN_t *can)
|
|
||||||
{
|
|
||||||
uint16_t cmd = output->new_current;
|
|
||||||
// uint16_t cmd = 500;
|
|
||||||
|
|
||||||
raw_tx.tx_header.StdId = 0x603;
|
|
||||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
|
||||||
raw_tx.tx_header.RTR = CAN_RTR_DATA;
|
|
||||||
raw_tx.tx_header.DLC = 0x04;
|
|
||||||
raw_tx.tx_data[0] = (uint8_t)(cmd >> 8 );
|
|
||||||
raw_tx.tx_data[1] = (uint8_t)(cmd & 0xFF);
|
|
||||||
raw_tx.tx_data[2] = 0x00;
|
|
||||||
raw_tx.tx_data[3] = (0x00 == 0x01); //save_flg
|
|
||||||
|
|
||||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
|
||||||
raw_tx.tx_data, &(can->mailbox.cap));
|
|
||||||
return DEVICE_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 获取输入信息
|
|
||||||
* @param[in] new_volt:新的电流值
|
|
||||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
int8_t CAN_Cap_input_send(CAN_t *can)
|
|
||||||
{
|
|
||||||
|
|
||||||
raw_tx.tx_header.StdId = 0x611;
|
|
||||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
|
||||||
raw_tx.tx_header.RTR = CAN_RTR_REMOTE;
|
|
||||||
raw_tx.tx_header.DLC = 0x00;
|
|
||||||
|
|
||||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
|
||||||
raw_tx.tx_data, &(can->mailbox.cap));
|
|
||||||
return DEVICE_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 获取输出信息
|
|
||||||
* @param[in] new_volt:新的电流值
|
|
||||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
int8_t CAN_Cap_output_send(CAN_t *can)
|
|
||||||
{
|
|
||||||
|
|
||||||
raw_tx.tx_header.StdId = 0x612;
|
|
||||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
|
||||||
raw_tx.tx_header.RTR = CAN_RTR_REMOTE;
|
|
||||||
raw_tx.tx_header.DLC = 0x00;
|
|
||||||
|
|
||||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
|
||||||
raw_tx.tx_data, &(can->mailbox.cap));
|
|
||||||
return DEVICE_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 获取其他信息
|
|
||||||
* @param[in] new_volt:新的电流值
|
|
||||||
save_flg: 0x00: 不保存至EEPROM 0x01: 保存至EEPROM
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
int8_t CAN_Cap_other_send(CAN_t *can)
|
|
||||||
{
|
|
||||||
raw_tx.tx_header.StdId = 0x613;
|
|
||||||
raw_tx.tx_header.IDE = CAN_ID_STD;
|
|
||||||
raw_tx.tx_header.RTR = CAN_RTR_REMOTE;
|
|
||||||
raw_tx.tx_header.DLC = 0x00;
|
|
||||||
|
|
||||||
HAL_CAN_AddTxMessage(BSP_CAN_GetHandle(can->param->cap), &raw_tx.tx_header,
|
|
||||||
raw_tx.tx_data, &(can->mailbox.cap));
|
|
||||||
return DEVICE_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 超电容器参数设置
|
|
||||||
* @param cap_out 电容输出结构体
|
|
||||||
* @param can can总线
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
void Can_Set_send(CAN_CapOutput_t *output, CAN_t *can)
|
|
||||||
{
|
|
||||||
|
|
||||||
CAN_Cap_input_send(can);//获取输入信息
|
|
||||||
osDelay(1);
|
|
||||||
CAN_Cap_output_send(can);//获取输出信息
|
|
||||||
osDelay(1);
|
|
||||||
//// CAN_Cap_other_send(can);//获取其他信息
|
|
||||||
//// osDelay(1);
|
|
||||||
CAN_Cap_cmd_send(output, can);//控制命令发送
|
|
||||||
osDelay(1);
|
|
||||||
CAN_Cap_power_send(output, can);//设置功率
|
|
||||||
osDelay(1);
|
|
||||||
CAN_Cap_voltage_send(output, can);//设置输出电压
|
|
||||||
osDelay(1);
|
|
||||||
CAN_Cap_current_send(output, can);//设置输出电流
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CAN_CAP_HandleOffline(CAN_Capacitor_t *cap, CAN_CapOutput_t *cap_out,
|
void CAN_CAP_HandleOffline(CAN_Capacitor_t *cap, CAN_CapOutput_t *cap_out,
|
||||||
float power_chassis)
|
float power_chassis)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -163,10 +163,6 @@ typedef union {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float power_limit;
|
float power_limit;
|
||||||
uint16_t new_cmd;//can的超电控制设置数值
|
|
||||||
uint16_t new_power;
|
|
||||||
uint16_t new_voltage;
|
|
||||||
uint16_t new_current;
|
|
||||||
} CAN_CapOutput_t;
|
} CAN_CapOutput_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -236,61 +232,11 @@ typedef struct {
|
|||||||
uint8_t tx_data[CAN_TX_BUF_SIZE_MAX];
|
uint8_t tx_data[CAN_TX_BUF_SIZE_MAX];
|
||||||
} CAN_RawTx_t;
|
} CAN_RawTx_t;
|
||||||
|
|
||||||
//超电
|
|
||||||
typedef union
|
|
||||||
{
|
|
||||||
|
|
||||||
uint16_t all;
|
|
||||||
struct {
|
|
||||||
uint16_t rdy: 1; /*!< bit0 就绪 */
|
|
||||||
uint16_t run: 1; /*!< bit1 运行 */
|
|
||||||
uint16_t alm: 1; /*!< bit2 报警 */
|
|
||||||
uint16_t pwr: 1; /*!< bit3 电源开关 */
|
|
||||||
uint16_t load: 1; /*!< bit4 负载开关 */
|
|
||||||
uint16_t cc: 1; /*!< bit5 恒流 */
|
|
||||||
uint16_t cv: 1; /*!< bit6 恒压 */
|
|
||||||
uint16_t cw: 1; /*!< bit7 恒功率 */
|
|
||||||
uint16_t revd: 7; /*!< bit8-14 保留 */
|
|
||||||
uint16_t flt: 1; /*!< bit15 故障 */
|
|
||||||
}bit;
|
|
||||||
|
|
||||||
}csr_t;
|
|
||||||
|
|
||||||
typedef struct mb_reg_type{
|
|
||||||
|
|
||||||
uint16_t ccr; /*!< 8000H 控制寄存器 */
|
|
||||||
uint16_t p_set; /*!< 8001H 输入功率限制 */
|
|
||||||
uint16_t v_set; /*!< 8002H 输出电压设置 */
|
|
||||||
uint16_t i_set; /*!< 8003H 输出电流限制 */
|
|
||||||
csr_t sta_code; /*!< 8100H 状态标志位 */
|
|
||||||
uint16_t err_code; /*!< 8101H 故障代码 */
|
|
||||||
int16_t v_in; /*!< 8102H 输入电压 */
|
|
||||||
int16_t i_in; /*!< 8103H 输入电流 */
|
|
||||||
int16_t p_in; /*!< 8104H 输入功率 */
|
|
||||||
int16_t v_out; /*!< 8105H 输出电压 */
|
|
||||||
int16_t i_out; /*!< 8106H 输出电流 */
|
|
||||||
int16_t p_out; /*!< 8107H 输出功率 */
|
|
||||||
int16_t temp; /*!< 8108H 温度 */
|
|
||||||
uint16_t total_time; /*!< 8109H 累计时间 */
|
|
||||||
uint16_t run_time; /*!< 810AH 运行时间 */
|
|
||||||
|
|
||||||
volatile uint16_t pm01_access_id; /* 正在访问的标识符 */
|
|
||||||
volatile uint16_t pm01_response_flg; /* 控制器响应成功标志位 */
|
|
||||||
|
|
||||||
uint16_t g_cmd_set ;
|
|
||||||
uint16_t g_power_set ;
|
|
||||||
uint16_t g_vout_set ;
|
|
||||||
uint16_t g_iout_set ;
|
|
||||||
|
|
||||||
}pm01_od_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float percentage;// 电容器的百分比状态
|
float percentage;
|
||||||
CAN_CapStatus_t cap_status;
|
CAN_CapStatus_t cap_status;
|
||||||
CAN_CapFeedback_t cap_feedback;
|
CAN_CapFeedback_t cap_feedback;
|
||||||
volatile pm01_od_t cap_od;
|
} CAN_Capacitor_t;
|
||||||
} CAN_Capacitor_t;//
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CAN_ChassisMotor_t chassis;
|
CAN_ChassisMotor_t chassis;
|
||||||
@@ -337,16 +283,6 @@ void CAN_CAP_HandleOffline(CAN_Capacitor_t *cap, CAN_CapOutput_t *cap_out,
|
|||||||
|
|
||||||
void CAN_Tof_Decode(CAN_Tof_t *tof, const uint8_t *raw);
|
void CAN_Tof_Decode(CAN_Tof_t *tof, const uint8_t *raw);
|
||||||
|
|
||||||
//添加send函数
|
|
||||||
int8_t CAN_Cap_cmd_send(CAN_CapOutput_t *output, CAN_t *can);
|
|
||||||
int8_t CAN_Cap_power_send(CAN_CapOutput_t *output, CAN_t *can);
|
|
||||||
int8_t CAN_Cap_voltage_send(CAN_CapOutput_t *output, CAN_t *can);
|
|
||||||
int8_t CAN_Cap_current_send(CAN_CapOutput_t *output, CAN_t *can);
|
|
||||||
int8_t CAN_Cap_output_send(CAN_t *can);
|
|
||||||
int8_t CAN_Cap_input_send(CAN_t *can);
|
|
||||||
int8_t CAN_Cap_other_send(CAN_t *can);
|
|
||||||
void Can_Set_send(CAN_CapOutput_t *output, CAN_t *can);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,42 +26,21 @@
|
|||||||
* @param cap_out 电容输出结构体
|
* @param cap_out 电容输出结构体
|
||||||
*/
|
*/
|
||||||
void Cap_Control(CAN_Capacitor_t *cap, const Referee_ForCap_t *referee,
|
void Cap_Control(CAN_Capacitor_t *cap, const Referee_ForCap_t *referee,
|
||||||
CAN_CapOutput_t *cap_out) {
|
CAN_CapOutput_t *cap_out) {
|
||||||
if (referee->ref_status != REF_STATUS_RUNNING) {
|
if (referee->ref_status != REF_STATUS_RUNNING) {
|
||||||
/* 当裁判系统离线时,依然使用裁判系统进程传来的数据 */
|
/* 当裁判系统离线时,依然使用裁判系统进程传来的数据 */
|
||||||
cap_out->power_limit = referee->chassis_power_limit;
|
cap_out->power_limit = referee->chassis_power_limit;
|
||||||
} else {
|
} else {
|
||||||
/* 当裁判系统在线时,使用算法控制裁判系统输出(即电容输入) */
|
/* 当裁判系统在线时,使用算法控制裁判系统输出(即电容输入) */
|
||||||
cap_out->power_limit =
|
cap_out->power_limit =
|
||||||
PowerLimit_CapInput(referee->chassis_watt, referee->chassis_power_limit,
|
PowerLimit_CapInput(referee->chassis_watt, referee->chassis_power_limit,
|
||||||
referee->chassis_pwr_buff);
|
referee->chassis_pwr_buff);
|
||||||
}
|
}
|
||||||
/* 更新电容状态和百分比 */
|
/* 更新电容状态和百分比 */
|
||||||
cap->cap_status = CAN_CAP_STATUS_RUNNING;
|
cap->cap_status = CAN_CAP_STATUS_RUNNING;
|
||||||
// cap->percentage = Capacity_GetCapacitorRemain(cap->cap_feedback.cap_volt,
|
cap->percentage = Capacity_GetCapacitorRemain(cap->cap_feedback.cap_volt,
|
||||||
// cap->cap_feedback.input_volt,
|
cap->cap_feedback.input_volt,
|
||||||
// CAP_CUTOFF_VOLT);//电容剩余电量比例
|
CAP_CUTOFF_VOLT);
|
||||||
cap->percentage = Capacity_GetCapacitorRemain(cap->cap_od.v_out,
|
|
||||||
cap->cap_od.v_in,
|
|
||||||
CAP_CUTOFF_VOLT);//电容剩余电量比例
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 运行设置电容参数
|
|
||||||
*
|
|
||||||
* @param cap_out 电容输出结构体
|
|
||||||
* @param can can总线
|
|
||||||
*/
|
|
||||||
void Cap_Can_Send(CAN_CapOutput_t *cap_out)
|
|
||||||
{
|
|
||||||
cap_out->new_cmd=2;
|
|
||||||
|
|
||||||
cap_out->new_power=5000;
|
|
||||||
|
|
||||||
cap_out->new_voltage=2400;
|
|
||||||
|
|
||||||
cap_out->new_current=100;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,14 +35,6 @@ void Cap_Control(CAN_Capacitor_t *cap, const Referee_ForCap_t *referee,
|
|||||||
*/
|
*/
|
||||||
void Cap_DumpUI(const CAN_Capacitor_t *cap, Referee_CapUI_t *ui);
|
void Cap_DumpUI(const CAN_Capacitor_t *cap, Referee_CapUI_t *ui);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 运行设置电容参数
|
|
||||||
*
|
|
||||||
* @param cap_out 电容输出结构体
|
|
||||||
* @param can can总线
|
|
||||||
*/
|
|
||||||
void Cap_Can_Send(CAN_CapOutput_t *cap_out) ;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ static const Config_RobotParam_t param_hero = {
|
|||||||
.pid = {
|
.pid = {
|
||||||
{
|
{
|
||||||
/* GIMBAL_PID_YAW_OMEGA_IDX */
|
/* GIMBAL_PID_YAW_OMEGA_IDX */
|
||||||
.k = 0.24f,
|
.k = 0.4f,
|
||||||
.p = 1.0f,
|
.p = 1.0f,
|
||||||
.i = 0.5f,
|
.i = 0.5f,
|
||||||
.d = 0.0f,
|
.d = 0.0f,
|
||||||
@@ -268,8 +268,8 @@ static const Config_RobotParam_t param_hero = {
|
|||||||
.range = M_2PI,
|
.range = M_2PI,
|
||||||
}, {
|
}, {
|
||||||
/* GIMBAL_PID_PIT_OMEGA_IDX */
|
/* GIMBAL_PID_PIT_OMEGA_IDX */
|
||||||
.k = 0.6f,
|
.k = 2.0f,
|
||||||
.p = 1.5f,
|
.p = 0.8f,
|
||||||
.i = 0.0f,
|
.i = 0.0f,
|
||||||
.d = 0.0f,
|
.d = 0.0f,
|
||||||
.i_limit = 1.0f,
|
.i_limit = 1.0f,
|
||||||
@@ -278,9 +278,9 @@ static const Config_RobotParam_t param_hero = {
|
|||||||
.range = -1.0f,
|
.range = -1.0f,
|
||||||
}, {
|
}, {
|
||||||
/* GIMBAL_PID_PIT_ANGLE_IDX */
|
/* GIMBAL_PID_PIT_ANGLE_IDX */
|
||||||
.k = 3.0f,
|
.k = 4.0f,
|
||||||
.p = 5.0f,
|
.p = 6.0f,
|
||||||
.i = 2.5f,
|
.i = 1.0f,
|
||||||
.d = 0.0f,
|
.d = 0.0f,
|
||||||
.i_limit = 0.0f,
|
.i_limit = 0.0f,
|
||||||
.out_limit = 10.0f,
|
.out_limit = 10.0f,
|
||||||
@@ -315,7 +315,7 @@ static const Config_RobotParam_t param_hero = {
|
|||||||
},
|
},
|
||||||
.trig_pid_param = {
|
.trig_pid_param = {
|
||||||
.k = 10.0f,
|
.k = 10.0f,
|
||||||
.p = 1.0f,
|
.p = 0.95f,
|
||||||
.i = 0.0f,
|
.i = 0.0f,
|
||||||
.d = 0.032f,
|
.d = 0.032f,
|
||||||
.i_limit = 1.0f,
|
.i_limit = 1.0f,
|
||||||
@@ -358,7 +358,7 @@ static const Config_RobotParam_t param_hero = {
|
|||||||
static const Config_PilotCfg_t cfg_qs = {
|
static const Config_PilotCfg_t cfg_qs = {
|
||||||
.param = {
|
.param = {
|
||||||
.sens_mouse = 0.01f,
|
.sens_mouse = 0.01f,
|
||||||
.sens_rc = 6.0f,
|
.sens_rc = 4.0f,
|
||||||
.map = {
|
.map = {
|
||||||
.key_map[CMD_BEHAVIOR_FORE] = {CMD_ACTIVE_PRESSED, CMD_KEY_W},
|
.key_map[CMD_BEHAVIOR_FORE] = {CMD_ACTIVE_PRESSED, CMD_KEY_W},
|
||||||
.key_map[CMD_BEHAVIOR_BACK] = {CMD_ACTIVE_PRESSED, CMD_KEY_S},
|
.key_map[CMD_BEHAVIOR_BACK] = {CMD_ACTIVE_PRESSED, CMD_KEY_S},
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#define HEAT_INCREASE_42MM (100.f) /* 每发射一颗42mm弹丸增加100热量 */
|
#define HEAT_INCREASE_42MM (100.f) /* 每发射一颗42mm弹丸增加100热量 */
|
||||||
#define HEAT_INCREASE_17MM (10.f) /* 每发射一颗17mm弹丸增加10热量 */
|
#define HEAT_INCREASE_17MM (10.f) /* 每发射一颗17mm弹丸增加10热量 */
|
||||||
|
|
||||||
#define BULLET_SPEED_LIMIT_42MM (16.0)
|
#define BULLET_SPEED_LIMIT_42MM (15.0)
|
||||||
#define BULLET_SPEED_LIMIT_17MM (30.0)
|
#define BULLET_SPEED_LIMIT_17MM (30.0)
|
||||||
|
|
||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
|
|||||||
@@ -53,17 +53,13 @@ void Task_Can(void *argument) {
|
|||||||
osMessageQueueReset(task_runtime.msgq.can.feedback.shoot);
|
osMessageQueueReset(task_runtime.msgq.can.feedback.shoot);
|
||||||
osMessageQueuePut(task_runtime.msgq.can.feedback.shoot, &can, 0, 0);
|
osMessageQueuePut(task_runtime.msgq.can.feedback.shoot, &can, 0, 0);
|
||||||
|
|
||||||
//不注释掉不能用
|
if (CAN_CheckFlag(&can, CAN_REC_CAP_FINISHED)) {
|
||||||
// if (CAN_CheckFlag(&can, CAN_REC_CAP_FINISHED)) {
|
osMessageQueueReset(task_runtime.msgq.can.feedback.cap);
|
||||||
// osMessageQueueReset(task_runtime.msgq.can.feedback.cap);
|
osMessageQueuePut(task_runtime.msgq.can.feedback.cap, &can, 0, 0);
|
||||||
// osMessageQueuePut(task_runtime.msgq.can.feedback.cap, &can, 0, 0);
|
CAN_ClearFlag(&can, CAN_REC_CAP_FINISHED);
|
||||||
// CAN_ClearFlag(&can, CAN_REC_CAP_FINISHED);
|
} else {
|
||||||
// } else {
|
// Error Handle
|
||||||
// // Error Handle
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
osMessageQueueReset(task_runtime.msgq.can.feedback.cap);
|
|
||||||
osMessageQueuePut(task_runtime.msgq.can.feedback.cap, &can, 0, 0);
|
|
||||||
|
|
||||||
if (CAN_CheckFlag(&can, CAN_REC_TOF_FINISHED)) {
|
if (CAN_CheckFlag(&can, CAN_REC_TOF_FINISHED)) {
|
||||||
osMessageQueueReset(task_runtime.msgq.can.feedback.tof);
|
osMessageQueueReset(task_runtime.msgq.can.feedback.tof);
|
||||||
@@ -88,19 +84,10 @@ void Task_Can(void *argument) {
|
|||||||
CAN_Motor_Control(CAN_MOTOR_GROUT_SHOOT1, &can_out, &can);
|
CAN_Motor_Control(CAN_MOTOR_GROUT_SHOOT1, &can_out, &can);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (osMessageQueueGet(task_runtime.msgq.can.output.cap, &(can_out.cap), 0,
|
if (osMessageQueueGet(task_runtime.msgq.can.output.cap, &(can_out.cap), 0,
|
||||||
// 0) == osOK) {
|
0) == osOK) {
|
||||||
// CAN_Cap_Control(&(can_out.cap), &can);
|
CAN_Cap_Control(&(can_out.cap), &can);
|
||||||
// }
|
}
|
||||||
|
|
||||||
//在cap的task里计算电容的输出功率消息队列
|
|
||||||
if (osMessageQueueGet(task_runtime.msgq.can.output.cap, &(can_out.cap), 0,
|
|
||||||
0) == osOK) {
|
|
||||||
// CAN_Cap_Control(&(can_out.cap), &can);
|
|
||||||
Can_Set_send(&(can_out.cap), &can);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,9 +74,6 @@ void Task_Cap(void *argument) {
|
|||||||
osKernelLock(); /* 锁住RTOS内核防止控制过程中断,造成错误 */
|
osKernelLock(); /* 锁住RTOS内核防止控制过程中断,造成错误 */
|
||||||
/* 根据裁判系统数据计算输出功率 */
|
/* 根据裁判系统数据计算输出功率 */
|
||||||
Cap_Control(&can.cap, &referee_cap, &cap_out);
|
Cap_Control(&can.cap, &referee_cap, &cap_out);
|
||||||
/* 超电参数设置 */
|
|
||||||
Cap_Can_Send(&cap_out);
|
|
||||||
|
|
||||||
osKernelUnlock();
|
osKernelUnlock();
|
||||||
/* 将电容输出值发送到CAN */
|
/* 将电容输出值发送到CAN */
|
||||||
osMessageQueueReset(task_runtime.msgq.can.output.cap);
|
osMessageQueueReset(task_runtime.msgq.can.output.cap);
|
||||||
|
|||||||
Reference in New Issue
Block a user