fix: remove duplicate pid_ref from DMMotorInstance
DMMotorInstance had its own pid_ref field while motor_controller already has pid_ref. Use motor_controller.pid_ref uniformly.
This commit is contained in:
@@ -188,7 +188,7 @@ DMMotorInstance *DMMotorInit(DM_Motor_Init_Config_s *config)
|
|||||||
|
|
||||||
void DMMotorSetRef(DMMotorInstance *motor, float ref)
|
void DMMotorSetRef(DMMotorInstance *motor, float ref)
|
||||||
{
|
{
|
||||||
motor->pid_ref = ref;
|
motor->motor_controller.pid_ref = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMMotorSetCtrlMode(DMMotorInstance *motor, DM_Motor_Mode_e mode)
|
void DMMotorSetCtrlMode(DMMotorInstance *motor, DM_Motor_Mode_e mode)
|
||||||
@@ -218,7 +218,7 @@ void DMMotorControl(void)
|
|||||||
/* angle PID: IMU feedback → velocity output */
|
/* angle PID: IMU feedback → velocity output */
|
||||||
float pid_ref = PIDCalculate(&motor->motor_controller.angle_PID,
|
float pid_ref = PIDCalculate(&motor->motor_controller.angle_PID,
|
||||||
*motor->motor_controller.other_angle_feedback_ptr,
|
*motor->motor_controller.other_angle_feedback_ptr,
|
||||||
motor->pid_ref);
|
motor->motor_controller.pid_ref);
|
||||||
|
|
||||||
if (motor->output_reverse == OUTPUT_DIRECTION_REVERSE)
|
if (motor->output_reverse == OUTPUT_DIRECTION_REVERSE)
|
||||||
pid_ref *= -1;
|
pid_ref *= -1;
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ typedef struct
|
|||||||
float mit_kp; // MIT mode KP (motor internal position gain, 0~500)
|
float mit_kp; // MIT mode KP (motor internal position gain, 0~500)
|
||||||
float mit_kd; // MIT mode KD (motor internal velocity gain, 0~5)
|
float mit_kd; // MIT mode KD (motor internal velocity gain, 0~5)
|
||||||
|
|
||||||
float pid_ref; // reference input from application
|
|
||||||
} DMMotorInstance;
|
} DMMotorInstance;
|
||||||
|
|
||||||
/* DM motor init config */
|
/* DM motor init config */
|
||||||
|
|||||||
Reference in New Issue
Block a user