Skip to content

Commit

Permalink
post-pretest version
Browse files Browse the repository at this point in the history
  • Loading branch information
jia-xie committed Aug 2, 2024
1 parent ddaf8d4 commit 7ecdf93
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
14 changes: 10 additions & 4 deletions src/app/src/chassis_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ void Chassis_Task_Init()
g_right_foot_motor = MF_Motor_Init(motor_config);

MF_Motor_Broadcast_Init(1);
PID_Init(&g_pid_left_leg_length, 8500.0f, 0.0f, 350.0f, 50.0f, 0.0f, 0.0f);
PID_Init(&g_pid_right_leg_length, 8500.0f, 0.0f, 350.0f, 50.0f, 0.0f, 0.0f);
PID_Init(&g_pid_left_leg_length, 1000.0f, 0.0f, 300.0f, 400.0f, 0.0f, 0.0f);
PID_Init(&g_pid_right_leg_length, 1000.0f, 0.0f, 300.0f, 400.0f, 0.0f, 0.0f);

PID_Init(&g_pid_left_leg_angle, 15.0f, 0.0f, 5.75f, 10.0f, 0.0f, 0.0f);
PID_Init(&g_pid_right_leg_angle, 15.0f, 0.0f, 5.75f, 10.0f, 0.0f, 0.0f);
Expand All @@ -172,7 +172,7 @@ void Chassis_Task_Init()
PID_Init(&g_pid_follow_gimbal, 8.0f, 0.0f, 0.95f, 6.0f, 0.0f, 0.0f);
g_robot_state.chassis_height = CHASSIS_DEFAULT_HEIGHT;

PID_Init(&g_pid_roll_compensation, 0.1f, 0.0006f, 0.0f, 0.20f, 0.15f, 0.0f);
PID_Init(&g_pid_roll_compensation, 0.4f, 0.0000f, 0.0f, 0.20f, 0.15f, 0.0f);
xvEstimateKF_Init(&vaEstimateKF);
}

Expand Down Expand Up @@ -441,6 +441,12 @@ void _vmc_torq_calc()
PID_dt(&g_pid_yaw_angle, g_chassis.current_yaw - g_chassis.target_yaw, TASK_TIME);
g_u_left.T_A -= g_pid_yaw_angle.output;
g_u_right.T_A += g_pid_yaw_angle.output;

if (g_robot_state.spintop_mode)
{
g_u_left.T_A -= (0.1f*(-1.0f));
g_u_right.T_A += 0.3f;
}
}

void Chassis_Disable()
Expand Down Expand Up @@ -524,7 +530,7 @@ void _chassis_cmd()
// Spintop vs Follow Gimbal
if (g_robot_state.spintop_mode)
{
g_chassis.target_yaw_speed = g_chassis.target_yaw_speed * 0.9f + 0.1f * 6.0f;
g_chassis.target_yaw_speed = g_chassis.target_yaw_speed * 0.9f + 0.1f * -7.0f;
}
else if (g_robot_state.gimbal_switching_dir_pending == 1)
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/src/gimbal_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Gimbal_Task_Init()
};

Motor_Config_t pitch_motor_config = {
.can_bus = 1,
.can_bus = 2,
.speed_controller_id = 7,
.offset = 3235,
.use_external_feedback = 1,
Expand Down
18 changes: 9 additions & 9 deletions src/app/src/robot.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern DJI_Motor_Handle_t *g_yaw;
#define MAX_SPEED (1.2f)

Robot_State_t g_robot_state = {0, 0};
float g_chassis_height_arr[4] = {0.13f, 0.20f, 0.28f, 0.35f};
float g_chassis_height_arr[6] = {0.15f, 0.18f, 0.21f, 0.24f, 0.27f, 0.30f};
int8_t g_current_height_index = 0;
Key_Prev_t g_key_prev = {0};
extern Launch_Target_t g_launch_target;
Expand Down Expand Up @@ -186,7 +186,7 @@ void Robot_Cmd_Loop()
// this does not interfere with remote control
if (g_remote.controller.right_switch != UP)
{
// g_robot_state.chassis_height = g_robot_state.chassis_height * 0.99f + 0.01f * g_chassis_height_arr[g_current_height_index];
g_robot_state.chassis_height = g_robot_state.chassis_height * 0.99f + 0.01f * g_chassis_height_arr[g_current_height_index];
g_robot_state.spintop_mode = 0;
}
/* Chassis ends here */
Expand Down Expand Up @@ -245,11 +245,11 @@ void Robot_Cmd_Loop()
g_launch_target.single_launch_flag = 0;
g_launch_target.burst_launch_flag = 1;
}
// else if ((g_remote.controller.wheel > 50.0f) || (g_remote.mouse.left == 1) || (g_remote.mouse.right == 1))
// { // dial wheel backward burst fire
// g_launch_target.single_launch_flag = 0;
// g_launch_target.burst_launch_flag = 1;
// }
else if ((g_remote.mouse.left == 1) || (g_remote.mouse.right == 1))
{ // dial wheel backward burst fire
g_launch_target.single_launch_flag = 0;
g_launch_target.burst_launch_flag = 1;
}
else
{ // dial wheel mid stop fire
g_launch_target.single_launch_flag = 0;
Expand Down Expand Up @@ -302,13 +302,13 @@ void Robot_Cmd_Loop()
{
// g_robot_state.chassis_height = g_robot_state.chassis_height * 0.995f + 0.05f * 0.30f;
g_current_height_index++;
__MAX_LIMIT(g_current_height_index, 0, 3);
__MAX_LIMIT(g_current_height_index, 0, 5);
}
if (g_remote.keyboard.C == 1 && g_key_prev.prev_C == 0)
{
// g_robot_state.chassis_height = g_robot_state.chassis_height * 0.995f + 0.05f * 0.13f;
g_current_height_index--;
__MAX_LIMIT(g_current_height_index, 0, 3);
__MAX_LIMIT(g_current_height_index, 0, 5);
}
if (g_remote.controller.right_switch == MID && g_key_prev.prev_right_switch == UP)
{
Expand Down

0 comments on commit 7ecdf93

Please sign in to comment.