2019-02-19 17:29:05 -04:00
|
|
|
#include "GCS_Copter.h"
|
|
|
|
|
|
|
|
#include "Copter.h"
|
|
|
|
|
2019-03-01 02:08:33 -04:00
|
|
|
const char* GCS_Copter::frame_string() const
|
|
|
|
{
|
|
|
|
return copter.get_frame_string();
|
|
|
|
}
|
|
|
|
|
2019-03-01 19:25:38 -04:00
|
|
|
bool GCS_Copter::simple_input_active() const
|
|
|
|
{
|
|
|
|
return copter.ap.simple_mode == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GCS_Copter::supersimple_input_active() const
|
|
|
|
{
|
|
|
|
return copter.ap.simple_mode == 2;
|
|
|
|
}
|
|
|
|
|
2019-02-19 19:01:55 -04:00
|
|
|
void GCS_Copter::update_vehicle_sensor_status_flags(void)
|
2019-02-19 17:29:05 -04:00
|
|
|
{
|
2019-02-19 19:01:55 -04:00
|
|
|
control_sensors_present |=
|
|
|
|
MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL |
|
|
|
|
MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION |
|
|
|
|
MAV_SYS_STATUS_SENSOR_YAW_POSITION;
|
|
|
|
|
|
|
|
control_sensors_enabled |=
|
|
|
|
MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL |
|
|
|
|
MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION |
|
|
|
|
MAV_SYS_STATUS_SENSOR_YAW_POSITION;
|
|
|
|
|
|
|
|
control_sensors_health |=
|
|
|
|
MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL |
|
|
|
|
MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION |
|
|
|
|
MAV_SYS_STATUS_SENSOR_YAW_POSITION;
|
2019-02-19 17:29:05 -04:00
|
|
|
|
|
|
|
#if OPTFLOW == ENABLED
|
|
|
|
const OpticalFlow *optflow = AP::opticalflow();
|
|
|
|
if (optflow && optflow->enabled()) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW;
|
2019-02-19 19:01:55 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if PRECISION_LANDING == ENABLED
|
|
|
|
if (copter.precland.enabled()) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
2019-02-19 19:01:55 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if VISUAL_ODOMETRY_ENABLED == ENABLED
|
|
|
|
const AP_VisualOdom *visual_odom = AP::visualodom();
|
|
|
|
if (visual_odom && visual_odom->enabled()) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
2019-02-19 19:01:55 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
const Copter::ap_t &ap = copter.ap;
|
|
|
|
|
|
|
|
if (ap.rc_receiver_present) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_RC_RECEIVER;
|
2019-02-19 19:01:55 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_RC_RECEIVER;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#if PROXIMITY_ENABLED == ENABLED
|
|
|
|
if (copter.g2.proximity.sensor_present()) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_PROXIMITY;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if RANGEFINDER_ENABLED == ENABLED
|
|
|
|
const RangeFinder *rangefinder = RangeFinder::get_singleton();
|
|
|
|
if (rangefinder && rangefinder->has_orientation(ROTATION_PITCH_270)) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-19 19:01:55 -04:00
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL;
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL;
|
2019-02-19 17:29:05 -04:00
|
|
|
|
|
|
|
switch (copter.control_mode) {
|
2019-09-07 20:33:56 -03:00
|
|
|
case Mode::Number::AUTO:
|
|
|
|
case Mode::Number::AVOID_ADSB:
|
|
|
|
case Mode::Number::GUIDED:
|
|
|
|
case Mode::Number::LOITER:
|
|
|
|
case Mode::Number::RTL:
|
|
|
|
case Mode::Number::CIRCLE:
|
|
|
|
case Mode::Number::LAND:
|
|
|
|
case Mode::Number::POSHOLD:
|
|
|
|
case Mode::Number::BRAKE:
|
|
|
|
case Mode::Number::THROW:
|
|
|
|
case Mode::Number::SMART_RTL:
|
2019-02-19 17:29:05 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL;
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL;
|
|
|
|
break;
|
2019-09-07 20:33:56 -03:00
|
|
|
case Mode::Number::ALT_HOLD:
|
|
|
|
case Mode::Number::GUIDED_NOGPS:
|
|
|
|
case Mode::Number::SPORT:
|
|
|
|
case Mode::Number::AUTOTUNE:
|
|
|
|
case Mode::Number::FLOWHOLD:
|
2019-02-19 17:29:05 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// stabilize, acro, drift, and flip have no automatic x,y or z control (i.e. all manual)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if PROXIMITY_ENABLED == ENABLED
|
|
|
|
if (copter.g2.proximity.sensor_enabled()) {
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_PROXIMITY;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-19 19:01:55 -04:00
|
|
|
if (ap.rc_receiver_present && !copter.failsafe.radio) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_RC_RECEIVER;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#if OPTFLOW == ENABLED
|
2019-02-19 19:01:55 -04:00
|
|
|
if (optflow && optflow->healthy()) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if PRECISION_LANDING == ENABLED
|
2019-06-24 10:03:52 -03:00
|
|
|
if (copter.precland.enabled() && copter.precland.healthy()) {
|
2019-02-19 19:01:55 -04:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if VISUAL_ODOMETRY_ENABLED == ENABLED
|
|
|
|
if (visual_odom && visual_odom->enabled() && visual_odom->healthy()) {
|
2019-02-19 19:01:55 -04:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if PROXIMITY_ENABLED == ENABLED
|
2019-02-19 19:01:55 -04:00
|
|
|
if (!copter.g2.proximity.sensor_failed()) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_PROXIMITY;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if AP_TERRAIN_AVAILABLE && AC_TERRAIN
|
|
|
|
switch (copter.terrain.status()) {
|
|
|
|
case AP_Terrain::TerrainStatusDisabled:
|
|
|
|
break;
|
|
|
|
case AP_Terrain::TerrainStatusUnhealthy:
|
|
|
|
// To-Do: restore unhealthy terrain status reporting once terrain is used in copter
|
|
|
|
//control_sensors_present |= MAV_SYS_STATUS_TERRAIN;
|
|
|
|
//control_sensors_enabled |= MAV_SYS_STATUS_TERRAIN;
|
|
|
|
//break;
|
|
|
|
case AP_Terrain::TerrainStatusOK:
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_TERRAIN;
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_TERRAIN;
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_TERRAIN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RANGEFINDER_ENABLED == ENABLED
|
|
|
|
if (copter.rangefinder_state.enabled) {
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
2019-02-19 19:01:55 -04:00
|
|
|
if (rangefinder && rangefinder->has_data_orient(ROTATION_PITCH_270)) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|