修改神秘小bug

This commit is contained in:
Robofish 2025-10-02 19:50:55 +08:00
parent 1b237f9944
commit 0b74f21104
5 changed files with 9 additions and 41 deletions

View File

@ -336,13 +336,13 @@ void Chassis_Output(Chassis_t *c) {
if (c == NULL) return;
for (int i = 0; i < 4; i++) {
MOTOR_LZ_MotionParam_t param = {0};
param.torque = c->output.joint[i].torque;
// param.torque = c->output.joint[i].torque;
MOTOR_LZ_MotionControl(&c->param->joint_motors[i], &param);
}
BSP_TIME_Delay_us(400); // 等待CAN总线空闲确保前面的命令发送完成
for (int i = 0; i < 2; i++) {
MOTOR_LK_SetOutput(&c->param->wheel_motors[i], c->output.wheel[i]);
// MOTOR_LK_SetOutput(&c->param->wheel_motors[i], 0.0f);
// MOTOR_LK_SetOutput(&c->param->wheel_motors[i], c->output.wheel[i]);
MOTOR_LK_SetOutput(&c->param->wheel_motors[i], 0.0f);
}
}

View File

@ -180,10 +180,10 @@ Config_RobotParam_t robot_config = {
.rc_can_param = {
.can = BSP_CAN_2,
.mode = RC_CAN_MODE_SLAVE,
.joy_id = 0x250,
.sw_id = 0x251,
.mouse_id = 0x252,
.keyboard_id = 0x253,
.joy_id = 0x30,
.sw_id = 0x31,
.mouse_id = 0x32,
.keyboard_id = 0x33,
},
};

View File

@ -8,7 +8,7 @@
- delay: 0
description: ''
freq_control: true
frequency: 500.0
frequency: 120.0
function: Task_rc
name: rc
stack: 256

View File

@ -7,7 +7,6 @@
#include "task/user_task.h"
/* USER INCLUDE BEGIN */
#include "bsp/can.h"
#include "device/dr16.h"
#include "device/rc_can.h"
#include "module/balance_chassis.h"
#include "module/config.h"
@ -18,10 +17,8 @@
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* USER STRUCT BEGIN */
DR16_t dr16;
RC_CAN_t rc_can;
Chassis_CMD_t cmd_to_chassis;
#define USE_RC_CAN
/* USER STRUCT END */
/* Private function --------------------------------------------------------- */
@ -38,40 +35,12 @@ void Task_rc(void *argument) {
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
/* USER CODE INIT BEGIN */
BSP_CAN_Init();
DR16_Init(&dr16);
RC_CAN_Init(&rc_can, &Config_GetRobotParam()->rc_can_param);
/* USER CODE INIT END */
while (1) {
tick += delay_tick; /* 计算下一个唤醒时刻 */
/* USER CODE BEGIN */
#ifdef USE_DR16
DR16_StartDmaRecv(&dr16);
if (DR16_WaitDmaCplt(20)) {
DR16_ParseData(&dr16);
switch (dr16.data.sw_l) {
case CMD_SW_UP: // 上位
cmd_to_chassis.mode = CHASSIS_MODE_RELAX;
break;
case CMD_SW_MID: // 中位
cmd_to_chassis.mode = CHASSIS_MODE_RECOVER;
break;
case CMD_SW_DOWN: // 下位
cmd_to_chassis.mode = CHASSIS_MODE_WHELL_BALANCE;
break;
default:
cmd_to_chassis.mode = CHASSIS_MODE_RELAX;
break;
}
cmd_to_chassis.move_vec.vx = dr16.data.ch_l_y;
cmd_to_chassis.move_vec.vy = dr16.data.ch_l_x;
cmd_to_chassis.move_vec.wz = dr16.data.ch_r_x;
cmd_to_chassis.height = dr16.data.ch_res;
} else {
DR16_Offline(&dr16);
cmd_to_chassis.mode = CHASSIS_MODE_RELAX;
}
#elif defined USE_RC_CAN
RC_CAN_Update(&rc_can, RC_CAN_DATA_JOYSTICK);
RC_CAN_Update(&rc_can, RC_CAN_DATA_SWITCH);
if (rc_can.header.online) {
@ -97,7 +66,6 @@ void Task_rc(void *argument) {
RC_CAN_OFFLINE(&rc_can);
cmd_to_chassis.mode = CHASSIS_MODE_RELAX;
}
#endif
osMessageQueuePut(task_runtime.msgq.Chassis_cmd, &cmd_to_chassis, 0, 0);
/* USER CODE END */

View File

@ -14,7 +14,7 @@ extern "C" {
/* Exported constants ------------------------------------------------------- */
/* 任务运行频率 */
#define BLINK_FREQ (100.0)
#define RC_FREQ (500.0)
#define RC_FREQ (120.0)
#define ATTI_ESTI_FREQ (1000.0)
#define CTRL_CHASSIS_FREQ (500.0)
#define CTRL_GIMBAL_FREQ (500.0)