From 52ca49c6826c243136a09d5105156430a4570f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 14 Jul 2017 13:13:21 +0200 Subject: [PATCH] geofence: remove fence & fence_vertex messages - this was never read - it was implemented wrong, leading to memory access violations in publishFence (an integer was passed instead of the fence_s struct) --- msg/CMakeLists.txt | 2 -- msg/fence.msg | 4 ---- msg/fence_vertex.msg | 2 -- src/modules/dataman/dataman.h | 12 ++---------- src/modules/navigator/geofence.cpp | 12 ------------ src/modules/navigator/geofence.h | 10 +++++++--- 6 files changed, 9 insertions(+), 33 deletions(-) delete mode 100644 msg/fence.msg delete mode 100644 msg/fence_vertex.msg diff --git a/msg/CMakeLists.txt b/msg/CMakeLists.txt index d28246639a..ca35d80078 100644 --- a/msg/CMakeLists.txt +++ b/msg/CMakeLists.txt @@ -55,8 +55,6 @@ set(msg_file_names esc_report.msg esc_status.msg estimator_status.msg - fence.msg - fence_vertex.msg filtered_bottom_flow.msg follow_target.msg fw_pos_ctrl_status.msg diff --git a/msg/fence.msg b/msg/fence.msg deleted file mode 100644 index 4109a0c8fe..0000000000 --- a/msg/fence.msg +++ /dev/null @@ -1,4 +0,0 @@ -uint8 GEOFENCE_MAX_VERTICES = 16 - -uint32 count # number of actual vertices -fence_vertex[16] vertices # geofence positions diff --git a/msg/fence_vertex.msg b/msg/fence_vertex.msg deleted file mode 100644 index 2e524f9697..0000000000 --- a/msg/fence_vertex.msg +++ /dev/null @@ -1,2 +0,0 @@ -float32 lat # latitude in degrees, worst case float precision gives us 2 meter resolution at the equator -float32 lon # longitude in degrees, worst case float precision gives us 2 meter resolution at the equator diff --git a/src/modules/dataman/dataman.h b/src/modules/dataman/dataman.h index 32bc59d6f5..d9d524fbf4 100644 --- a/src/modules/dataman/dataman.h +++ b/src/modules/dataman/dataman.h @@ -66,11 +66,7 @@ typedef enum { #if defined(MEMORY_CONSTRAINED_SYSTEM) enum { DM_KEY_SAFE_POINTS_MAX = 8, -#ifdef __cplusplus - DM_KEY_FENCE_POINTS_MAX = fence_s::GEOFENCE_MAX_VERTICES, -#else - DM_KEY_FENCE_POINTS_MAX = GEOFENCE_MAX_VERTICES, -#endif + DM_KEY_FENCE_POINTS_MAX = 16, DM_KEY_WAYPOINTS_OFFBOARD_0_MAX = NUM_MISSIONS_SUPPORTED, DM_KEY_WAYPOINTS_OFFBOARD_1_MAX = NUM_MISSIONS_SUPPORTED, DM_KEY_WAYPOINTS_ONBOARD_MAX = (NUM_MISSIONS_SUPPORTED / 10), @@ -81,11 +77,7 @@ enum { /** The maximum number of instances for each item type */ enum { DM_KEY_SAFE_POINTS_MAX = 8, -#ifdef __cplusplus - DM_KEY_FENCE_POINTS_MAX = fence_s::GEOFENCE_MAX_VERTICES, -#else - DM_KEY_FENCE_POINTS_MAX = GEOFENCE_MAX_VERTICES, -#endif + DM_KEY_FENCE_POINTS_MAX = 64, DM_KEY_WAYPOINTS_OFFBOARD_0_MAX = NUM_MISSIONS_SUPPORTED, DM_KEY_WAYPOINTS_OFFBOARD_1_MAX = NUM_MISSIONS_SUPPORTED, DM_KEY_WAYPOINTS_ONBOARD_MAX = NUM_MISSIONS_SUPPORTED, diff --git a/src/modules/navigator/geofence.cpp b/src/modules/navigator/geofence.cpp index 931ab8173a..8918983f7f 100644 --- a/src/modules/navigator/geofence.cpp +++ b/src/modules/navigator/geofence.cpp @@ -237,7 +237,6 @@ Geofence::addPoint(int argc, char *argv[]) if ((argc == 1) && (strcmp("-clear", argv[0]) == 0)) { dm_clear(DM_KEY_FENCE_POINTS); - publishFence(0); return; } @@ -265,7 +264,6 @@ Geofence::addPoint(int argc, char *argv[]) if (dm_write(DM_KEY_FENCE_POINTS, ix, DM_PERSIST_POWER_ON_RESET, &vertex, sizeof(vertex)) == sizeof(vertex)) { if (last) { - publishFence((unsigned)ix + 1); } return; @@ -274,16 +272,6 @@ Geofence::addPoint(int argc, char *argv[]) PX4_WARN("can't store fence point"); } -void -Geofence::publishFence(unsigned vertices) -{ - if (_fence_pub == nullptr) { - _fence_pub = orb_advertise(ORB_ID(fence), &vertices); - - } else { - orb_publish(ORB_ID(fence), _fence_pub, &vertices); - } -} int Geofence::loadFromFile(const char *filename) diff --git a/src/modules/navigator/geofence.h b/src/modules/navigator/geofence.h index 25ba9b2a8a..f329282db6 100644 --- a/src/modules/navigator/geofence.h +++ b/src/modules/navigator/geofence.h @@ -43,6 +43,11 @@ #include +#include +#include +#include +#include +#include #include #include #include @@ -99,8 +104,6 @@ public: */ void addPoint(int argc, char *argv[]); - void publishFence(unsigned vertices); - int loadFromFile(const char *filename); bool isEmpty() {return _vertices_count == 0;} @@ -114,7 +117,8 @@ public: private: Navigator *_navigator{nullptr}; - orb_advert_t _fence_pub{nullptr}; /**< publish fence topic */ + home_position_s _home_pos{0}; + bool _home_pos_set{false}; hrt_abstime _last_horizontal_range_warning{0}; hrt_abstime _last_vertical_range_warning{0};