Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Copter to compile when Fence is disable but Avoidance is not #26561

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ArduCopter/Copter.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@
#include <AC_CustomControl/AC_CustomControl.h> // Custom control library
#endif

#if AP_AVOIDANCE_ENABLED && !AP_FENCE_ENABLED
#error AC_Avoidance relies on AP_FENCE_ENABLED which is disabled
#endif

#if AP_OAPATHPLANNER_ENABLED && !AP_FENCE_ENABLED
#error AP_OAPathPlanner relies on AP_FENCE_ENABLED which is disabled
#endif
Expand Down
38 changes: 25 additions & 13 deletions Tools/autotest/test_build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, feature, vehicle, bytes_delta):

class TestBuildOptions(object):
def __init__(self,
match_glob=None,
match_glob=[],
do_step_disable_all=True,
do_step_disable_none=False,
do_step_disable_defaults=True,
Expand Down Expand Up @@ -317,9 +317,13 @@ def run_disable_in_turn(self):
options = self.get_build_options_from_ardupilot_tree()
count = 1
for feature in sorted(options, key=lambda x : x.define):
if self.match_glob is not None:
if not fnmatch.fnmatch(feature.define, self.match_glob):
continue
match = False
for match_glob in self.match_glob:
if fnmatch.fnmatch(feature.define, match_glob):
match = True
break
if not match:
continue
with open("/tmp/run-disable-in-turn-progress", "w") as f:
f.write(f"{count}/{len(options)} {feature.define}\n")
# if feature.define < "WINCH_ENABLED":
Expand Down Expand Up @@ -355,9 +359,13 @@ def run_enable_in_turn(self):
options = self.get_build_options_from_ardupilot_tree()
count = 1
for feature in options:
if self.match_glob is not None:
if not fnmatch.fnmatch(feature.define, self.match_glob):
continue
match = False
for match_glob in self.match_glob:
if fnmatch.fnmatch(feature.define, match_glob):
match = True
break
if not match:
continue
self.progress("Enabling feature %s(%s) (%u/%u)" %
(feature.label, feature.define, count, len(options)))
with open("/tmp/run-enable-in-turn-progress", "w") as f:
Expand All @@ -377,9 +385,13 @@ def get_disable_all_defines(self):
options = self.get_build_options_from_ardupilot_tree()
defines = {}
for feature in options:
if self.match_glob is not None:
if not fnmatch.fnmatch(feature.define, self.match_glob):
continue
match = False
for match_glob in self.match_glob:
if fnmatch.fnmatch(feature.define, match_glob):
match = True
break
if not match:
continue
defines[feature.define] = 0
for define in self.must_have_defines_for_board(self._board):
defines[define] = 1
Expand Down Expand Up @@ -453,9 +465,9 @@ def run(self):

parser = optparse.OptionParser()
parser.add_option("--define-match-glob",
type='string',
default=None,
help='feature define must match this glob to be tested')
default=[],
action='append',
help='feature define must match any of these globs to be tested')
parser.add_option("--no-run-with-defaults",
action='store_true',
help='Do not run the run-with-defaults step')
Expand Down
2 changes: 1 addition & 1 deletion Tools/scripts/build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self,
Feature('Safety', 'PARACHUTE', 'HAL_PARACHUTE_ENABLED', 'Enable Parachute', 0, None),
Feature('Safety', 'FENCE', 'AP_FENCE_ENABLED', 'Enable Geofence', 2, None),
Feature('Safety', 'RALLY', 'HAL_RALLY_ENABLED', 'Enable Rally Points', 0, None), # noqa
Feature('Safety', 'AC_AVOID', 'AP_AVOIDANCE_ENABLED', 'Enable Avoidance', 0, 'FENCE'),
Feature('Safety', 'AC_AVOID', 'AP_AVOIDANCE_ENABLED', 'Enable Avoidance', 0, None),
Feature('Safety', 'AC_OAPATHPLANNER', 'AP_OAPATHPLANNER_ENABLED', 'Enable Object Avoidance Path Planner', 0, 'FENCE'),

Feature('Battery', 'BATTERY_FUELFLOW', 'AP_BATTERY_FUELFLOW_ENABLED', 'Enable Fuel Flow BatteryMonitor', 0, None),
Expand Down
2 changes: 1 addition & 1 deletion libraries/AC_Avoidance/AC_Avoidance_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <AC_Fence/AC_Fence_config.h>

#ifndef AP_AVOIDANCE_ENABLED
#define AP_AVOIDANCE_ENABLED AP_FENCE_ENABLED
Copy link
Contributor

@rmackay9 rmackay9 Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should change this so it's (AP_FENCE_ENABLE || HAL_PROXIMITY_ENABLED || AP_BEACON_ENABLED). No point in having avoidance if none of these are available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see if this works - but this sort of thing usually ends up with include loops / tears.

#define AP_AVOIDANCE_ENABLED 1
#endif

#ifndef AP_OAPATHPLANNER_ENABLED
Expand Down
Loading