From 34d8c75d3a891c0a01baf031d1970dd2c64567fe Mon Sep 17 00:00:00 2001 From: "ucart@co3050-12" <dawehr@iastate.edu> Date: Sat, 18 Feb 2017 21:20:45 -0600 Subject: [PATCH] Allowed values to be set before Gear switch. Re-enabled x/y controllers and made throttle manual for autonomous mode. --- quad/sw/modular_quad_pid/src/control_algorithm.c | 12 ++++++------ quad/sw/modular_quad_pid/src/initialize_components.c | 9 +++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/quad/sw/modular_quad_pid/src/control_algorithm.c b/quad/sw/modular_quad_pid/src/control_algorithm.c index 63ba75613..ee77a7623 100644 --- a/quad/sw/modular_quad_pid/src/control_algorithm.c +++ b/quad/sw/modular_quad_pid/src/control_algorithm.c @@ -184,13 +184,13 @@ parameter_struct->pid_controllers[PITCH_ID].current_point = sensor_struct->pitch_angle_filtered; parameter_struct->pid_controllers[PITCH_ID].setpoint = - /*(user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)? - (parameter_struct->pid_controllers[LOCAL_X_ID].pid_correction) + pitch_trim :*/ user_input_struct->pitch_angle_manual_setpoint; + (user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)? + (parameter_struct->pid_controllers[LOCAL_X_ID].pid_correction) + pitch_trim : user_input_struct->pitch_angle_manual_setpoint; parameter_struct->pid_controllers[ROLL_ID].current_point = sensor_struct->roll_angle_filtered; parameter_struct->pid_controllers[ROLL_ID].setpoint = - /*(user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)? - (parameter_struct->pid_controllers[LOCAL_Y_ID].pid_correction) + roll_trim :*/ user_input_struct->roll_angle_manual_setpoint; + (user_defined_struct->flight_mode == AUTO_FLIGHT_MODE)? + (parameter_struct->pid_controllers[LOCAL_Y_ID].pid_correction) + roll_trim : user_input_struct->roll_angle_manual_setpoint; //logging and PID computation @@ -239,8 +239,8 @@ if(user_defined_struct->flight_mode == AUTO_FLIGHT_MODE) { //THROTTLE - raw_actuator_struct->controller_corrected_motor_commands[THROTTLE] = - ((int)(parameter_struct->pid_controllers[ALT_ID].pid_correction)) + sensor_struct->trims.throttle; + //raw_actuator_struct->controller_corrected_motor_commands[THROTTLE] = + // ((int)(parameter_struct->pid_controllers[ALT_ID].pid_correction)) + sensor_struct->trims.throttle; //ROLL raw_actuator_struct->controller_corrected_motor_commands[ROLL] = diff --git a/quad/sw/modular_quad_pid/src/initialize_components.c b/quad/sw/modular_quad_pid/src/initialize_components.c index c548d26d2..0b693dea6 100644 --- a/quad/sw/modular_quad_pid/src/initialize_components.c +++ b/quad/sw/modular_quad_pid/src/initialize_components.c @@ -24,13 +24,10 @@ int protection_loops(modular_structs_t *structs) // wait until throttle is low and the gear switch is engaged (so you don't immediately break out of the main loop below) // also wait for the flight mode to be set to manual - while(rc_commands[THROTTLE] > 125000 || read_kill(rc_commands[GEAR]) || !read_flap(rc_commands[FLAP])) - read_rec_all(rc_commands); - - // wait until the ground station has connected to the quad and acknowledged that its ready to start - while (!structs->user_input_struct.receivedBeginUpdate) { + while(rc_commands[THROTTLE] > 125000 || read_kill(rc_commands[GEAR]) || !read_flap(rc_commands[FLAP]) || + !structs->user_input_struct.receivedBeginUpdate) { process_received(structs); - usleep(10000); + read_rec_all(rc_commands); } // let the pilot/observers know that the quad is now active -- GitLab