Skip to content

Commit

Permalink
Sub: Send a clear message if depth sensor is not connected
Browse files Browse the repository at this point in the history
Fix bluerobotics/ardusub#151

Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric authored and jaxxzer committed Apr 19, 2018
1 parent 8fa1700 commit 0878f50
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions ArduSub/ArduSub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,16 @@ void Sub::update_altitude()
}
}

bool Sub::control_check_barometer()
{
if (!ap.depth_sensor_present) { // can't hold depth without a depth sensor
gcs().send_text(MAV_SEVERITY_WARNING, "Depth sensor is not connected.");
return false;
} else if (failsafe.sensor_health) {
gcs().send_text(MAV_SEVERITY_WARNING, "Depth sensor error.");
return false;
}
return true;
}

AP_HAL_MAIN_CALLBACKS(&sub);
2 changes: 2 additions & 0 deletions ArduSub/Sub.h
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,8 @@ class Sub : public AP_HAL::HAL::Callbacks {

void convert_old_parameters(void);

bool control_check_barometer();

enum Failsafe_Action {
Failsafe_Action_None = 0,
Failsafe_Action_Warn = 1,
Expand Down
3 changes: 1 addition & 2 deletions ArduSub/control_althold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
bool Sub::althold_init()
{
#if CONFIG_HAL_BOARD != HAL_BOARD_SITL
if (!ap.depth_sensor_present || failsafe.sensor_health) { // can't hold depth without a depth sensor, exit immediately.
gcs().send_text(MAV_SEVERITY_WARNING, "BAD DEPTH");
if(!control_check_barometer()) {
return false;
}
#endif
Expand Down
3 changes: 1 addition & 2 deletions ArduSub/control_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
bool Sub::surface_init()
{
#if CONFIG_HAL_BOARD != HAL_BOARD_SITL
if (!ap.depth_sensor_present || failsafe.sensor_health) { // can't hold depth without a depth sensor, exit immediately.
gcs().send_text(MAV_SEVERITY_WARNING, "BAD DEPTH");
if(!control_check_barometer()) {
return false;
}
#endif
Expand Down

0 comments on commit 0878f50

Please sign in to comment.