diff --git a/libraries/AC_Avoidance/AC_Avoid.cpp b/libraries/AC_Avoidance/AC_Avoid.cpp
index 75f0aeb0fc..f508d59484 100644
--- a/libraries/AC_Avoidance/AC_Avoid.cpp
+++ b/libraries/AC_Avoidance/AC_Avoid.cpp
@@ -13,6 +13,10 @@
along with this program. If not, see .
*/
+#include "AC_Avoidance_config.h"
+
+#if AP_AVOIDANCE_ENABLED
+
#include "AC_Avoid.h"
#include // AHRS library
#include // Failsafe fence library
@@ -1477,3 +1481,5 @@ AC_Avoid *ac_avoid()
}
#endif // !APM_BUILD_Arduplane
+
+#endif // AP_AVOIDANCE_ENABLED
diff --git a/libraries/AC_Avoidance/AC_Avoid.h b/libraries/AC_Avoidance/AC_Avoid.h
index 6bccfb846d..0d99b5e197 100644
--- a/libraries/AC_Avoidance/AC_Avoid.h
+++ b/libraries/AC_Avoidance/AC_Avoid.h
@@ -1,5 +1,9 @@
#pragma once
+#include "AC_Avoidance_config.h"
+
+#if AP_AVOIDANCE_ENABLED
+
#include
#include
#include
@@ -228,3 +232,5 @@ private:
namespace AP {
AC_Avoid *ac_avoid();
};
+
+#endif // AP_AVOIDANCE_ENABLED
diff --git a/libraries/AC_Avoidance/AC_Avoidance_Logging.cpp b/libraries/AC_Avoidance/AC_Avoidance_Logging.cpp
index 7a6b3354f9..54859110fb 100644
--- a/libraries/AC_Avoidance/AC_Avoidance_Logging.cpp
+++ b/libraries/AC_Avoidance/AC_Avoidance_Logging.cpp
@@ -7,6 +7,7 @@
#include "AP_OABendyRuler.h"
#include
+#if AP_OAPATHPLANNER_BENDYRULER_ENABLED
void AP_OABendyRuler::Write_OABendyRuler(const uint8_t type, const bool active, const float target_yaw, const float target_pitch, const bool resist_chg, const float margin, const Location &final_dest, const Location &oa_dest) const
{
int32_t oa_dest_alt, final_alt;
@@ -32,7 +33,9 @@ void AP_OABendyRuler::Write_OABendyRuler(const uint8_t type, const bool active,
};
AP::logger().WriteBlock(&pkt, sizeof(pkt));
}
+#endif // AP_OAPATHPLANNER_BENDYRULER_ENABLED
+#if AP_OAPATHPLANNER_DIJKSTRA_ENABLED
void AP_OADijkstra::Write_OADijkstra(const uint8_t state, const uint8_t error_id, const uint8_t curr_point, const uint8_t tot_points, const Location &final_dest, const Location &oa_dest) const
{
const struct log_OADijkstra pkt{
@@ -49,7 +52,9 @@ void AP_OADijkstra::Write_OADijkstra(const uint8_t state, const uint8_t error_id
};
AP::logger().WriteBlock(&pkt, sizeof(pkt));
}
+#endif
+#if AP_OAPATHPLANNER_ENABLED
void AP_OADijkstra::Write_Visgraph_point(const uint8_t version, const uint8_t point_num, const int32_t Lat, const int32_t Lon) const
{
const struct log_OD_Visgraph pkt{
@@ -62,8 +67,9 @@ void AP_OADijkstra::Write_Visgraph_point(const uint8_t version, const uint8_t po
};
AP::logger().WriteBlock(&pkt, sizeof(pkt));
}
+#endif
-
+#if AP_AVOIDANCE_ENABLED
void AC_Avoid::Write_SimpleAvoidance(const uint8_t state, const Vector3f& desired_vel, const Vector3f& modified_vel, const bool back_up) const
{
const struct log_SimpleAvoid pkt{
@@ -80,5 +86,6 @@ void AC_Avoid::Write_SimpleAvoidance(const uint8_t state, const Vector3f& desire
};
AP::logger().WriteBlock(&pkt, sizeof(pkt));
}
+#endif
#endif // HAL_LOGGING_ENABLED
diff --git a/libraries/AC_Avoidance/AC_Avoidance_config.h b/libraries/AC_Avoidance/AC_Avoidance_config.h
new file mode 100644
index 0000000000..602d06829c
--- /dev/null
+++ b/libraries/AC_Avoidance/AC_Avoidance_config.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include
+#include
+
+#ifndef AP_AVOIDANCE_ENABLED
+#define AP_AVOIDANCE_ENABLED AP_FENCE_ENABLED
+#endif
+
+#ifndef AP_OAPATHPLANNER_ENABLED
+#define AP_OAPATHPLANNER_ENABLED AP_FENCE_ENABLED
+#endif
+
+#ifndef AP_OAPATHPLANNER_BACKEND_DEFAULT_ENABLED
+#define AP_OAPATHPLANNER_BACKEND_DEFAULT_ENABLED AP_OAPATHPLANNER_ENABLED
+#endif
+
+#ifndef AP_OAPATHPLANNER_BENDYRULER_ENABLED
+#define AP_OAPATHPLANNER_BENDYRULER_ENABLED AP_OAPATHPLANNER_BACKEND_DEFAULT_ENABLED
+#endif
+
+#ifndef AP_OAPATHPLANNER_DIJKSTRA_ENABLED
+#define AP_OAPATHPLANNER_DIJKSTRA_ENABLED AP_OAPATHPLANNER_BACKEND_DEFAULT_ENABLED
+#endif
+
+
+
+#ifndef AP_OADATABASE_ENABLED
+#define AP_OADATABASE_ENABLED AP_OAPATHPLANNER_ENABLED
+#endif
diff --git a/libraries/AC_Avoidance/AP_OABendyRuler.cpp b/libraries/AC_Avoidance/AP_OABendyRuler.cpp
index ed122bff29..aa66c944d4 100644
--- a/libraries/AC_Avoidance/AP_OABendyRuler.cpp
+++ b/libraries/AC_Avoidance/AP_OABendyRuler.cpp
@@ -13,6 +13,10 @@
along with this program. If not, see .
*/
+#include "AC_Avoidance_config.h"
+
+#if AP_OAPATHPLANNER_BENDYRULER_ENABLED
+
#include "AP_OABendyRuler.h"
#include
#include
@@ -708,3 +712,5 @@ bool AP_OABendyRuler::calc_margin_from_object_database(const Location &start, co
return false;
}
+
+#endif // AP_OAPATHPLANNER_BENDYRULER_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OABendyRuler.h b/libraries/AC_Avoidance/AP_OABendyRuler.h
index 35e9b4a1c3..625a792739 100644
--- a/libraries/AC_Avoidance/AP_OABendyRuler.h
+++ b/libraries/AC_Avoidance/AP_OABendyRuler.h
@@ -1,5 +1,9 @@
#pragma once
+#include "AC_Avoidance_config.h"
+
+#if AP_OAPATHPLANNER_BENDYRULER_ENABLED
+
#include
#include
#include
@@ -88,3 +92,5 @@ private:
float _bearing_prev; // stored bearing in degrees
Location _destination_prev; // previous destination, to check if there has been a change in destination
};
+
+#endif // AP_OAPATHPLANNER_BENDYRULER_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OADatabase.cpp b/libraries/AC_Avoidance/AP_OADatabase.cpp
index aeae78098b..20bc48f594 100644
--- a/libraries/AC_Avoidance/AP_OADatabase.cpp
+++ b/libraries/AC_Avoidance/AP_OADatabase.cpp
@@ -11,6 +11,10 @@
along with this program. If not, see .
*/
+#include "AC_Avoidance_config.h"
+
+#if AP_OADATABASE_ENABLED
+
#include "AP_OADatabase.h"
#include
@@ -482,3 +486,5 @@ AP_OADatabase *oadatabase()
}
}
+
+#endif // AP_OADATABASE_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OADatabase.h b/libraries/AC_Avoidance/AP_OADatabase.h
index 2a77fdc566..8860c24299 100644
--- a/libraries/AC_Avoidance/AP_OADatabase.h
+++ b/libraries/AC_Avoidance/AP_OADatabase.h
@@ -1,5 +1,9 @@
#pragma once
+#include "AC_Avoidance_config.h"
+
+#if AP_OADATABASE_ENABLED
+
#include
#include
#include
@@ -115,4 +119,4 @@ namespace AP {
AP_OADatabase *oadatabase();
};
-
+#endif // AP_OADATABASE_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OADijkstra.cpp b/libraries/AC_Avoidance/AP_OADijkstra.cpp
index d40b7a182f..e2cd63ec4d 100644
--- a/libraries/AC_Avoidance/AP_OADijkstra.cpp
+++ b/libraries/AC_Avoidance/AP_OADijkstra.cpp
@@ -13,6 +13,10 @@
along with this program. If not, see .
*/
+#include "AC_Avoidance_config.h"
+
+#if AP_OAPATHPLANNER_DIJKSTRA_ENABLED
+
#include "AP_OADijkstra.h"
#include "AP_OAPathPlanner.h"
@@ -1011,3 +1015,5 @@ bool AP_OADijkstra::convert_node_to_point(const AP_OAVisGraph::OAItemID& id, Vec
}
#endif // AP_FENCE_ENABLED
+
+#endif // AP_OAPATHPLANNER_DIJKSTRA_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OADijkstra.h b/libraries/AC_Avoidance/AP_OADijkstra.h
index f56e940e30..2cfd4ec049 100644
--- a/libraries/AC_Avoidance/AP_OADijkstra.h
+++ b/libraries/AC_Avoidance/AP_OADijkstra.h
@@ -1,5 +1,9 @@
#pragma once
+#include "AC_Avoidance_config.h"
+
+#if AP_OAPATHPLANNER_DIJKSTRA_ENABLED
+
#include
#include
#include
@@ -219,3 +223,5 @@ private:
// reference to AP_OAPathPlanner options param
AP_Int16 &_options;
};
+
+#endif // AP_OAPATHPLANNER_DIJKSTRA_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OAPathPlanner.cpp b/libraries/AC_Avoidance/AP_OAPathPlanner.cpp
index d513d49756..a702ed6de5 100644
--- a/libraries/AC_Avoidance/AP_OAPathPlanner.cpp
+++ b/libraries/AC_Avoidance/AP_OAPathPlanner.cpp
@@ -13,6 +13,10 @@
along with this program. If not, see .
*/
+#include "AC_Avoidance_config.h"
+
+#if AP_OAPATHPLANNER_ENABLED
+
#include "AP_OAPathPlanner.h"
#include
#include
@@ -432,3 +436,5 @@ AP_OAPathPlanner *ap_oapathplanner()
}
}
+
+#endif // AP_OAPATHPLANNER_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OAPathPlanner.h b/libraries/AC_Avoidance/AP_OAPathPlanner.h
index 3c08dc4b76..a349368efe 100644
--- a/libraries/AC_Avoidance/AP_OAPathPlanner.h
+++ b/libraries/AC_Avoidance/AP_OAPathPlanner.h
@@ -1,5 +1,9 @@
#pragma once
+#include "AC_Avoidance_config.h"
+
+#if AP_OAPATHPLANNER_ENABLED
+
#include
#include
#include
@@ -135,3 +139,5 @@ private:
namespace AP {
AP_OAPathPlanner *ap_oapathplanner();
};
+
+#endif // AP_OAPATHPLANNER_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OAVisGraph.cpp b/libraries/AC_Avoidance/AP_OAVisGraph.cpp
index 4fd4f2c172..4b7fc09960 100644
--- a/libraries/AC_Avoidance/AP_OAVisGraph.cpp
+++ b/libraries/AC_Avoidance/AP_OAVisGraph.cpp
@@ -13,6 +13,10 @@
along with this program. If not, see .
*/
+#include "AC_Avoidance_config.h"
+
+#if AP_OAPATHPLANNER_ENABLED
+
#include "AP_OAVisGraph.h"
// constructor initialises expanding array to use 20 elements per chunk
@@ -39,3 +43,5 @@ bool AP_OAVisGraph::add_item(const OAItemID &id1, const OAItemID &id2, float dis
_num_items++;
return true;
}
+
+#endif // AP_OAPATHPLANNER_ENABLED
diff --git a/libraries/AC_Avoidance/AP_OAVisGraph.h b/libraries/AC_Avoidance/AP_OAVisGraph.h
index 800fbff407..7c58236d5b 100644
--- a/libraries/AC_Avoidance/AP_OAVisGraph.h
+++ b/libraries/AC_Avoidance/AP_OAVisGraph.h
@@ -1,5 +1,9 @@
#pragma once
+#include "AC_Avoidance_config.h"
+
+#if AP_OAPATHPLANNER_ENABLED
+
#include
#include
@@ -54,3 +58,5 @@ private:
AP_ExpandingArray _items;
uint16_t _num_items;
};
+
+#endif // AP_OAPATHPLANNER_ENABLED