自瞄初步测试完毕
This commit is contained in:
parent
e2f57ad306
commit
e78845b802
|
@ -118,7 +118,9 @@ static void RemoteControlSet() {
|
||||||
// 控制底盘和云台运行模式,云台待添加,云台是否始终使用IMU数据?
|
// 控制底盘和云台运行模式,云台待添加,云台是否始终使用IMU数据?
|
||||||
if (switch_is_down(rc_data[TEMP].rc.switch_right)) // 右侧开关状态[下],小陀螺
|
if (switch_is_down(rc_data[TEMP].rc.switch_right)) // 右侧开关状态[下],小陀螺
|
||||||
{
|
{
|
||||||
chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
|
// chassis_cmd_send.chassis_mode = CHASSIS_ROTATE;
|
||||||
|
// gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
|
||||||
|
chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW;
|
||||||
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
|
gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
|
||||||
} else if (switch_is_mid(rc_data[TEMP].rc.switch_right)) // 右侧开关状态[中],,底盘跟随云台
|
} else if (switch_is_mid(rc_data[TEMP].rc.switch_right)) // 右侧开关状态[中],,底盘跟随云台
|
||||||
{
|
{
|
||||||
|
@ -131,7 +133,7 @@ static void RemoteControlSet() {
|
||||||
// gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
|
// gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 云台参数,确定云台控制数据
|
// 云台参数,确定云台控制数据
|
||||||
if (switch_is_mid(rc_data[TEMP].rc.switch_left) ||
|
if (switch_is_mid(rc_data[TEMP].rc.switch_left) ||
|
||||||
(vision_recv_data->x == 0 && vision_recv_data->y == 0 && vision_recv_data->z == 0
|
(vision_recv_data->x == 0 && vision_recv_data->y == 0 && vision_recv_data->z == 0
|
||||||
&& vision_recv_data->vx == 0 && vision_recv_data->vy == 0 &&
|
&& vision_recv_data->vx == 0 && vision_recv_data->vy == 0 &&
|
||||||
|
@ -139,6 +141,7 @@ static void RemoteControlSet() {
|
||||||
{
|
{
|
||||||
// 待添加,视觉会发来和目标的误差,同样将其转化为total angle的增量进行控制
|
// 待添加,视觉会发来和目标的误差,同样将其转化为total angle的增量进行控制
|
||||||
// ...
|
// ...
|
||||||
|
aim_select.suggest_fire = 0;
|
||||||
gimbal_cmd_send.yaw -= 0.0025f * (float) rc_data[TEMP].rc.rocker_l_;
|
gimbal_cmd_send.yaw -= 0.0025f * (float) rc_data[TEMP].rc.rocker_l_;
|
||||||
gimbal_cmd_send.pitch -= 0.001f * (float) rc_data[TEMP].rc.rocker_l1;
|
gimbal_cmd_send.pitch -= 0.001f * (float) rc_data[TEMP].rc.rocker_l1;
|
||||||
|
|
||||||
|
@ -169,6 +172,8 @@ static void RemoteControlSet() {
|
||||||
|
|
||||||
auto_aim(&aim_select, &trajectory_cal, vision_recv_data);
|
auto_aim(&aim_select, &trajectory_cal, vision_recv_data);
|
||||||
|
|
||||||
|
VisionSetAim(aim_select.aim_point[0], aim_select.aim_point[1], aim_select.aim_point[2]);
|
||||||
|
|
||||||
gimbal_cmd_send.yaw = trajectory_cal.cmd_yaw * 180 / PI;
|
gimbal_cmd_send.yaw = trajectory_cal.cmd_yaw * 180 / PI;
|
||||||
|
|
||||||
gimbal_cmd_send.pitch = trajectory_cal.cmd_pitch * 180 / PI;
|
gimbal_cmd_send.pitch = trajectory_cal.cmd_pitch * 180 / PI;
|
||||||
|
@ -191,16 +196,29 @@ static void RemoteControlSet() {
|
||||||
; // 弹舱舵机控制,待添加servo_motor模块,开启
|
; // 弹舱舵机控制,待添加servo_motor模块,开启
|
||||||
else; // 弹舱舵机控制,待添加servo_motor模块,关闭
|
else; // 弹舱舵机控制,待添加servo_motor模块,关闭
|
||||||
|
|
||||||
|
|
||||||
// 摩擦轮控制,拨轮向上打为负,向下为正
|
// 摩擦轮控制,拨轮向上打为负,向下为正
|
||||||
if (rc_data[TEMP].rc.dial < -100) // 向上超过100,打开摩擦轮
|
if (rc_data[TEMP].rc.dial < -100) // 向上超过100,打开摩擦轮
|
||||||
shoot_cmd_send.friction_mode = FRICTION_ON;
|
shoot_cmd_send.friction_mode = FRICTION_ON;
|
||||||
else
|
else
|
||||||
shoot_cmd_send.friction_mode = FRICTION_OFF;
|
shoot_cmd_send.friction_mode = FRICTION_OFF;
|
||||||
|
|
||||||
// 拨弹控制,遥控器固定为一种拨弹模式,可自行选择
|
// 拨弹控制,遥控器固定为一种拨弹模式,可自行选择
|
||||||
if (rc_data[TEMP].rc.dial < -500)
|
if (rc_data[TEMP].rc.dial < -500 )//
|
||||||
shoot_cmd_send.load_mode = LOAD_BURSTFIRE;
|
shoot_cmd_send.load_mode = LOAD_BURSTFIRE;
|
||||||
else
|
else
|
||||||
shoot_cmd_send.load_mode = LOAD_STOP;
|
shoot_cmd_send.load_mode = LOAD_STOP;
|
||||||
|
|
||||||
|
// 视觉控制发射
|
||||||
|
if (aim_select.suggest_fire == 1) {
|
||||||
|
//shoot_cmd_send.friction_mode = FRICTION_ON;
|
||||||
|
//shoot_cmd_send.shoot_mode = SHOOT_ON;
|
||||||
|
shoot_cmd_send.load_mode = LOAD_BURSTFIRE;
|
||||||
|
} else {
|
||||||
|
//shoot_cmd_send.friction_mode = FRICTION_OFF;
|
||||||
|
shoot_cmd_send.load_mode = LOAD_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
// 射频控制,固定每秒1发,后续可以根据左侧拨轮的值大小切换射频,
|
// 射频控制,固定每秒1发,后续可以根据左侧拨轮的值大小切换射频,
|
||||||
shoot_cmd_send.shoot_rate = 8;
|
shoot_cmd_send.shoot_rate = 8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,8 +217,8 @@ void ShootTask()
|
||||||
// DJIMotorSetRef(friction_r, 0);
|
// DJIMotorSetRef(friction_r, 0);
|
||||||
// break;
|
// break;
|
||||||
//default: // 当前为了调试设定的默认值4000,因为还没有加入裁判系统无法读取弹速.
|
//default: // 当前为了调试设定的默认值4000,因为还没有加入裁判系统无法读取弹速.
|
||||||
DJIMotorSetRef(friction_l, 40000);
|
DJIMotorSetRef(friction_l, 30000);
|
||||||
DJIMotorSetRef(friction_r, 40000);
|
DJIMotorSetRef(friction_r, 30000);
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ void get_cmd_angle(Trajectory_Type_t *trajectory_cal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void auto_aim(Aim_Select_Type_t *aim_sel, Trajectory_Type_t *trajectory_cal, RecievePacket_t *receive_packet) {
|
void auto_aim(Aim_Select_Type_t *aim_sel, Trajectory_Type_t *trajectory_cal, RecievePacket_t *receive_packet) {
|
||||||
trajectory_cal->extra_delay_time = 0.025;//0.025
|
trajectory_cal->extra_delay_time = 0.035;//0.025
|
||||||
|
|
||||||
aim_sel->target_state.armor_type = receive_packet->id;
|
aim_sel->target_state.armor_type = receive_packet->id;
|
||||||
aim_sel->target_state.armor_num = receive_packet->armors_num;
|
aim_sel->target_state.armor_num = receive_packet->armors_num;
|
||||||
|
|
|
@ -177,8 +177,8 @@ void VisionSend()
|
||||||
static uint8_t send_buffer[24]={0};
|
static uint8_t send_buffer[24]={0};
|
||||||
|
|
||||||
send_data.header = 0x5A;
|
send_data.header = 0x5A;
|
||||||
//VisionSetFlag(1);
|
// VisionSetFlag(data->detect_color);
|
||||||
VisionSetAim(recv_data.x,recv_data.y,recv_data.z);
|
// VisionSetAim(data->aim_x,data->aim_y,data->aim_z);
|
||||||
send_data.checksum = crc_16(&send_data.header,sizeof(send_data)-2);
|
send_data.checksum = crc_16(&send_data.header,sizeof(send_data)-2);
|
||||||
|
|
||||||
memcpy(send_buffer,&send_data,sizeof(send_data));
|
memcpy(send_buffer,&send_data,sizeof(send_data));
|
||||||
|
|
Loading…
Reference in New Issue