2019-02-19 17:33:12 -04:00
|
|
|
#include "GCS_Rover.h"
|
|
|
|
|
|
|
|
#include "Rover.h"
|
|
|
|
|
2019-11-10 22:47:52 -04:00
|
|
|
#include <AP_RangeFinder/AP_RangeFinder_Backend.h>
|
2019-02-19 17:33:12 -04:00
|
|
|
|
2020-02-11 21:01:17 -04:00
|
|
|
uint8_t GCS_Rover::sysid_this_mav() const
|
|
|
|
{
|
|
|
|
return rover.g.sysid_this_mav;
|
|
|
|
}
|
|
|
|
|
2019-03-01 19:25:26 -04:00
|
|
|
bool GCS_Rover::simple_input_active() const
|
|
|
|
{
|
|
|
|
if (rover.control_mode != &rover.mode_simple) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return (rover.g2.simple_type == ModeSimple::Simple_InitialHeading);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GCS_Rover::supersimple_input_active() const
|
|
|
|
{
|
|
|
|
if (rover.control_mode != &rover.mode_simple) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return (rover.g2.simple_type == ModeSimple::Simple_CardinalDirections);
|
|
|
|
}
|
|
|
|
|
2019-02-19 19:16:12 -04:00
|
|
|
void GCS_Rover::update_vehicle_sensor_status_flags(void)
|
2019-02-19 17:33:12 -04:00
|
|
|
{
|
2021-04-13 00:55:54 -03:00
|
|
|
// mode-specific:
|
2019-02-19 19:16:12 -04:00
|
|
|
control_sensors_present |=
|
|
|
|
MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL |
|
|
|
|
MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION |
|
|
|
|
MAV_SYS_STATUS_SENSOR_YAW_POSITION |
|
|
|
|
MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL;
|
|
|
|
|
2019-02-19 17:33:12 -04:00
|
|
|
if (rover.control_mode->attitude_stabilized()) {
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL; // 3D angular rate control
|
2019-02-19 19:16:12 -04:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL; // 3D angular rate control
|
2019-02-19 17:33:12 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION; // 3D angular rate control
|
2019-02-19 19:16:12 -04:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION; // 3D angular rate control
|
2019-02-19 17:33:12 -04:00
|
|
|
}
|
|
|
|
if (rover.control_mode->is_autopilot_mode()) {
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_YAW_POSITION; // yaw position
|
2019-02-19 19:16:12 -04:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_YAW_POSITION; // yaw position
|
2019-02-19 17:33:12 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL; // X/Y position control
|
2019-02-19 19:16:12 -04:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL; // X/Y position control
|
2019-02-19 17:33:12 -04:00
|
|
|
}
|
|
|
|
|
2021-04-13 00:55:54 -03:00
|
|
|
#if HAL_PROXIMITY_ENABLED
|
|
|
|
const AP_Proximity *proximity = AP_Proximity::get_singleton();
|
|
|
|
if (proximity && proximity->get_status() > AP_Proximity::Status::NotConnected) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
}
|
|
|
|
if (proximity && proximity->get_status() != AP_Proximity::Status::NoData) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-09-07 03:49:51 -03:00
|
|
|
#if AP_OPTICALFLOW_ENABLED
|
|
|
|
const AP_OpticalFlow *optflow = AP::opticalflow();
|
|
|
|
if (optflow && optflow->enabled()) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW;
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW;
|
|
|
|
}
|
|
|
|
if (optflow && optflow->healthy()) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-19 17:33:12 -04:00
|
|
|
const RangeFinder *rangefinder = RangeFinder::get_singleton();
|
|
|
|
if (rangefinder && rangefinder->num_sensors() > 0) {
|
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
AP_RangeFinder_Backend *s = rangefinder->get_backend(0);
|
|
|
|
if (s != nullptr && s->has_data()) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|