修复了遥控器摇杆值解算错误的问题
This commit is contained in:
parent
9f09002235
commit
02b3af15c7
|
@ -59,15 +59,15 @@ void ChassisInit()
|
|||
{
|
||||
// 四个轮子的参数一样,改tx_id和反转标志位即可
|
||||
Motor_Init_Config_s chassis_motor_config = {
|
||||
.can_init_config.can_handle=&hcan2,
|
||||
.can_init_config.can_handle=&hcan1,
|
||||
.controller_param_init_config = {
|
||||
.speed_PID = {
|
||||
.Kp=1,
|
||||
.Kp=10,
|
||||
.Ki=0,
|
||||
.Kd=0,
|
||||
},
|
||||
.current_PID = {
|
||||
.Kp=1,
|
||||
.Kp=10,
|
||||
.Ki=0,
|
||||
.Kd=0,
|
||||
},
|
||||
|
|
|
@ -98,8 +98,8 @@ static void RemoteControlSet()
|
|||
// 左侧开关状态为[下],或视觉未识别到目标,纯遥控器拨杆控制
|
||||
if (switch_is_down(rc_data[TEMP].rc.s[1]) || vision_recv_data->target_state == NO_TARGET)
|
||||
{ // 按照摇杆的输出大小进行角度增量,增益系数需调整
|
||||
gimbal_cmd_send.yaw += 0.04f * (float)rc_data[TEMP].rc.joystick[2];
|
||||
gimbal_cmd_send.pitch += 0.5f * (float)rc_data[TEMP].rc.joystick[3];
|
||||
gimbal_cmd_send.yaw += 0.0015f * (float)rc_data[TEMP].rc.joystick[2];
|
||||
gimbal_cmd_send.pitch += 0.0025f * (float)rc_data[TEMP].rc.joystick[3];
|
||||
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
|
||||
}
|
||||
|
||||
|
@ -114,9 +114,9 @@ static void RemoteControlSet()
|
|||
; // 弹舱舵机控制,待添加servo_motor模块,关闭
|
||||
// 摩擦轮控制,后续可以根据左侧拨轮的值大小切换射频
|
||||
if (rc_data[TEMP].rc.joystick[4] > 100)
|
||||
shoot_cmd_send.shoot_mode = FRICTION_ON;
|
||||
shoot_cmd_send.friction_mode = FRICTION_ON;
|
||||
else
|
||||
shoot_cmd_send.shoot_mode = FRICTION_OFF;
|
||||
shoot_cmd_send.friction_mode = FRICTION_OFF;
|
||||
// 拨弹控制,目前固定为连发
|
||||
if (rc_data[TEMP].rc.joystick[4] > 500)
|
||||
shoot_cmd_send.load_mode = LOAD_BURSTFIRE;
|
||||
|
@ -143,9 +143,9 @@ static void EmergencyHandler()
|
|||
if (rc_data[TEMP].rc.joystick[4] > 300) // 还需添加重要应用和模块离线的判断
|
||||
{
|
||||
robot_state = ROBOT_STOP; // 遥控器左上侧拨轮打满,进入紧急停止模式
|
||||
gimbal_cmd_send.gimbal_mode == GIMBAL_ZERO_FORCE;
|
||||
chassis_cmd_send.chassis_mode == CHASSIS_ZERO_FORCE;
|
||||
shoot_cmd_send.shoot_mode == SHOOT_STOP;
|
||||
gimbal_cmd_send.gimbal_mode = GIMBAL_ZERO_FORCE;
|
||||
chassis_cmd_send.chassis_mode = CHASSIS_ZERO_FORCE;
|
||||
shoot_cmd_send.load_mode = SHOOT_STOP;
|
||||
return;
|
||||
}
|
||||
// if(rc_data[TEMP].rc.joystick[4]<-300 && 各个模块正常)
|
||||
|
|
|
@ -22,7 +22,7 @@ void GimbalInit()
|
|||
Motor_Init_Config_s yaw_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 1,
|
||||
.tx_id = 2,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
|
@ -51,7 +51,7 @@ void GimbalInit()
|
|||
Motor_Init_Config_s pitch_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 2,
|
||||
.tx_id = 1,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
|
|
|
@ -52,14 +52,13 @@
|
|||
* @brief 这些枚举类型和结构体会作为CMD控制数据和各应用的反馈数据的一部分
|
||||
*
|
||||
*/
|
||||
//机器人状态
|
||||
// 机器人状态
|
||||
typedef enum
|
||||
{
|
||||
ROBOT_STOP,
|
||||
ROBOT_WORKING,
|
||||
} Robot_Status_e;
|
||||
|
||||
|
||||
// 应用状态
|
||||
typedef enum
|
||||
{
|
||||
|
@ -94,7 +93,7 @@ typedef enum
|
|||
{
|
||||
FRICTION_OFF, // 摩擦轮关闭
|
||||
FRICTION_ON, // 摩擦轮开启
|
||||
} shoot_mode_e;
|
||||
} friction_mode_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -153,7 +152,7 @@ typedef struct
|
|||
{
|
||||
loader_mode_e load_mode;
|
||||
lid_mode_e lid_mode;
|
||||
shoot_mode_e shoot_mode;
|
||||
friction_mode_e friction_mode;
|
||||
Bullet_Speed_e bullet_speed; // 弹速枚举
|
||||
uint8_t rest_heat;
|
||||
float shoot_rate; // 连续发射的射频,unit per s,发/秒
|
||||
|
|
|
@ -24,17 +24,17 @@ void ShootInit()
|
|||
// 左摩擦轮
|
||||
Motor_Init_Config_s left_friction_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 1,
|
||||
.can_handle = &hcan2,
|
||||
.tx_id = 6,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.speed_PID = {
|
||||
.Kp=1,
|
||||
.Kp=10,
|
||||
.Ki=0,
|
||||
.Kd=0,
|
||||
},
|
||||
.current_PID = {
|
||||
.Kp=1,
|
||||
.Kp=10,
|
||||
.Ki=0,
|
||||
.Kd=0,
|
||||
},
|
||||
|
@ -51,8 +51,8 @@ void ShootInit()
|
|||
// 右摩擦轮
|
||||
Motor_Init_Config_s right_friction_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 2,
|
||||
.can_handle = &hcan2,
|
||||
.tx_id = 5,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.speed_PID = {
|
||||
|
@ -77,8 +77,8 @@ void ShootInit()
|
|||
// 拨盘电机
|
||||
Motor_Init_Config_s loader_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 3,
|
||||
.can_handle = &hcan2,
|
||||
.tx_id = 7,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
|
@ -87,11 +87,6 @@ void ShootInit()
|
|||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.angle_PID = {
|
||||
.Kp=1,
|
||||
.Ki=0,
|
||||
.Kd=0,
|
||||
},
|
||||
.speed_PID = {
|
||||
.Kp=1,
|
||||
.Ki=0,
|
||||
|
|
|
@ -19,11 +19,11 @@ static void sbus_to_rc(volatile const uint8_t *sbus_buf)
|
|||
{
|
||||
memcpy(&rc_ctrl[1], &rc_ctrl[TEMP], sizeof(RC_ctrl_t)); // 保存上一次的数据
|
||||
// 摇杆,直接解算时减去偏置
|
||||
rc_ctrl[TEMP].rc.joystick[0] = (sbus_buf[0] | (sbus_buf[1] << 8)) & 0x07ff - RC_CH_VALUE_OFFSET; //!< Channel 0
|
||||
rc_ctrl[TEMP].rc.joystick[1] = ((sbus_buf[1] >> 3) | (sbus_buf[2] << 5)) & 0x07ff - RC_CH_VALUE_OFFSET; //!< Channel 1
|
||||
rc_ctrl[TEMP].rc.joystick[2] = ((sbus_buf[2] >> 6) | (sbus_buf[3] << 2) | (sbus_buf[4] << 10)) & 0x07ff - RC_CH_VALUE_OFFSET; //!< Channel 2
|
||||
rc_ctrl[TEMP].rc.joystick[3] = ((sbus_buf[4] >> 1) | (sbus_buf[5] << 7)) & 0x07ff - RC_CH_VALUE_OFFSET; //!< Channel 3
|
||||
rc_ctrl[TEMP].rc.joystick[4] = sbus_buf[16] | (sbus_buf[17] << 8) - RC_CH_VALUE_OFFSET; // 左侧拨轮
|
||||
rc_ctrl[TEMP].rc.joystick[0] = ((sbus_buf[0] | (sbus_buf[1] << 8)) & 0x07ff) - RC_CH_VALUE_OFFSET; //!< Channel 0
|
||||
rc_ctrl[TEMP].rc.joystick[1] = (((sbus_buf[1] >> 3) | (sbus_buf[2] << 5)) & 0x07ff) - RC_CH_VALUE_OFFSET; //!< Channel 1
|
||||
rc_ctrl[TEMP].rc.joystick[2] = (((sbus_buf[2] >> 6) | (sbus_buf[3] << 2) | (sbus_buf[4] << 10)) & 0x07ff) - RC_CH_VALUE_OFFSET; //!< Channel 2
|
||||
rc_ctrl[TEMP].rc.joystick[3] = (((sbus_buf[4] >> 1) | (sbus_buf[5] << 7)) & 0x07ff) - RC_CH_VALUE_OFFSET; //!< Channel 3
|
||||
rc_ctrl[TEMP].rc.joystick[4] = (sbus_buf[16] | (sbus_buf[17] << 8)) - RC_CH_VALUE_OFFSET; // 左侧拨轮
|
||||
// 开关,0左1右
|
||||
rc_ctrl[TEMP].rc.s[0] = ((sbus_buf[5] >> 4) & 0x0003); //!< Switch left
|
||||
rc_ctrl[TEMP].rc.s[1] = ((sbus_buf[5] >> 4) & 0x000C) >> 2; //!< Switch right
|
||||
|
|
Loading…
Reference in New Issue