You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
#include "Copter.h" |
|
|
|
/* |
|
* Init and run calls for stabilize flight mode |
|
*/ |
|
|
|
// stabilize_run - runs the main stabilize controller |
|
// should be called at 100hz or more |
|
void Copter::ModeStabilize::run() |
|
{ |
|
float target_roll, target_pitch; |
|
float target_yaw_rate; |
|
|
|
// if not armed set throttle to zero and exit immediately |
|
if (!motors->armed() || ap.throttle_zero || !motors->get_interlock()) { |
|
zero_throttle_and_relax_ac(); |
|
return; |
|
} |
|
|
|
// clear landing flag |
|
set_land_complete(false); |
|
|
|
motors->set_desired_spool_state(AP_Motors::DESIRED_THROTTLE_UNLIMITED); |
|
|
|
// apply SIMPLE mode transform to pilot inputs |
|
update_simple_mode(); |
|
|
|
// convert pilot input to lean angles |
|
get_pilot_desired_lean_angles(target_roll, target_pitch, copter.aparm.angle_max, copter.aparm.angle_max); |
|
|
|
// get pilot's desired yaw rate |
|
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in()); |
|
|
|
// call attitude controller |
|
attitude_control->input_euler_angle_roll_pitch_euler_rate_yaw(target_roll, target_pitch, target_yaw_rate); |
|
|
|
// body-frame rate controller is run directly from 100hz loop |
|
|
|
// output pilot's throttle |
|
attitude_control->set_throttle_out(get_pilot_desired_throttle(), |
|
true, |
|
g.throttle_filt); |
|
}
|
|
|