2015-06-04 00:13:34 -03:00
/*
additional arming checks for plane
*/
2017-01-09 03:56:56 -04:00
# include "AP_Arming.h"
2015-06-04 00:13:34 -03:00
# include "Plane.h"
2015-10-25 14:03:46 -03:00
const AP_Param : : GroupInfo AP_Arming_Plane : : var_info [ ] = {
2015-08-24 00:53:15 -03:00
// variables from parent vehicle
AP_NESTEDGROUPINFO ( AP_Arming , 0 ) ,
// @Param: RUDDER
// @DisplayName: Rudder Arming
2016-02-11 00:59:00 -04:00
// @Description: Control arm/disarm by rudder input. When enabled arming is done with right rudder, disarming with left rudder. Rudder arming only works in manual throttle modes with throttle at zero +- deadzone (RCx_DZ)
2015-08-24 00:53:15 -03:00
// @Values: 0:Disabled,1:ArmingOnly,2:ArmOrDisarm
// @User: Advanced
AP_GROUPINFO ( " RUDDER " , 3 , AP_Arming_Plane , rudder_arming_value , ARMING_RUDDER_ARMONLY ) ,
AP_GROUPEND
} ;
2016-08-15 00:37:28 -03:00
enum HomeState AP_Arming_Plane : : home_status ( ) const
{
return plane . home_is_set ;
}
2015-08-24 00:53:15 -03:00
2015-06-04 00:13:34 -03:00
/*
additional arming checks for plane
2016-11-05 20:23:32 -03:00
2015-06-04 00:13:34 -03:00
*/
bool AP_Arming_Plane : : pre_arm_checks ( bool report )
{
// call parent class checks
bool ret = AP_Arming : : pre_arm_checks ( report ) ;
2015-08-24 00:53:15 -03:00
// Check airspeed sensor
ret & = AP_Arming : : airspeed_checks ( report ) ;
2017-12-06 19:02:11 -04:00
if ( plane . g . fs_timeout_long < plane . g . fs_timeout_short & & plane . g . fs_action_short ! = FS_ACTION_SHORT_DISABLED ) {
2017-09-19 23:18:37 -03:00
if ( report ) {
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: FS_LONG_TIMEOUT < FS_SHORT_TIMEOUT " ) ;
}
ret = false ;
}
2016-06-23 09:40:13 -03:00
if ( plane . aparm . roll_limit_cd < 300 ) {
2015-06-04 00:13:34 -03:00
if ( report ) {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: LIM_ROLL_CD too small (%u) " , plane . aparm . roll_limit_cd ) ;
2015-06-04 00:13:34 -03:00
}
ret = false ;
}
if ( plane . aparm . pitch_limit_max_cd < 300 ) {
if ( report ) {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: LIM_PITCH_MAX too small (%u) " , plane . aparm . pitch_limit_max_cd ) ;
2015-06-04 00:13:34 -03:00
}
ret = false ;
}
if ( plane . aparm . pitch_limit_min_cd > - 300 ) {
if ( report ) {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: LIM_PITCH_MIN too large (%u) " , plane . aparm . pitch_limit_min_cd ) ;
2015-06-04 00:13:34 -03:00
}
ret = false ;
}
if ( plane . channel_throttle - > get_reverse ( ) & &
plane . g . throttle_fs_enabled & &
plane . g . throttle_fs_value <
ArduPlane: Fix up after refactoring RC_Channel class
Further to refactor of RC_Channel class which included
adding get_xx set_xx methods, change reads and writes to the public members
to calls to get and set functionsss
old public member(int16_t) get function -> int16_t set function (int16_t)
(expression where c is an object of type RC_Channel)
c.radio_in c.get_radio_in() c.set_radio_in(v)
c.control_in c.get_control_in() c.set_control_in(v)
c.servo_out c.get_servo_out() c.set_servo_out(v)
c.pwm_out c.get_pwm_out() // use existing
c.radio_out c.get_radio_out() c.set_radio_out(v)
c.radio_max c.get_radio_max() c.set_radio_max(v)
c.radio_min c.get_radio_min() c.set_radio_min(v)
c.radio_trim c.get_radio_trim() c.set_radio_trim(v);
c.min_max_configured() // return true if min and max are configured
Because data members of RC_Channels are now private and so cannot be written directly
some overloads are provided in the Plane classes to provide the old functionality
new overload Plane::stick_mix_channel(RC_Channel *channel)
which forwards to the previously existing
void stick_mix_channel(RC_Channel *channel, int16_t &servo_out);
new overload Plane::channel_output_mixer(Rc_Channel* , RC_Channel*)const
which forwards to
(uint8_t mixing_type, int16_t & chan1, int16_t & chan2)const;
Rename functions
RC_Channel_aux::set_radio_trim(Aux_servo_function_t function)
to RC_Channel_aux::set_trim_to_radio_in_for(Aux_servo_function_t function)
RC_Channel_aux::set_servo_out(Aux_servo_function_t function, int16_t value)
to RC_Channel_aux::set_servo_out_for(Aux_servo_function_t function, int16_t value)
Rationale:
RC_Channel is a complicated class, which combines
several functionalities dealing with stick inputs
in pwm and logical units, logical and actual actuator
outputs, unit conversion etc, etc
The intent of this PR is to clarify existing use of
the class. At the basic level it should now be possible
to grep all places where private variable is set by
searching for the set_xx function.
(The wider purpose is to provide a more generic and
logically simpler method of output mixing. This is a small step)
2016-05-08 05:33:02 -03:00
plane . channel_throttle - > get_radio_max ( ) ) {
2015-06-04 00:13:34 -03:00
if ( report ) {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: Invalid THR_FS_VALUE for rev throttle " ) ;
2015-06-04 00:13:34 -03:00
}
ret = false ;
}
2016-02-20 05:02:52 -04:00
if ( plane . quadplane . available ( ) & & plane . scheduler . get_loop_rate_hz ( ) < 100 ) {
if ( report ) {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: quadplane needs SCHED_LOOP_RATE > 100 " ) ;
2016-02-20 05:02:52 -04:00
}
ret = false ;
}
2016-02-21 12:06:43 -04:00
if ( plane . control_mode = = AUTO & & plane . mission . num_commands ( ) < = 1 ) {
if ( report ) {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: No mission loaded " ) ;
2016-02-21 12:06:43 -04:00
}
ret = false ;
}
2016-08-12 17:02:31 -03:00
// check adsb avoidance failsafe
if ( plane . failsafe . adsb ) {
if ( report ) {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: ADSB threat detected " ) ;
2016-08-12 17:02:31 -03:00
}
ret = false ;
}
2016-09-10 19:19:22 -03:00
# if HAVE_PX4_MIXER
2016-09-06 04:03:13 -03:00
if ( plane . last_mixer_crc = = - 1 ) {
if ( report ) {
2016-09-06 04:25:15 -03:00
// if you ever get this error, a reboot is recommended.
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: Mixer error " ) ;
2016-09-06 04:03:13 -03:00
}
ret = false ;
}
# endif // CONFIG_HAL_BOARD
2015-06-04 00:13:34 -03:00
return ret ;
}
2015-10-16 00:52:57 -03:00
bool AP_Arming_Plane : : ins_checks ( bool report )
{
// call parent class checks
if ( ! AP_Arming : : ins_checks ( report ) ) {
return false ;
}
// additional plane specific checks
if ( ( checks_to_perform & ARMING_CHECK_ALL ) | |
( checks_to_perform & ARMING_CHECK_INS ) ) {
if ( ! ahrs . healthy ( ) ) {
if ( report ) {
const char * reason = ahrs . prearm_failure_reason ( ) ;
if ( reason ) {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: %s " , reason ) ;
2015-10-16 00:52:57 -03:00
} else {
2017-07-09 00:47:39 -03:00
gcs ( ) . send_text ( MAV_SEVERITY_CRITICAL , " PreArm: AHRS not healthy " ) ;
2015-10-16 00:52:57 -03:00
}
}
return false ;
}
}
return true ;
}