增加限位
This commit is contained in:
parent
7bc41dbeaf
commit
fc2ac5c99d
2
MDK-ARM/.vscode/keil-assistant.log
vendored
2
MDK-ARM/.vscode/keil-assistant.log
vendored
@ -6,3 +6,5 @@
|
||||
|
||||
[info] Log at : 2025/10/17|20:08:11|GMT+0800
|
||||
|
||||
[info] Log at : 2025/10/19|16:41:15|GMT+0800
|
||||
|
||||
|
||||
2
MDK-ARM/.vscode/uv4.log
vendored
2
MDK-ARM/.vscode/uv4.log
vendored
@ -1,4 +1,4 @@
|
||||
*** Using Compiler 'V6.7', folder: 'D:\keil\ARM\ARMCLANG\Bin'
|
||||
Build target 'zzzzh'
|
||||
"zzzzh\zzzzh.axf" - 0 Error(s), 0 Warning(s).
|
||||
Build Time Elapsed: 00:00:02
|
||||
Build Time Elapsed: 00:00:05
|
||||
|
||||
2
MDK-ARM/.vscode/uv4.log.lock
vendored
2
MDK-ARM/.vscode/uv4.log.lock
vendored
@ -1 +1 @@
|
||||
2025/10/17 20:08:32
|
||||
2025/10/19 16:41:29
|
||||
File diff suppressed because one or more lines are too long
@ -143,7 +143,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGUARM</Key>
|
||||
<Name>(105=-1,-1,-1,-1,0)</Name>
|
||||
<Name></Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
@ -161,20 +161,15 @@
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>dr16,0x0A</ItemText>
|
||||
<ItemText>bmi088,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>bmi088,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>imu_eulr,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>imu_temp_pid_param</ItemText>
|
||||
</Ww>
|
||||
@ -183,27 +178,17 @@
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>dr16,0x0A</ItemText>
|
||||
<ItemText>chassis_fb,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>chassis_fb</ItemText>
|
||||
<ItemText>chassis_cmd,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>cmd_to_chassis</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>chassis</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>\\zzzzh\../User/task/test.c\chassis.limit</ItemText>
|
||||
<ItemText>dr16,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow2>
|
||||
<Tracepoint>
|
||||
@ -212,7 +197,7 @@
|
||||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aLwin>0</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
|
||||
@ -81,7 +81,7 @@
|
||||
</BeforeMake>
|
||||
<AfterMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>1</RunUserProg2>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,7 +22,7 @@ Dialog DLL: TCM.DLL V1.32.0.0
|
||||
|
||||
<h2>Project:</h2>
|
||||
c:\Users\ÕÅÐÞÒÕ\Desktop\chassis\MDK-ARM\zzzzh.uvprojx
|
||||
Project File Date: 10/14/2025
|
||||
Project File Date: 10/19/2025
|
||||
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V6.7', folder: 'D:\keil\ARM\ARMCLANG\Bin'
|
||||
@ -50,7 +50,7 @@ Package Vendor: Keil
|
||||
<h2>Collection of Component Files used:</h2>
|
||||
|
||||
* Component: ARM::CMSIS:CORE:5.0.1
|
||||
Build Time Elapsed: 00:00:02
|
||||
Build Time Elapsed: 00:00:05
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -133,7 +133,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h)(0x68C65D
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68C65D59)
|
||||
I (..\User\task\user_task.h)(0x68ECF321)
|
||||
I (..\User\module\config.h)(0x68DCDCE8)
|
||||
I (..\User\module\chassis.h)(0x68ECF095)
|
||||
I (..\User\module\chassis.h)(0x68F49369)
|
||||
I (..\User\bsp\can.h)(0x68EE5C62)
|
||||
I (..\Core\Inc\can.h)(0x68EE5A24)
|
||||
I (..\User\bsp\bsp.h)(0x68EE5C62)
|
||||
@ -1966,7 +1966,7 @@ I (D:\keil\ARM\ARMCLANG\include\string.h)(0x588CAFD2)
|
||||
F (..\User\module\config.c)(0x68DDDFDF)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -c
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
-D__MICROLIB -gdwarf-3 -O3 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../User
-I./RTE/_zzzzh
-ID:/keil/ARM/PACK/ARM/CMSIS/5.0.1/CMSIS/Include
-ID:/keil/ARM/PACK/Keil/STM32F4xx_DFP/2.14.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include
-D__UVISION_VERSION="524" -D_RTE_ -DSTM32F407xx -DUSE_HAL_DRIVER -DSTM32F407xx
-o zzzzh/config.o -MD)
|
||||
I (..\User\module\config.h)(0x68DCDCE8)
|
||||
I (D:\keil\ARM\ARMCLANG\include\stdint.h)(0x588CAFD2)
|
||||
I (..\User\module\chassis.h)(0x68ECF095)
|
||||
I (..\User\module\chassis.h)(0x68F49369)
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68C65D59)
|
||||
I (D:\keil\ARM\ARMCLANG\include\stddef.h)(0x588CAFD2)
|
||||
I (..\User\bsp\can.h)(0x68EE5C62)
|
||||
@ -2025,7 +2025,7 @@ I (..\User\component\ahrs.h)(0x68EE5C62)
|
||||
I (..\User\device\motor_rm.h)(0x68EE5C18)
|
||||
I (..\User\device\motor.h)(0x68EE5C18)
|
||||
I (..\User\device\device.h)(0x68EE5C63)
|
||||
F (..\User\module\chassis.c)(0x68F22AA4)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -c
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
-D__MICROLIB -gdwarf-3 -O3 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../User
-I./RTE/_zzzzh
-ID:/keil/ARM/PACK/ARM/CMSIS/5.0.1/CMSIS/Include
-ID:/keil/ARM/PACK/Keil/STM32F4xx_DFP/2.14.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include
-D__UVISION_VERSION="524" -D_RTE_ -DSTM32F407xx -DUSE_HAL_DRIVER -DSTM32F407xx
-o zzzzh/chassis.o -MD)
|
||||
F (..\User\module\chassis.c)(0x68F4A0FB)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -c
-fno-rtti -funsigned-char -fshort-enums -fshort-wchar
-D__MICROLIB -gdwarf-3 -O3 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../User
-I./RTE/_zzzzh
-ID:/keil/ARM/PACK/ARM/CMSIS/5.0.1/CMSIS/Include
-ID:/keil/ARM/PACK/Keil/STM32F4xx_DFP/2.14.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include
-D__UVISION_VERSION="524" -D_RTE_ -DSTM32F407xx -DUSE_HAL_DRIVER -DSTM32F407xx
-o zzzzh/chassis.o -MD)
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68C65D59)
|
||||
I (D:\keil\ARM\ARMCLANG\include\stdint.h)(0x588CAFD2)
|
||||
I (D:\keil\ARM\ARMCLANG\include\stddef.h)(0x588CAFD2)
|
||||
@ -2083,7 +2083,7 @@ I (D:\keil\ARM\ARMCLANG\include\math.h)(0x58A47FFE)
|
||||
I (..\User\device\motor_rm.h)(0x68EE5C18)
|
||||
I (..\User\device\motor.h)(0x68EE5C18)
|
||||
I (..\User\device\device.h)(0x68EE5C63)
|
||||
I (..\User\module\chassis.h)(0x68ECF095)
|
||||
I (..\User\module\chassis.h)(0x68F49369)
|
||||
I (..\User\component\filter.h)(0x68EE5C62)
|
||||
I (..\User\component\mixer.h)(0x68EE5C62)
|
||||
I (..\User\component\pid.h)(0x68EE5C62)
|
||||
@ -2102,7 +2102,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h)(0x68C65D59
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h)(0x68C65D59)
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68C65D59)
|
||||
I (..\User\module\config.h)(0x68DCDCE8)
|
||||
I (..\User\module\chassis.h)(0x68ECF095)
|
||||
I (..\User\module\chassis.h)(0x68F49369)
|
||||
I (..\User\bsp\can.h)(0x68EE5C62)
|
||||
I (..\Core\Inc\can.h)(0x68EE5A24)
|
||||
I (..\Core\Inc\main.h)(0x68EE5A28)
|
||||
@ -2166,7 +2166,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h)(0x68C65D59
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h)(0x68C65D59)
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68C65D59)
|
||||
I (..\User\module\config.h)(0x68DCDCE8)
|
||||
I (..\User\module\chassis.h)(0x68ECF095)
|
||||
I (..\User\module\chassis.h)(0x68F49369)
|
||||
I (..\User\bsp\can.h)(0x68EE5C62)
|
||||
I (..\Core\Inc\can.h)(0x68EE5A24)
|
||||
I (..\Core\Inc\main.h)(0x68EE5A28)
|
||||
@ -2229,7 +2229,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h)(0x68C65D59
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h)(0x68C65D59)
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68C65D59)
|
||||
I (..\User\module\config.h)(0x68DCDCE8)
|
||||
I (..\User\module\chassis.h)(0x68ECF095)
|
||||
I (..\User\module\chassis.h)(0x68F49369)
|
||||
I (..\User\bsp\can.h)(0x68EE5C62)
|
||||
I (..\Core\Inc\can.h)(0x68EE5A24)
|
||||
I (..\Core\Inc\main.h)(0x68EE5A28)
|
||||
@ -2293,7 +2293,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h)(0x68C65D59
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h)(0x68C65D59)
|
||||
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68C65D59)
|
||||
I (..\User\module\config.h)(0x68DCDCE8)
|
||||
I (..\User\module\chassis.h)(0x68ECF095)
|
||||
I (..\User\module\chassis.h)(0x68F49369)
|
||||
I (..\User\bsp\can.h)(0x68EE5C62)
|
||||
I (..\Core\Inc\can.h)(0x68EE5A24)
|
||||
I (..\Core\Inc\main.h)(0x68EE5A28)
|
||||
|
||||
@ -19,8 +19,10 @@
|
||||
|
||||
|
||||
static int8_t Chassis_SetMode(Chassis_t *c, Chassis_Mode_t mode, uint32_t now) {
|
||||
if (!c) return CHASSIS_ERR_NULL;
|
||||
if (mode == c->mode) return CHASSIS_OK;
|
||||
if (!c)
|
||||
return CHASSIS_ERR_NULL;
|
||||
if (mode == c->mode)
|
||||
return CHASSIS_OK;
|
||||
|
||||
if (mode == CHASSIS_MODE_ROTOR && c->mode != CHASSIS_MODE_ROTOR) {
|
||||
srand(now);
|
||||
@ -47,18 +49,21 @@ static float Chassis_CalcWz(const float min, const float max, uint32_t now) {
|
||||
int8_t Chassis_Init(Chassis_t *c, const Chassis_Params_t *param,
|
||||
AHRS_Eulr_t *mech_zero, float target_freq) {
|
||||
if (!c) return CHASSIS_ERR_NULL;
|
||||
|
||||
c->param = param;
|
||||
c->mode = CHASSIS_MODE_RELAX;
|
||||
|
||||
|
||||
c->mech_zero = *mech_zero;
|
||||
c->feedback.imu.eulr = *mech_zero;
|
||||
c->mech_zero = *mech_zero;
|
||||
c->feedback.imu.eulr = *mech_zero;
|
||||
|
||||
if (param->reverse.yaw) {
|
||||
CircleReverse(&(c->mech_zero.yaw));
|
||||
c->feedback.imu.eulr.yaw = -c->feedback.imu.eulr.yaw + M_2PI;
|
||||
}
|
||||
c->limit.vx.max = param->limit.max_vx;
|
||||
c->limit.vx.min = -param->limit.max_vx;
|
||||
c->limit.vy.max = param->limit.max_vy;
|
||||
c->limit.vy.min = -param->limit.max_vy;
|
||||
c->limit.wz.max = param->limit.max_wz;
|
||||
c->limit.wz.min = -param->limit.max_wz;
|
||||
|
||||
Mixer_Mode_t mixer_mode;
|
||||
switch (param->type) {
|
||||
@ -95,24 +100,23 @@ if (param->reverse.yaw) {
|
||||
PID_Init(&c->pid.motor[i], KPID_MODE_NO_D, target_freq, ¶m->pid.motor_pid_param);
|
||||
LowPassFilter2p_Init(&c->filter.in[i], target_freq, param->low_pass_cutoff_freq.in);
|
||||
LowPassFilter2p_Init(&c->filter.out[i], target_freq, param->low_pass_cutoff_freq.out);
|
||||
|
||||
c->feedback.motor[i].rotor_speed = 0;
|
||||
c->feedback.motor[i].torque_current = 0;
|
||||
c->feedback.motor[i].rotor_abs_angle = 0;
|
||||
c->feedback.motor[i].temp = 0;
|
||||
}
|
||||
|
||||
PID_Init(&c->pid.follow, KPID_MODE_NO_D, target_freq, ¶m->pid.follow_pid_param);
|
||||
Mixer_Init(&c->mixer, mixer_mode);
|
||||
|
||||
c->move_vec.vx = c->move_vec.vy = c->move_vec.wz = 0.0f;
|
||||
for (uint8_t i = 0; i < c->num_wheel; i++) {
|
||||
c->feedback.motor[i].rotor_speed = 0;
|
||||
c->feedback.motor[i].torque_current = 0;
|
||||
c->feedback.motor[i].rotor_abs_angle = 0;
|
||||
c->feedback.motor[i].temp = 0;
|
||||
}
|
||||
for (uint8_t i = 0; i < c->num_wheel; i++) {
|
||||
c->out.motor[i] = 0.0f;
|
||||
}
|
||||
for (int i = 0; i < c->num_wheel; i++) {
|
||||
MOTOR_RM_Register(&(c->param->motor_param[i]));
|
||||
c->motors[i] = MOTOR_RM_GetMotor(&(c->param->motor_param[i]));
|
||||
|
||||
}
|
||||
return CHASSIS_OK;
|
||||
}
|
||||
@ -120,23 +124,27 @@ if (param->reverse.yaw) {
|
||||
|
||||
int8_t Chassis_UpdateFeedback(Chassis_t *c, const Chassis_Feedback_t *feedback) {
|
||||
if (!c || !feedback) return CHASSIS_ERR_NULL;
|
||||
|
||||
float yaw = c->param->reverse.yaw ? -feedback->imu.eulr.yaw : feedback->imu.eulr.yaw;
|
||||
while (yaw > M_PI) yaw -= M_2PI;
|
||||
while (yaw < -M_PI) yaw += M_2PI;
|
||||
c->feedback.imu.eulr.yaw = yaw;
|
||||
|
||||
if (c->param->reverse.yaw) {
|
||||
c->feedback.imu.eulr.yaw = -feedback->imu.eulr.yaw;
|
||||
} else {
|
||||
c->feedback.imu.eulr.yaw = feedback->imu.eulr.yaw;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < c->num_wheel; i++) {
|
||||
MOTOR_RM_Update(&(c->param->motor_param[i]));
|
||||
MOTOR_RM_t *rm_motor = c->motors[i];
|
||||
if (rm_motor) {
|
||||
c->feedback.motor[i] = rm_motor->feedback;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CHASSIS_ERR_NULL;
|
||||
}
|
||||
// MOTOR_RM_t *rm_motor = c->motors[i];
|
||||
// if (rm_motor) {
|
||||
// c->feedback.motor[i] = rm_motor->feedback;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return CHASSIS_ERR_NULL;
|
||||
// }
|
||||
MOTOR_RM_t *rm_motor = MOTOR_RM_GetMotor(&(c->param->motor_param[i]));
|
||||
if (rm_motor != NULL) {
|
||||
c->feedback.motor[i] = rm_motor->feedback;
|
||||
}
|
||||
}
|
||||
return CHASSIS_OK;
|
||||
}
|
||||
@ -148,14 +156,16 @@ int8_t Chassis_Control(Chassis_t *c, const ChassisCmd_t *c_cmd, uint32_t now) {
|
||||
c->dt = (float)(now - c->last_wakeup) / 1000.0f;
|
||||
c->last_wakeup = now;
|
||||
|
||||
if (!isfinite(c->dt) || c->dt <= 0.0f) {
|
||||
c->dt = 0.001f;
|
||||
}
|
||||
if (c->dt < 0.0005f) c->dt = 0.0005f;
|
||||
if (c->dt > 0.050f) c->dt = 0.050f;
|
||||
if (!isfinite(c->dt) || c->dt <= 0.0f) {
|
||||
c->dt = 0.001f;
|
||||
}
|
||||
if (c->dt < 0.0005f) c->dt = 0.0005f;
|
||||
if (c->dt > 0.050f) c->dt = 0.050f;
|
||||
|
||||
Chassis_SetMode(c, c_cmd->mode, now);
|
||||
|
||||
Clip(&c->move_vec.vx, c->limit.vx.min, c->limit.vx.max);
|
||||
Clip(&c->move_vec.vy, c->limit.vy.min, c->limit.vy.max);
|
||||
Clip(&c->move_vec.wz, c->limit.wz.min, c->limit.wz.max);
|
||||
switch (c->mode) {
|
||||
case CHASSIS_MODE_BREAK:
|
||||
c->move_vec.vx = c->move_vec.vy = 0.0f;
|
||||
@ -180,6 +190,7 @@ if (c->dt > 0.050f) c->dt = 0.050f;
|
||||
c->move_vec.wz = 0.0f;
|
||||
break;
|
||||
case CHASSIS_MODE_OPEN:
|
||||
c->move_vec.wz = c_cmd->ctrl_vec.wz;
|
||||
case CHASSIS_MODE_FOLLOW_GIMBAL:
|
||||
c->move_vec.wz = PID_Calc(&c->pid.follow, c->mech_zero.yaw, c->feedback.imu.eulr.yaw, 0.0f, c->dt);
|
||||
break;
|
||||
@ -196,9 +207,10 @@ if (c->dt > 0.050f) c->dt = 0.050f;
|
||||
|
||||
|
||||
for (uint8_t i = 0; i < c->num_wheel; i++) {
|
||||
float rf = c->setpoint.motor_rpm[i];
|
||||
float fb = LowPassFilter2p_Apply(&c->filter.in[i], (float)c->feedback.motor[i].rotor_speed);
|
||||
float out_current = 0.0f;
|
||||
|
||||
//float out_current = 0.0f;
|
||||
float out_current = PID_Calc(&c->pid.motor[i], rf, fb, 0.0f, c->dt);
|
||||
switch (c->mode) {
|
||||
case CHASSIS_MODE_BREAK:
|
||||
case CHASSIS_MODE_FOLLOW_GIMBAL:
|
||||
@ -208,7 +220,7 @@ if (c->dt > 0.050f) c->dt = 0.050f;
|
||||
out_current = PID_Calc(&c->pid.motor[i], c->setpoint.motor_rpm[i], fb, 0.0f, c->dt);
|
||||
break;
|
||||
case CHASSIS_MODE_OPEN:
|
||||
out_current = c->setpoint.motor_rpm[i] / 9000.0f;
|
||||
out_current = c->setpoint.motor_rpm[i] / 7000.0f;
|
||||
break;
|
||||
case CHASSIS_MODE_RELAX:
|
||||
out_current = 0.0f;
|
||||
@ -216,17 +228,17 @@ if (c->dt > 0.050f) c->dt = 0.050f;
|
||||
}
|
||||
|
||||
|
||||
out_current = LowPassFilter2p_Apply(&c->filter.out[i], out_current);
|
||||
|
||||
c->out.motor[i] = out_current;
|
||||
c->out.motor[i] = LowPassFilter2p_Apply(&c->filter.out[i], out_current);
|
||||
Clip(&c->out.motor[i], -c->param->limit.max_current, c->param->limit.max_current);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return CHASSIS_OK;
|
||||
}
|
||||
|
||||
void Chassis_Output(Chassis_t *c) {
|
||||
if (!c) return;
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
//ÿ¸öµç»úÄ¿±êÊä³ö
|
||||
for (uint8_t i = 0; i < c->num_wheel; i++) {
|
||||
@ -240,7 +252,6 @@ void Chassis_Output(Chassis_t *c) {
|
||||
MOTOR_RM_t *rm = c->motors[i];
|
||||
if (rm) {
|
||||
MOTOR_RM_Ctrl(&rm->param);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ extern "C" {
|
||||
#define CHASSIS_ERR_MODE (-3) /* 运行时出配置了错误的ChassisMode_t */
|
||||
#define CHASSIS_ERR_TYPE (-4) /* 运行时出配置了错误的Chassis_Type_t */
|
||||
|
||||
#define MAX_MOTOR_CURRENT 20.0f
|
||||
/* 底盘控制模式 */
|
||||
typedef enum {
|
||||
CHASSIS_MODE_RELAX, /* 放松模式,电机不输出。一般情况底盘初始化之后的模式 */
|
||||
@ -52,7 +53,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
float max;
|
||||
float min;
|
||||
} Chassis_Limit_t;//移植云台的代码
|
||||
} Chassis_Limit_t;
|
||||
|
||||
/* 底盘类型(底盘的物理设计) */
|
||||
typedef enum {
|
||||
@ -85,7 +86,10 @@ typedef struct {
|
||||
struct {
|
||||
bool yaw;
|
||||
} reverse;
|
||||
|
||||
struct {
|
||||
float max_vx, max_vy, max_wz;
|
||||
float max_current;
|
||||
} limit;
|
||||
} Chassis_Params_t;
|
||||
|
||||
typedef struct {
|
||||
@ -136,11 +140,9 @@ typedef struct {
|
||||
KPID_t follow; /* 跟随云台用的PID */
|
||||
} pid;
|
||||
|
||||
// struct {
|
||||
// Chassis_Limit_t vx; // ??????
|
||||
// Chassis_Limit_t vy; // ??????
|
||||
// Chassis_Limit_t wz; // ?z???????
|
||||
//} limit;
|
||||
struct {
|
||||
Chassis_Limit_t vx, vy, wz;
|
||||
} limit;
|
||||
|
||||
/* 滤波器 */
|
||||
struct {
|
||||
@ -226,6 +228,7 @@ void Chassis_ResetOutput(Chassis_t *c);
|
||||
*/
|
||||
//void Chassis_DumpUI(const Chassis_t *c, Referee_ChassisUI_t *ui);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user