2013-05-29 20:51:34 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2013-08-29 02:34:34 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-04-02 05:26:37 -03:00
|
|
|
/*
|
2012-08-21 23:19:52 -03:00
|
|
|
* AP_MotorsHeli.cpp - ArduCopter motors library
|
|
|
|
* Code by RandyMackay. DIYDrones.com
|
|
|
|
*
|
|
|
|
*/
|
2012-10-26 20:59:07 -03:00
|
|
|
#include <stdlib.h>
|
2015-08-11 03:28:44 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2012-04-02 05:26:37 -03:00
|
|
|
#include "AP_MotorsHeli.h"
|
2015-09-13 23:02:52 -03:00
|
|
|
#include <GCS_MAVLink/GCS.h>
|
2012-04-02 05:26:37 -03:00
|
|
|
|
2012-10-26 20:59:07 -03:00
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
|
2015-10-25 14:03:46 -03:00
|
|
|
const AP_Param::GroupInfo AP_MotorsHeli::var_info[] = {
|
2012-08-21 23:19:52 -03:00
|
|
|
|
2014-09-18 22:54:26 -03:00
|
|
|
// 1 was ROL_MAX which has been replaced by CYC_MAX
|
2012-08-21 23:19:52 -03:00
|
|
|
|
2014-09-18 22:54:26 -03:00
|
|
|
// 2 was PIT_MAX which has been replaced by CYC_MAX
|
2012-08-21 23:19:52 -03:00
|
|
|
|
|
|
|
// @Param: COL_MIN
|
|
|
|
// @DisplayName: Collective Pitch Minimum
|
2013-11-04 00:13:54 -04:00
|
|
|
// @Description: Lowest possible servo position for the swashplate
|
2012-08-21 23:19:52 -03:00
|
|
|
// @Range: 1000 2000
|
|
|
|
// @Units: PWM
|
|
|
|
// @Increment: 1
|
|
|
|
// @User: Standard
|
2015-07-22 10:46:53 -03:00
|
|
|
AP_GROUPINFO("COL_MIN", 3, AP_MotorsHeli, _collective_min, AP_MOTORS_HELI_COLLECTIVE_MIN),
|
2012-08-21 23:19:52 -03:00
|
|
|
|
|
|
|
// @Param: COL_MAX
|
|
|
|
// @DisplayName: Collective Pitch Maximum
|
2013-11-04 00:13:54 -04:00
|
|
|
// @Description: Highest possible servo position for the swashplate
|
2012-08-21 23:19:52 -03:00
|
|
|
// @Range: 1000 2000
|
|
|
|
// @Units: PWM
|
|
|
|
// @Increment: 1
|
|
|
|
// @User: Standard
|
2015-07-22 10:46:53 -03:00
|
|
|
AP_GROUPINFO("COL_MAX", 4, AP_MotorsHeli, _collective_max, AP_MOTORS_HELI_COLLECTIVE_MAX),
|
2012-08-21 23:19:52 -03:00
|
|
|
|
|
|
|
// @Param: COL_MID
|
|
|
|
// @DisplayName: Collective Pitch Mid-Point
|
2013-11-04 00:13:54 -04:00
|
|
|
// @Description: Swash servo position corresponding to zero collective pitch (or zero lift for Assymetrical blades)
|
2012-08-21 23:19:52 -03:00
|
|
|
// @Range: 1000 2000
|
|
|
|
// @Units: PWM
|
|
|
|
// @Increment: 1
|
|
|
|
// @User: Standard
|
2015-07-22 10:46:53 -03:00
|
|
|
AP_GROUPINFO("COL_MID", 5, AP_MotorsHeli, _collective_mid, AP_MOTORS_HELI_COLLECTIVE_MID),
|
2012-08-21 23:19:52 -03:00
|
|
|
|
|
|
|
// @Param: SV_MAN
|
|
|
|
// @DisplayName: Manual Servo Mode
|
2015-10-10 07:29:16 -03:00
|
|
|
// @Description: Manual servo override for swash set-up. Do not set this manually!
|
2015-10-13 14:39:58 -03:00
|
|
|
// @Values: 0:Disabled,1:Passthrough,2:Max collective,3:Mid collective,4:Min collective
|
2012-08-21 23:19:52 -03:00
|
|
|
// @User: Standard
|
2015-10-14 15:57:51 -03:00
|
|
|
AP_GROUPINFO("SV_MAN", 6, AP_MotorsHeli, _servo_mode, SERVO_CONTROL_MODE_AUTOMATED),
|
2012-08-21 23:19:52 -03:00
|
|
|
|
|
|
|
// @Param: GOV_SETPOINT
|
|
|
|
// @DisplayName: External Motor Governor Setpoint
|
2013-11-04 00:13:54 -04:00
|
|
|
// @Description: PWM passed to the external motor governor when external governor is enabled
|
2013-11-07 03:07:53 -04:00
|
|
|
// @Range: 0 1000
|
2012-08-21 23:19:52 -03:00
|
|
|
// @Units: PWM
|
|
|
|
// @Increment: 10
|
|
|
|
// @User: Standard
|
2015-08-07 16:50:15 -03:00
|
|
|
AP_GROUPINFO("RSC_SETPOINT", 7, AP_MotorsHeli, _rsc_setpoint, AP_MOTORS_HELI_RSC_SETPOINT),
|
2012-08-21 23:19:52 -03:00
|
|
|
|
|
|
|
// @Param: RSC_MODE
|
|
|
|
// @DisplayName: Rotor Speed Control Mode
|
2015-08-11 21:20:28 -03:00
|
|
|
// @Description: Determines the method of rotor speed control
|
|
|
|
// @Values: 1:Ch8 Input, 2:SetPoint, 3:Throttle Curve
|
2012-08-21 23:19:52 -03:00
|
|
|
// @User: Standard
|
2015-08-28 03:23:26 -03:00
|
|
|
AP_GROUPINFO("RSC_MODE", 8, AP_MotorsHeli, _rsc_mode, (int8_t)ROTOR_CONTROL_MODE_SPEED_PASSTHROUGH),
|
2012-08-21 23:19:52 -03:00
|
|
|
|
2013-11-06 08:39:10 -04:00
|
|
|
// @Param: LAND_COL_MIN
|
|
|
|
// @DisplayName: Landing Collective Minimum
|
|
|
|
// @Description: Minimum collective position while landed or landing
|
|
|
|
// @Range: 0 500
|
|
|
|
// @Units: pwm
|
|
|
|
// @Increment: 1
|
|
|
|
// @User: Standard
|
2015-08-07 16:50:15 -03:00
|
|
|
AP_GROUPINFO("LAND_COL_MIN", 9, AP_MotorsHeli, _land_collective_min, AP_MOTORS_HELI_LAND_COLLECTIVE_MIN),
|
2013-11-06 08:39:10 -04:00
|
|
|
|
2013-11-07 03:07:53 -04:00
|
|
|
// @Param: RSC_RAMP_TIME
|
|
|
|
// @DisplayName: RSC Ramp Time
|
2013-11-09 00:38:33 -04:00
|
|
|
// @Description: Time in seconds for the output to the main rotor's ESC to reach full speed
|
2013-11-07 03:07:53 -04:00
|
|
|
// @Range: 0 60
|
|
|
|
// @Units: Seconds
|
|
|
|
// @User: Standard
|
2015-08-07 16:50:15 -03:00
|
|
|
AP_GROUPINFO("RSC_RAMP_TIME", 10, AP_MotorsHeli, _rsc_ramp_time, AP_MOTORS_HELI_RSC_RAMP_TIME),
|
2013-11-07 03:07:53 -04:00
|
|
|
|
2013-11-09 00:38:33 -04:00
|
|
|
// @Param: RSC_RUNUP_TIME
|
|
|
|
// @DisplayName: RSC Runup Time
|
|
|
|
// @Description: Time in seconds for the main rotor to reach full speed. Must be longer than RSC_RAMP_TIME
|
|
|
|
// @Range: 0 60
|
|
|
|
// @Units: Seconds
|
|
|
|
// @User: Standard
|
2015-08-07 16:50:15 -03:00
|
|
|
AP_GROUPINFO("RSC_RUNUP_TIME", 11, AP_MotorsHeli, _rsc_runup_time, AP_MOTORS_HELI_RSC_RUNUP_TIME),
|
2013-11-07 03:07:53 -04:00
|
|
|
|
2015-06-18 20:38:37 -03:00
|
|
|
// @Param: RSC_CRITICAL
|
|
|
|
// @DisplayName: Critical Rotor Speed
|
|
|
|
// @Description: Rotor speed below which flight is not possible
|
2015-08-06 05:17:09 -03:00
|
|
|
// @Range: 0 1000
|
2015-06-18 20:38:37 -03:00
|
|
|
// @Increment: 10
|
|
|
|
// @User: Standard
|
2015-08-07 16:50:15 -03:00
|
|
|
AP_GROUPINFO("RSC_CRITICAL", 12, AP_MotorsHeli, _rsc_critical, AP_MOTORS_HELI_RSC_CRITICAL),
|
2015-05-25 08:23:15 -03:00
|
|
|
|
2015-08-07 20:58:49 -03:00
|
|
|
// @Param: RSC_IDLE
|
|
|
|
// @DisplayName: Rotor Speed Output at Idle
|
|
|
|
// @Description: Rotor speed output while armed but rotor control speed is not engaged
|
|
|
|
// @Range: 0 500
|
|
|
|
// @Increment: 10
|
|
|
|
// @User: Standard
|
2015-08-11 21:20:28 -03:00
|
|
|
AP_GROUPINFO("RSC_IDLE", 13, AP_MotorsHeli, _rsc_idle_output, AP_MOTORS_HELI_RSC_IDLE_DEFAULT),
|
|
|
|
|
|
|
|
// @Param: RSC_POWER_LOW
|
|
|
|
// @DisplayName: Throttle Servo Low Power Position
|
|
|
|
// @Description: Throttle output at zero collective pitch.
|
|
|
|
// @Range: 0 1000
|
|
|
|
// @Increment: 10
|
|
|
|
// @User: Standard
|
|
|
|
AP_GROUPINFO("RSC_POWER_LOW", 14, AP_MotorsHeli, _rsc_power_low, AP_MOTORS_HELI_RSC_POWER_LOW_DEFAULT),
|
|
|
|
|
|
|
|
// @Param: RSC_POWER_HIGH
|
|
|
|
// @DisplayName: Throttle Servo High Power Position
|
|
|
|
// @Description: Throttle output at max collective pitch.
|
|
|
|
// @Range: 0 1000
|
|
|
|
// @Increment: 10
|
|
|
|
// @User: Standard
|
|
|
|
AP_GROUPINFO("RSC_POWER_HIGH", 15, AP_MotorsHeli, _rsc_power_high, AP_MOTORS_HELI_RSC_POWER_HIGH_DEFAULT),
|
2015-08-07 20:58:49 -03:00
|
|
|
|
2014-09-18 22:54:26 -03:00
|
|
|
// @Param: CYC_MAX
|
|
|
|
// @DisplayName: Cyclic Pitch Angle Max
|
|
|
|
// @Description: Maximum pitch angle of the swash plate
|
|
|
|
// @Range: 0 18000
|
|
|
|
// @Units: Centi-Degrees
|
|
|
|
// @Increment: 100
|
|
|
|
// @User: Advanced
|
|
|
|
AP_GROUPINFO("CYC_MAX", 16, AP_MotorsHeli, _cyclic_max, AP_MOTORS_HELI_SWASH_CYCLIC_MAX),
|
|
|
|
|
2015-10-21 20:47:24 -03:00
|
|
|
// @Param: SV_TEST
|
|
|
|
// @DisplayName: Boot-up Servo Test Cycles
|
|
|
|
// @Description: Number of cycles to run servo test on boot-up
|
|
|
|
// @Range: 0 10
|
|
|
|
// @Increment: 1
|
|
|
|
// @User: Standard
|
|
|
|
AP_GROUPINFO("SV_TEST", 17, AP_MotorsHeli, _servo_test, 0),
|
|
|
|
|
2012-04-02 05:26:37 -03:00
|
|
|
AP_GROUPEND
|
|
|
|
};
|
|
|
|
|
2013-11-04 07:53:27 -04:00
|
|
|
//
|
|
|
|
// public methods
|
|
|
|
//
|
|
|
|
|
2012-04-02 05:26:37 -03:00
|
|
|
// init
|
|
|
|
void AP_MotorsHeli::Init()
|
|
|
|
{
|
2012-08-21 23:19:52 -03:00
|
|
|
// set update rate
|
|
|
|
set_update_rate(_speed_hz);
|
2013-11-04 07:53:27 -04:00
|
|
|
|
2015-10-21 20:47:24 -03:00
|
|
|
// load boot-up servo test cycles into counter to be consumed
|
|
|
|
_servo_test_cycle_counter = _servo_test;
|
|
|
|
|
2015-08-12 12:41:40 -03:00
|
|
|
// ensure inputs are not passed through to servos on start-up
|
2015-10-14 15:57:51 -03:00
|
|
|
_servo_mode = SERVO_CONTROL_MODE_AUTOMATED;
|
2013-11-04 07:53:27 -04:00
|
|
|
|
2015-08-12 14:22:39 -03:00
|
|
|
// initialise Servo/PWM ranges and endpoints
|
2015-08-12 12:41:40 -03:00
|
|
|
init_outputs();
|
|
|
|
|
|
|
|
// calculate all scalars
|
|
|
|
calculate_scalars();
|
2012-04-02 05:26:37 -03:00
|
|
|
}
|
|
|
|
|
2015-08-12 14:22:39 -03:00
|
|
|
// output_min - sets servos to neutral point with motors stopped
|
|
|
|
void AP_MotorsHeli::output_min()
|
|
|
|
{
|
|
|
|
// move swash to mid
|
|
|
|
move_actuators(0,0,500,0);
|
|
|
|
|
|
|
|
update_motor_control(ROTOR_CONTROL_STOP);
|
|
|
|
|
|
|
|
// override limits flags
|
|
|
|
limit.roll_pitch = true;
|
|
|
|
limit.yaw = true;
|
|
|
|
limit.throttle_lower = true;
|
|
|
|
limit.throttle_upper = false;
|
|
|
|
}
|
|
|
|
|
2015-05-21 15:33:18 -03:00
|
|
|
// output - sends commands to the servos
|
|
|
|
void AP_MotorsHeli::output()
|
|
|
|
{
|
|
|
|
// update throttle filter
|
|
|
|
update_throttle_filter();
|
|
|
|
|
|
|
|
if (_flags.armed) {
|
2015-11-14 18:14:03 -04:00
|
|
|
calculate_armed_scalars();
|
2015-05-21 15:33:18 -03:00
|
|
|
if (!_flags.interlock) {
|
|
|
|
output_armed_zero_throttle();
|
|
|
|
} else if (_flags.stabilizing) {
|
|
|
|
output_armed_stabilizing();
|
|
|
|
} else {
|
|
|
|
output_armed_not_stabilizing();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
output_disarmed();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-08-12 14:22:39 -03:00
|
|
|
// sends commands to the motors
|
|
|
|
void AP_MotorsHeli::output_armed_stabilizing()
|
|
|
|
{
|
|
|
|
// if manual override active after arming, deactivate it and reinitialize servos
|
2015-10-14 15:57:51 -03:00
|
|
|
if (_servo_mode != SERVO_CONTROL_MODE_AUTOMATED) {
|
2015-08-12 14:22:39 -03:00
|
|
|
reset_flight_controls();
|
|
|
|
}
|
|
|
|
|
|
|
|
move_actuators(_roll_control_input, _pitch_control_input, _throttle_control_input, _yaw_control_input);
|
|
|
|
|
|
|
|
update_motor_control(ROTOR_CONTROL_ACTIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AP_MotorsHeli::output_armed_not_stabilizing()
|
|
|
|
{
|
|
|
|
// if manual override active after arming, deactivate it and reinitialize servos
|
2015-10-14 15:57:51 -03:00
|
|
|
if (_servo_mode != SERVO_CONTROL_MODE_AUTOMATED) {
|
2015-08-12 14:22:39 -03:00
|
|
|
reset_flight_controls();
|
|
|
|
}
|
|
|
|
|
|
|
|
// helicopters always run stabilizing flight controls
|
|
|
|
move_actuators(_roll_control_input, _pitch_control_input, _throttle_control_input, _yaw_control_input);
|
|
|
|
|
|
|
|
update_motor_control(ROTOR_CONTROL_ACTIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// output_armed_zero_throttle - sends commands to the motors
|
|
|
|
void AP_MotorsHeli::output_armed_zero_throttle()
|
|
|
|
{
|
|
|
|
// if manual override active after arming, deactivate it and reinitialize servos
|
2015-10-14 15:57:51 -03:00
|
|
|
if (_servo_mode != SERVO_CONTROL_MODE_AUTOMATED) {
|
2015-08-12 14:22:39 -03:00
|
|
|
reset_flight_controls();
|
|
|
|
}
|
|
|
|
|
|
|
|
move_actuators(_roll_control_input, _pitch_control_input, _throttle_control_input, _yaw_control_input);
|
|
|
|
|
|
|
|
update_motor_control(ROTOR_CONTROL_IDLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// output_disarmed - sends commands to the motors
|
|
|
|
void AP_MotorsHeli::output_disarmed()
|
|
|
|
{
|
2015-10-21 20:47:24 -03:00
|
|
|
if (_servo_test_cycle_counter > 0){
|
|
|
|
// perform boot-up servo test cycle if enabled
|
|
|
|
servo_test();
|
|
|
|
} else {
|
|
|
|
// manual override (i.e. when setting up swash)
|
|
|
|
switch (_servo_mode) {
|
|
|
|
case SERVO_CONTROL_MODE_MANUAL_PASSTHROUGH:
|
|
|
|
// pass pilot commands straight through to swash
|
|
|
|
_roll_control_input = _roll_radio_passthrough;
|
|
|
|
_pitch_control_input = _pitch_radio_passthrough;
|
|
|
|
_throttle_control_input = _throttle_radio_passthrough;
|
|
|
|
_yaw_control_input = _yaw_radio_passthrough;
|
|
|
|
break;
|
|
|
|
case SERVO_CONTROL_MODE_MANUAL_CENTER:
|
|
|
|
// fixate mid collective
|
|
|
|
_roll_control_input = 0;
|
|
|
|
_pitch_control_input = 0;
|
|
|
|
_throttle_control_input = _collective_mid_pwm;
|
|
|
|
_yaw_control_input = 0;
|
|
|
|
break;
|
|
|
|
case SERVO_CONTROL_MODE_MANUAL_MAX:
|
|
|
|
// fixate max collective
|
|
|
|
_roll_control_input = 0;
|
|
|
|
_pitch_control_input = 0;
|
|
|
|
_throttle_control_input = 1000;
|
|
|
|
_yaw_control_input = 4500;
|
|
|
|
break;
|
|
|
|
case SERVO_CONTROL_MODE_MANUAL_MIN:
|
|
|
|
// fixate min collective
|
|
|
|
_roll_control_input = 0;
|
|
|
|
_pitch_control_input = 0;
|
|
|
|
_throttle_control_input = 0;
|
|
|
|
_yaw_control_input = -4500;
|
|
|
|
break;
|
|
|
|
case SERVO_CONTROL_MODE_MANUAL_OSCILLATE:
|
|
|
|
// use servo_test function from child classes
|
|
|
|
servo_test();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// no manual override
|
|
|
|
break;
|
|
|
|
}
|
2015-08-12 14:22:39 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// ensure swash servo endpoints haven't been moved
|
|
|
|
init_outputs();
|
|
|
|
|
|
|
|
// continuously recalculate scalars to allow setup
|
|
|
|
calculate_scalars();
|
|
|
|
|
|
|
|
// helicopters always run stabilizing flight controls
|
|
|
|
move_actuators(_roll_control_input, _pitch_control_input, _throttle_control_input, _yaw_control_input);
|
|
|
|
|
|
|
|
update_motor_control(ROTOR_CONTROL_STOP);
|
|
|
|
}
|
|
|
|
|
2015-07-08 14:14:49 -03:00
|
|
|
// parameter_check - check if helicopter specific parameters are sensible
|
2015-09-13 23:02:52 -03:00
|
|
|
bool AP_MotorsHeli::parameter_check(bool display_msg) const
|
2015-07-08 14:14:49 -03:00
|
|
|
{
|
|
|
|
// returns false if _rsc_setpoint is not higher than _rsc_critical as this would not allow rotor_runup_complete to ever return true
|
|
|
|
if (_rsc_critical >= _rsc_setpoint) {
|
2015-09-13 23:02:52 -03:00
|
|
|
if (display_msg) {
|
2015-10-24 18:45:41 -03:00
|
|
|
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_CRITICAL, "PreArm: H_RSC_CRITICAL too large");
|
2015-09-13 23:02:52 -03:00
|
|
|
}
|
2015-07-08 14:14:49 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-10 18:29:17 -03:00
|
|
|
// returns false if RSC Mode is not set to a valid control mode
|
2015-08-28 03:23:26 -03:00
|
|
|
if (_rsc_mode <= (int8_t)ROTOR_CONTROL_MODE_DISABLED || _rsc_mode > (int8_t)ROTOR_CONTROL_MODE_CLOSED_LOOP_POWER_OUTPUT) {
|
2015-09-13 23:02:52 -03:00
|
|
|
if (display_msg) {
|
2015-10-24 18:45:41 -03:00
|
|
|
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_CRITICAL, "PreArm: H_RSC_MODE invalid");
|
2015-09-13 23:02:52 -03:00
|
|
|
}
|
2015-08-10 18:29:17 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns false if RSC Runup Time is less than Ramp time as this could cause undesired behaviour of rotor speed estimate
|
|
|
|
if (_rsc_runup_time <= _rsc_ramp_time){
|
2015-09-13 23:02:52 -03:00
|
|
|
if (display_msg) {
|
2015-10-24 18:45:41 -03:00
|
|
|
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_CRITICAL, "PreArm: H_RUNUP_TIME too small");
|
2015-09-13 23:02:52 -03:00
|
|
|
}
|
2015-08-10 18:29:17 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-11 21:20:28 -03:00
|
|
|
// returns false if idle output is higher than critical rotor speed as this could block runup_complete from going false
|
|
|
|
if ( _rsc_idle_output >= _rsc_critical){
|
2015-09-13 23:02:52 -03:00
|
|
|
if (display_msg) {
|
2015-10-24 18:45:41 -03:00
|
|
|
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_CRITICAL, "PreArm: H_RSC_IDLE too large");
|
2015-09-13 23:02:52 -03:00
|
|
|
}
|
2015-08-10 18:29:17 -03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-08 14:14:49 -03:00
|
|
|
// all other cases parameters are OK
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-22 05:14:05 -03:00
|
|
|
// reset_swash_servo
|
|
|
|
void AP_MotorsHeli::reset_swash_servo(RC_Channel& servo)
|
|
|
|
{
|
2015-08-11 21:46:20 -03:00
|
|
|
servo.set_range(0, 1000);
|
2015-08-12 12:41:40 -03:00
|
|
|
|
|
|
|
// swash servos always use full endpoints as restricting them would lead to scaling errors
|
2015-07-22 05:14:05 -03:00
|
|
|
servo.radio_min = 1000;
|
|
|
|
servo.radio_max = 2000;
|
|
|
|
}
|
|
|
|
|
2015-05-21 15:19:25 -03:00
|
|
|
// update the throttle input filter
|
|
|
|
void AP_MotorsHeli::update_throttle_filter()
|
|
|
|
{
|
|
|
|
_throttle_filter.apply(_throttle_in, 1.0f/_loop_rate);
|
|
|
|
|
2015-06-15 23:05:04 -03:00
|
|
|
// constrain throttle signal to 0-1000
|
|
|
|
_throttle_control_input = constrain_float(_throttle_filter.get(),0.0f,1000.0f);
|
2015-05-14 22:00:46 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// set_radio_passthrough used to pass radio inputs directly to outputs
|
|
|
|
void AP_MotorsHeli::set_radio_passthrough(int16_t radio_roll_input, int16_t radio_pitch_input, int16_t radio_throttle_input, int16_t radio_yaw_input)
|
|
|
|
{
|
|
|
|
_roll_radio_passthrough = radio_roll_input;
|
|
|
|
_pitch_radio_passthrough = radio_pitch_input;
|
|
|
|
_throttle_radio_passthrough = radio_throttle_input;
|
|
|
|
_yaw_radio_passthrough = radio_yaw_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
// reset_radio_passthrough used to reset all radio inputs to center
|
|
|
|
void AP_MotorsHeli::reset_radio_passthrough()
|
|
|
|
{
|
|
|
|
_roll_radio_passthrough = 0;
|
|
|
|
_pitch_radio_passthrough = 0;
|
|
|
|
_throttle_radio_passthrough = 500;
|
|
|
|
_yaw_radio_passthrough = 0;
|
2015-05-21 15:19:25 -03:00
|
|
|
}
|
2015-08-12 14:22:39 -03:00
|
|
|
|
|
|
|
// reset_flight_controls - resets all controls and scalars to flight status
|
|
|
|
void AP_MotorsHeli::reset_flight_controls()
|
|
|
|
{
|
|
|
|
reset_radio_passthrough();
|
2015-10-14 15:57:51 -03:00
|
|
|
_servo_mode = SERVO_CONTROL_MODE_AUTOMATED;
|
2015-08-12 14:22:39 -03:00
|
|
|
init_outputs();
|
|
|
|
calculate_scalars();
|
|
|
|
}
|