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
|
|
|
|
2024-09-15 12:15:47 -03:00
|
|
|
// Update position controller flags
|
|
|
|
if (copter.pos_control != nullptr) {
|
|
|
|
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
|
|
|
|
2024-09-15 12:15:47 -03:00
|
|
|
// XY position controller
|
|
|
|
if (copter.pos_control->is_active_xy()) {
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL;
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Z altitude controller
|
|
|
|
if (copter.pos_control->is_active_z()) {
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL;
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL;
|
|
|
|
}
|
2019-02-19 17:29:05 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2023-11-07 18:23:41 -04:00
|
|
|
#if AP_RANGEFINDER_ENABLED
|
2021-04-13 00:55:53 -03:00
|
|
|
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
|
|
|
}
|