From 3e77eed2bbe7a47dbcd3adec5173dc6d378105d0 Mon Sep 17 00:00:00 2001 From: SkyLi Date: Sat, 30 May 2026 00:36:32 +0800 Subject: [PATCH] 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. --- modules/motor/DMmotor/dmmotor.c | 4 ++-- modules/motor/DMmotor/dmmotor.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/motor/DMmotor/dmmotor.c b/modules/motor/DMmotor/dmmotor.c index 81f4ed1..ebb9efb 100644 --- a/modules/motor/DMmotor/dmmotor.c +++ b/modules/motor/DMmotor/dmmotor.c @@ -188,7 +188,7 @@ DMMotorInstance *DMMotorInit(DM_Motor_Init_Config_s *config) 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) @@ -218,7 +218,7 @@ void DMMotorControl(void) /* angle PID: IMU feedback → velocity output */ float pid_ref = PIDCalculate(&motor->motor_controller.angle_PID, *motor->motor_controller.other_angle_feedback_ptr, - motor->pid_ref); + motor->motor_controller.pid_ref); if (motor->output_reverse == OUTPUT_DIRECTION_REVERSE) pid_ref *= -1; diff --git a/modules/motor/DMmotor/dmmotor.h b/modules/motor/DMmotor/dmmotor.h index d6e2223..cfa2bac 100644 --- a/modules/motor/DMmotor/dmmotor.h +++ b/modules/motor/DMmotor/dmmotor.h @@ -57,7 +57,6 @@ typedef struct 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 pid_ref; // reference input from application } DMMotorInstance; /* DM motor init config */