refactor: manual mode from absolute setpoint to velocity control, remove auto-enable at motor init
Manual mode now receives angular velocity (degrees/s) via 0xA6 frame instead of absolute angle reference. The firmware integrates velocity * dt into gimbal angle ref. Motors are no longer auto-enabled at DMMotorInit — they stay disabled until a mode switch out of DEBUG. Extract ROBOT_CMD_DELAY macro to replace magic number. Fix "volity" typo → "velocity" and update docs/protocol comments accordingly.
This commit is contained in:
@@ -38,8 +38,8 @@ static void DecodeVision()
|
||||
if (calc_checksum(buf, VISION_MANUAL_LEN) != buf[VISION_MANUAL_LEN - 1])
|
||||
return;
|
||||
vision_data.zero_force = buf[1];
|
||||
memcpy(&vision_data.yaw_ref, buf + 2, 4);
|
||||
memcpy(&vision_data.pitch_ref, buf + 6, 4);
|
||||
memcpy(&vision_data.yaw_degree_velocity, buf + 2, 4);
|
||||
memcpy(&vision_data.pitch_degree_velocity, buf + 6, 4);
|
||||
vision_data.manual_updated = 1;
|
||||
}
|
||||
else if (sof == VISION_SOF_DEBUG && len == VISION_DEBUG_LEN)
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
* error_x/y: float, 归一化误差, 视觉PID外环反馈值
|
||||
*
|
||||
* ---- 手动控制数据帧 0xA6 (11 字节) ----
|
||||
* [SOF:0xA6][zero_force:1][yaw_ref:4][pitch_ref:4][checksum:1]
|
||||
* zero_force: 0=正常角度控制, 1=零力/保持当前位置
|
||||
* yaw_ref/pitch_ref: float, 角度参考值 (degrees)
|
||||
* [SOF:0xA6][zero_force:1][yaw_velocity:4][pitch_velocity:4][checksum:1]
|
||||
* zero_force: 0=正常速度控制, 1=零力/保持当前位置
|
||||
* yaw_velocity/pitch_velocity: float, 角速度 (degrees/s)
|
||||
*
|
||||
* ---- 命令帧 0xA7 (3 字节) ----
|
||||
* [SOF:0xA7][cmd:1][checksum:1]
|
||||
@@ -68,8 +68,8 @@ typedef struct
|
||||
|
||||
/* 手动模式数据 */
|
||||
uint8_t zero_force;
|
||||
float yaw_ref;
|
||||
float pitch_ref;
|
||||
float yaw_degree_velocity;
|
||||
float pitch_degree_velocity;
|
||||
uint8_t manual_updated; // 收到新的手动数据帧标志
|
||||
|
||||
/* 调试模式数据 */
|
||||
|
||||
@@ -191,9 +191,6 @@ DMMotorInstance *DMMotorInit(DM_Motor_Init_Config_s *config)
|
||||
};
|
||||
//motor->motor_daemon = DaemonRegister(&conf);
|
||||
|
||||
/* enable motor */
|
||||
DMMotorSetMode(DM_CMD_ENABLE_MODE, motor);
|
||||
|
||||
dm_motor_instance[idx++] = motor;
|
||||
return motor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user