2019-02-19 17:29:05 -04:00
|
|
|
#include "GCS_Copter.h"
|
|
|
|
|
|
|
|
#include "Copter.h"
|
|
|
|
|
2020-02-11 21:01:17 -04:00
|
|
|
uint8_t GCS_Copter::sysid_this_mav() const
|
|
|
|
{
|
|
|
|
return copter.g.sysid_this_mav;
|
|
|
|
}
|
|
|
|
|
2019-03-01 02:08:33 -04:00
|
|
|
const char* GCS_Copter::frame_string() const
|
|
|
|
{
|
2020-12-06 23:46:09 -04:00
|
|
|
if (copter.motors == nullptr) {
|
2023-01-14 18:06:08 -04:00
|
|
|
return "MultiCopter";
|
2020-12-06 23:46:09 -04:00
|
|
|
}
|
2020-11-05 16:00:12 -04:00
|
|
|
return copter.motors->get_frame_string();
|
2019-03-01 02:08:33 -04:00
|
|
|
}
|
|
|
|
|
2019-03-01 19:25:38 -04:00
|
|
|
bool GCS_Copter::simple_input_active() const
|
|
|
|
{
|
2020-06-15 10:05:09 -03:00
|
|
|
return copter.simple_mode == Copter::SimpleMode::SIMPLE;
|
2019-03-01 19:25:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GCS_Copter::supersimple_input_active() const
|
|
|
|
{
|
2020-06-15 10:05:09 -03:00
|
|
|
return copter.simple_mode == Copter::SimpleMode::SUPERSIMPLE;
|
2019-03-01 19:25:38 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
}
|
2021-04-13 00:55:53 -03: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
|
|
|
}
|
|
|
|
|
2021-04-13 00:55:53 -03:00
|
|
|
// update flightmode-specific flags:
|
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
|
|
|
|
2020-01-30 03:29:36 -04:00
|
|
|
switch (copter.flightmode->mode_number()) {
|
2019-09-07 20:33:56 -03:00
|
|
|
case Mode::Number::AUTO:
|
2021-07-25 07:27:51 -03:00
|
|
|
case Mode::Number::AUTO_RTL:
|
2019-09-07 20:33:56 -03:00
|
|
|
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;
|
2020-04-30 06:27:21 -03:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL;
|
2019-02-19 17:29:05 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL;
|
2020-04-30 06:27:21 -03:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL;
|
2019-02-19 17:29:05 -04:00
|
|
|
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;
|
2020-04-30 06:27:21 -03:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL;
|
2019-02-19 17:29:05 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// stabilize, acro, drift, and flip have no automatic x,y or z control (i.e. all manual)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-13 00:55:53 -03:00
|
|
|
// optional sensors, some of which are essentially always
|
|
|
|
// available in the firmware:
|
2021-03-25 05:08:44 -03:00
|
|
|
#if HAL_PROXIMITY_ENABLED
|
2021-04-13 00:55:53 -03:00
|
|
|
if (copter.g2.proximity.sensor_present()) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_PROXIMITY;
|
|
|
|
}
|
2019-02-19 17:29:05 -04:00
|
|
|
if (copter.g2.proximity.sensor_enabled()) {
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_PROXIMITY;
|
|
|
|
}
|
2021-04-13 00:55:53 -03:00
|
|
|
if (!copter.g2.proximity.sensor_failed()) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_PROXIMITY;
|
|
|
|
}
|
2019-02-19 17:29:05 -04:00
|
|
|
#endif
|
|
|
|
|
2021-04-13 00:55:53 -03:00
|
|
|
#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;
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
2021-04-13 00:55:53 -03:00
|
|
|
if (copter.rangefinder_state.enabled) {
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
if (rangefinder && rangefinder->has_data_orient(ROTATION_PITCH_270)) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-03-22 05:45:41 -03:00
|
|
|
#if AC_PRECLAND_ENABLED
|
2021-04-13 00:55:53 -03:00
|
|
|
if (copter.precland.enabled()) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
|
|
|
}
|
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
|
|
|
|
|
2021-02-12 23:40:10 -04:00
|
|
|
#if AP_TERRAIN_AVAILABLE
|
2019-02-19 17:29:05 -04:00
|
|
|
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
|
2020-10-09 08:33:21 -03:00
|
|
|
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_PROPULSION;
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_PROPULSION;
|
|
|
|
// only mark propulsion healthy if all of the motors are producing
|
|
|
|
// nominal thrust
|
|
|
|
if (!copter.motors->get_thrust_boost()) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_PROPULSION;
|
|
|
|
}
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|