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.
101 lines
4.0 KiB
101 lines
4.0 KiB
10 years ago
|
#include "Copter.h"
|
||
|
|
||
11 years ago
|
#if FRAME_CONFIG == HELI_FRAME
|
||
|
/*
|
||
9 years ago
|
* Init and run calls for acro flight mode for trad heli
|
||
11 years ago
|
*/
|
||
|
|
||
|
// heli_acro_init - initialise acro controller
|
||
7 years ago
|
bool Copter::ModeAcro_Heli::init(bool ignore_checks)
|
||
11 years ago
|
{
|
||
11 years ago
|
// if heli is equipped with a flybar, then tell the attitude controller to pass through controls directly to servos
|
||
8 years ago
|
attitude_control->use_flybar_passthrough(motors->has_flybar(), motors->supports_yaw_passthrough());
|
||
11 years ago
|
|
||
8 years ago
|
motors->set_acro_tail(true);
|
||
10 years ago
|
|
||
9 years ago
|
// set stab collective false to use full collective pitch range
|
||
9 years ago
|
_copter.input_manager.set_use_stab_col(false);
|
||
9 years ago
|
|
||
11 years ago
|
// always successfully enter acro
|
||
11 years ago
|
return true;
|
||
|
}
|
||
|
|
||
|
// heli_acro_run - runs the acro controller
|
||
|
// should be called at 100hz or more
|
||
7 years ago
|
void Copter::ModeAcro_Heli::run()
|
||
11 years ago
|
{
|
||
11 years ago
|
float target_roll, target_pitch, target_yaw;
|
||
9 years ago
|
float pilot_throttle_scaled;
|
||
11 years ago
|
|
||
|
// Tradheli should not reset roll, pitch, yaw targets when motors are not runup, because
|
||
|
// we may be in autorotation flight. These should be reset only when transitioning from disarmed
|
||
|
// to armed, because the pilot will have placed the helicopter down on the landing pad. This is so
|
||
|
// that the servos move in a realistic fashion while disarmed for operational checks.
|
||
|
// Also, unlike multicopters we do not set throttle (i.e. collective pitch) to zero so the swash servos move
|
||
|
|
||
8 years ago
|
if(!motors->armed()) {
|
||
9 years ago
|
_copter.heli_flags.init_targets_on_arming=true;
|
||
7 years ago
|
attitude_control->set_attitude_target_to_current_attitude();
|
||
|
attitude_control->reset_rate_controller_I_terms();
|
||
11 years ago
|
}
|
||
10 years ago
|
|
||
9 years ago
|
if(motors->armed() && _copter.heli_flags.init_targets_on_arming) {
|
||
7 years ago
|
attitude_control->set_attitude_target_to_current_attitude();
|
||
|
attitude_control->reset_rate_controller_I_terms();
|
||
|
if (motors->get_interlock()) {
|
||
9 years ago
|
_copter.heli_flags.init_targets_on_arming=false;
|
||
10 years ago
|
}
|
||
11 years ago
|
}
|
||
|
|
||
9 years ago
|
// clear landing flag above zero throttle
|
||
8 years ago
|
if (motors->armed() && motors->get_interlock() && motors->rotor_runup_complete() && !ap.throttle_zero) {
|
||
9 years ago
|
set_land_complete(false);
|
||
|
}
|
||
|
|
||
8 years ago
|
if (!motors->has_flybar()){
|
||
11 years ago
|
// convert the input to the desired body frame rate
|
||
9 years ago
|
get_pilot_desired_angle_rates(channel_roll->get_control_in(), channel_pitch->get_control_in(), channel_yaw->get_control_in(), target_roll, target_pitch, target_yaw);
|
||
9 years ago
|
|
||
8 years ago
|
if (motors->supports_yaw_passthrough()) {
|
||
9 years ago
|
// if the tail on a flybar heli has an external gyro then
|
||
|
// also use no deadzone for the yaw control and
|
||
|
// pass-through the input direct to output.
|
||
8 years ago
|
target_yaw = channel_yaw->get_control_in_zero_dz();
|
||
9 years ago
|
}
|
||
|
|
||
11 years ago
|
// run attitude controller
|
||
8 years ago
|
attitude_control->input_rate_bf_roll_pitch_yaw(target_roll, target_pitch, target_yaw);
|
||
11 years ago
|
}else{
|
||
10 years ago
|
/*
|
||
|
for fly-bar passthrough use control_in values with no
|
||
|
deadzone. This gives true pass-through.
|
||
|
*/
|
||
8 years ago
|
float roll_in = channel_roll->get_control_in_zero_dz();
|
||
|
float pitch_in = channel_pitch->get_control_in_zero_dz();
|
||
10 years ago
|
float yaw_in;
|
||
|
|
||
8 years ago
|
if (motors->supports_yaw_passthrough()) {
|
||
10 years ago
|
// if the tail on a flybar heli has an external gyro then
|
||
|
// also use no deadzone for the yaw control and
|
||
|
// pass-through the input direct to output.
|
||
8 years ago
|
yaw_in = channel_yaw->get_control_in_zero_dz();
|
||
10 years ago
|
} else {
|
||
|
// if there is no external gyro then run the usual
|
||
|
// ACRO_YAW_P gain on the input control, including
|
||
|
// deadzone
|
||
9 years ago
|
yaw_in = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
|
||
10 years ago
|
}
|
||
|
|
||
11 years ago
|
// run attitude controller
|
||
8 years ago
|
attitude_control->passthrough_bf_roll_pitch_rate_yaw(roll_in, pitch_in, yaw_in);
|
||
11 years ago
|
}
|
||
11 years ago
|
|
||
9 years ago
|
// get pilot's desired throttle
|
||
9 years ago
|
pilot_throttle_scaled = _copter.input_manager.get_pilot_desired_collective(channel_throttle->get_control_in());
|
||
9 years ago
|
|
||
11 years ago
|
// output pilot's throttle without angle boost
|
||
8 years ago
|
attitude_control->set_throttle_out(pilot_throttle_scaled, false, g.throttle_filt);
|
||
11 years ago
|
}
|
||
|
|
||
|
#endif //HELI_FRAME
|