fix: set txconf.Identifier from tx_id before CANTransmit, enable motor task
- DM motor send functions now fill txconf.Identifier from tx_id before CANTransmit (MIT=tid, PosVel=tid+0x100, Velocity=tid+0x200, SetMode=tid) - Enable motor task with stack size 1024 1000Hz - Increase FDCAN1 StdFiltersNbr from 1 to 14 - Comment out INS temperature log, DM error handling and PID for testing - Remove test_robot_cmd.c
This commit is contained in:
@@ -179,7 +179,8 @@ void INS_Task(void)
|
||||
if ((count % 1000) == 0)
|
||||
{
|
||||
// 1Hz 可以加入monitor函数,检查IMU是否正常运行/离线
|
||||
LOGINFO("[IMU] Temperature: %d C, PWM: %d", (int)(BMI088.Temperature * 100), (int)TempCtrl.Output);
|
||||
//LOGINFO("[IMU] Temperature: %d C, PWM: %d", (int)(BMI088.Temperature * 100), (int)TempCtrl.Output);
|
||||
//LOGINFO("[IMU] Yaw: %d, Pitch: %d, Roll: %d", (int)(INS.Yaw*100), (int)(INS.Pitch*100), (int)(INS.Roll*100));
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
@@ -46,6 +46,7 @@ void DMMotorSendMIT(CANInstance *can, float pos, float vel, float kp, float kd,
|
||||
buf[6] = (uint8_t)(((kd_uint & 0xF) << 4) | (torq_uint >> 8));
|
||||
buf[7] = (uint8_t)(torq_uint);
|
||||
|
||||
can->txconf.Identifier = can->tx_id;
|
||||
CANTransmit(can, 1);
|
||||
}
|
||||
|
||||
@@ -65,11 +66,8 @@ void DMMotorSendPosVel(CANInstance *can, float pos, float vel)
|
||||
buf[6] = vel_bytes[2];
|
||||
buf[7] = vel_bytes[3];
|
||||
|
||||
/* Temporarily change tx_id to motor_id + 0x100 for this transmission */
|
||||
uint32_t saved_id = can->tx_id;
|
||||
can->tx_id = saved_id + 0x100;
|
||||
can->txconf.Identifier = can->tx_id + 0x100;
|
||||
CANTransmit(can, 1);
|
||||
can->tx_id = saved_id;
|
||||
}
|
||||
|
||||
/* Velocity mode: CAN ID = motor_id + 0x200 */
|
||||
@@ -87,10 +85,8 @@ void DMMotorSendVelocity(CANInstance *can, float vel)
|
||||
buf[6] = 0;
|
||||
buf[7] = 0;
|
||||
|
||||
uint32_t saved_id = can->tx_id;
|
||||
can->tx_id = saved_id + 0x200;
|
||||
can->txconf.Identifier = can->tx_id + 0x200;
|
||||
CANTransmit(can, 1);
|
||||
can->tx_id = saved_id;
|
||||
}
|
||||
|
||||
/* ---- Motor commands (enable/disable/zero/clear error) ---- */
|
||||
@@ -99,6 +95,7 @@ void DMMotorSetMode(DMMotor_Mode_e cmd, DMMotorInstance *motor)
|
||||
{
|
||||
memset(motor->motor_can_instance->tx_buff, 0xFF, 7);
|
||||
motor->motor_can_instance->tx_buff[7] = (uint8_t)cmd;
|
||||
motor->motor_can_instance->txconf.Identifier = motor->motor_can_instance->tx_id;
|
||||
CANTransmit(motor->motor_can_instance, 1);
|
||||
}
|
||||
|
||||
@@ -228,9 +225,10 @@ void DMMotorControl(void)
|
||||
|
||||
switch (motor->ctrl_mode)
|
||||
{
|
||||
case DM_MODE_VELOCITY:
|
||||
case DM_MODE_VELOCITY:{
|
||||
DMMotorSendVelocity(can, vel_cmd);
|
||||
break;
|
||||
}
|
||||
case DM_MODE_MIT: {
|
||||
float pos_cmd = pid_ref * DEGREE_2_RAD;
|
||||
LIMIT_MIN_MAX(pos_cmd, DM_P_MIN, DM_P_MAX);
|
||||
|
||||
Reference in New Issue
Block a user