aboutsummaryrefslogtreecommitdiff
path: root/src/modules/navigator/navigator_main.cpp
diff options
context:
space:
mode:
authorBan Siesta <bansiesta@gmail.com>2014-12-19 22:26:31 +0000
committerBan Siesta <bansiesta@gmail.com>2014-12-19 22:26:31 +0000
commit2a09473e5fc73bf2f59f0d27b0b5c38b2c91812f (patch)
treefda3c8920df9fdab418bdfed25fe1a327eb200b7 /src/modules/navigator/navigator_main.cpp
parent19d5383c56b78132e63ea30ef1625b0aaa4a0dee (diff)
downloadpx4-firmware-2a09473e5fc73bf2f59f0d27b0b5c38b2c91812f.tar.gz
px4-firmware-2a09473e5fc73bf2f59f0d27b0b5c38b2c91812f.tar.bz2
px4-firmware-2a09473e5fc73bf2f59f0d27b0b5c38b2c91812f.zip
topics: move geofence status to its own topic
Diffstat (limited to 'src/modules/navigator/navigator_main.cpp')
-rw-r--r--src/modules/navigator/navigator_main.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp
index df620e5e7..0ab85d56e 100644
--- a/src/modules/navigator/navigator_main.cpp
+++ b/src/modules/navigator/navigator_main.cpp
@@ -110,6 +110,7 @@ Navigator::Navigator() :
_param_update_sub(-1),
_pos_sp_triplet_pub(-1),
_mission_result_pub(-1),
+ _geofence_result_pub(-1),
_att_sp_pub(-1),
_vstatus{},
_control_mode{},
@@ -398,8 +399,8 @@ Navigator::task_main()
have_geofence_position_data = false;
if (!inside) {
/* inform other apps via the mission result */
- _mission_result.geofence_violated = true;
- publish_mission_result();
+ _geofence_result.geofence_violated = true;
+ publish_geofence_result();
/* Issue a warning about the geofence violation once */
if (!_geofence_violation_warning_sent) {
@@ -408,8 +409,8 @@ Navigator::task_main()
}
} else {
/* inform other apps via the mission result */
- _mission_result.geofence_violated = false;
- publish_mission_result();
+ _geofence_result.geofence_violated = false;
+ publish_geofence_result();
/* Reset the _geofence_violation_warning_sent field */
_geofence_violation_warning_sent = false;
}
@@ -642,6 +643,21 @@ Navigator::publish_mission_result()
}
void
+Navigator::publish_geofence_result()
+{
+
+ /* lazily publish the geofence result only once available */
+ if (_geofence_result_pub > 0) {
+ /* publish mission result */
+ orb_publish(ORB_ID(geofence_result), _geofence_result_pub, &_geofence_result);
+
+ } else {
+ /* advertise and publish */
+ _geofence_result_pub = orb_advertise(ORB_ID(geofence_result), &_geofence_result);
+ }
+}
+
+void
Navigator::publish_att_sp()
{
/* lazily publish the attitude sp only once available */