Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Rover/GCS_Rover.cpp
9436 views
1
#include "GCS_Rover.h"
2
3
#include "Rover.h"
4
5
#include <AP_RangeFinder/AP_RangeFinder_Backend.h>
6
7
bool GCS_Rover::simple_input_active() const
8
{
9
if (rover.control_mode != &rover.mode_simple) {
10
return false;
11
}
12
return (rover.g2.simple_type == ModeSimple::Simple_InitialHeading);
13
}
14
15
bool GCS_Rover::supersimple_input_active() const
16
{
17
if (rover.control_mode != &rover.mode_simple) {
18
return false;
19
}
20
return (rover.g2.simple_type == ModeSimple::Simple_CardinalDirections);
21
}
22
23
void GCS_Rover::update_vehicle_sensor_status_flags(void)
24
{
25
// mode-specific:
26
control_sensors_present |=
27
MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL |
28
MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION |
29
MAV_SYS_STATUS_SENSOR_YAW_POSITION |
30
MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL;
31
32
if (rover.control_mode->attitude_stabilized()) {
33
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL; // 3D angular rate control
34
control_sensors_health |= MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL; // 3D angular rate control
35
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION; // 3D angular rate control
36
control_sensors_health |= MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION; // 3D angular rate control
37
}
38
if (rover.control_mode->is_autopilot_mode()) {
39
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_YAW_POSITION; // yaw position
40
control_sensors_health |= MAV_SYS_STATUS_SENSOR_YAW_POSITION; // yaw position
41
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL; // X/Y position control
42
control_sensors_health |= MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL; // X/Y position control
43
}
44
45
#if HAL_PROXIMITY_ENABLED
46
const AP_Proximity *proximity = AP_Proximity::get_singleton();
47
if (proximity && proximity->get_status() > AP_Proximity::Status::NotConnected) {
48
control_sensors_present |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
49
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
50
}
51
if (proximity && proximity->get_status() != AP_Proximity::Status::NoData) {
52
control_sensors_health |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
53
}
54
#endif
55
56
#if AP_RANGEFINDER_ENABLED
57
const RangeFinder *rangefinder = RangeFinder::get_singleton();
58
if (rangefinder && rangefinder->num_sensors() > 0) {
59
control_sensors_present |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
60
control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
61
AP_RangeFinder_Backend *s = rangefinder->get_backend(0);
62
if (s != nullptr && s->has_data()) {
63
control_sensors_health |= MAV_SYS_STATUS_SENSOR_LASER_POSITION;
64
}
65
}
66
#endif
67
}
68
69