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
|
|
|
|
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
|
|
|
{
|
|
|
|
// first what sensors/controllers we have
|
|
|
|
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:16:12 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
2019-02-19 17:33:12 -04:00
|
|
|
}
|
|
|
|
const AP_Proximity *proximity = AP_Proximity::get_singleton();
|
2019-09-27 05:59:08 -03:00
|
|
|
if (proximity && proximity->get_status() > AP_Proximity::Status::NotConnected) {
|
2019-02-19 17:33:12 -04:00
|
|
|
control_sensors_present |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
2019-02-19 19:16:12 -04:00
|
|
|
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
2019-02-19 17:33:12 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-02-19 19:16:12 -04:00
|
|
|
if (visual_odom && visual_odom->enabled() && visual_odom->healthy()) {
|
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_VISION_POSITION;
|
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;
|
|
|
|
}
|
|
|
|
}
|
2019-09-27 05:59:08 -03:00
|
|
|
if (proximity && proximity->get_status() != AP_Proximity::Status::NoData) {
|
2019-02-19 19:16:12 -04:00
|
|
|
control_sensors_health |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
|
2019-02-19 17:33:12 -04:00
|
|
|
}
|
|
|
|
}
|