Browse Source

Rover: fence moved to vehicle

apm_2208
Iampete1 3 years ago committed by Andrew Tridgell
parent
commit
eac067a5c4
  1. 4
      Rover/AP_Rally.cpp
  2. 11
      Rover/Parameters.cpp
  3. 3
      Rover/Parameters.h
  4. 1
      Rover/Rover.cpp
  5. 2
      Rover/failsafe.cpp
  6. 12
      Rover/fence.cpp
  7. 6
      Rover/mode_auto.cpp
  8. 6
      Rover/system.cpp
  9. 1
      Rover/wscript

4
Rover/AP_Rally.cpp

@ -21,8 +21,10 @@ @@ -21,8 +21,10 @@
bool AP_Rally_Rover::is_valid(const Location &rally_point) const
{
if (!rover.g2.fence.check_destination_within_fence(rally_point)) {
#if AC_FENCE
if (!rover.fence.check_destination_within_fence(rally_point)) {
return false;
}
#endif
return true;
}

11
Rover/Parameters.cpp

@ -478,10 +478,6 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { @@ -478,10 +478,6 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
// @User: Standard
AP_GROUPINFO("FRAME_CLASS", 16, ParametersG2, frame_class, 1),
// @Group: FENCE_
// @Path: ../libraries/AC_Fence/AC_Fence.cpp
AP_SUBGROUPINFO(fence, "FENCE_", 17, ParametersG2, AC_Fence),
#if HAL_PROXIMITY_ENABLED
// @Group: PRX
// @Path: ../libraries/AP_Proximity/AP_Proximity.cpp
@ -847,7 +843,7 @@ void Rover::load_parameters(void) @@ -847,7 +843,7 @@ void Rover::load_parameters(void)
AP_BoardConfig::BOARD_SAFETY_OPTION_BUTTON_ACTIVE_ARMED);
#endif
#if AP_AIRSPEED_ENABLED | AP_AIS_ENABLED
#if AP_AIRSPEED_ENABLED | AP_AIS_ENABLED | AC_FENCE
// Find G2's Top Level Key
AP_Param::ConversionInfo info;
if (!AP_Param::find_top_level_key_by_pointer(&g2, info.old_key)) {
@ -866,4 +862,9 @@ void Rover::load_parameters(void) @@ -866,4 +862,9 @@ void Rover::load_parameters(void)
#if AP_AIS_ENABLED
AP_Param::convert_class(info.old_key, &ais, ais.var_info, 50, 114, false);
#endif
// PARAMETER_CONVERSION - Added: Mar-2022
#if AC_FENCE
AP_Param::convert_class(info.old_key, &fence, fence.var_info, 17, 4049, false);
#endif
}

3
Rover/Parameters.h

@ -334,9 +334,6 @@ public: @@ -334,9 +334,6 @@ public:
// frame class for vehicle
AP_Int8 frame_class;
// fence library
AC_Fence fence;
#if HAL_PROXIMITY_ENABLED
// proximity library
AP_Proximity proximity;

1
Rover/Rover.cpp

@ -82,7 +82,6 @@ const AP_Scheduler::Task Rover::scheduler_tasks[] = { @@ -82,7 +82,6 @@ const AP_Scheduler::Task Rover::scheduler_tasks[] = {
SCHED_TASK_CLASS(AP_Proximity, &rover.g2.proximity, update, 50, 200, 27),
#endif
SCHED_TASK_CLASS(AP_WindVane, &rover.g2.windvane, update, 20, 100, 30),
SCHED_TASK_CLASS(AC_Fence, &rover.g2.fence, update, 10, 100, 33),
SCHED_TASK(update_wheel_encoder, 50, 200, 36),
SCHED_TASK(update_compass, 10, 200, 39),
SCHED_TASK(update_logging1, 10, 200, 45),

2
Rover/failsafe.cpp

@ -149,6 +149,6 @@ void Rover::handle_battery_failsafe(const char* type_str, const int8_t action) @@ -149,6 +149,6 @@ void Rover::handle_battery_failsafe(const char* type_str, const int8_t action)
void Rover::afs_fs_check(void)
{
// perform AFS failsafe checks
g2.afs.check(g2.fence.get_breaches() != 0, failsafe.last_valid_rc_ms);
g2.afs.check(fence.get_breaches() != 0, failsafe.last_valid_rc_ms);
}
#endif

12
Rover/fence.cpp

@ -3,11 +3,12 @@ @@ -3,11 +3,12 @@
// fence_check - ask fence library to check for breaches and initiate the response
void Rover::fence_check()
{
#if AC_FENCE
uint8_t new_breaches; // the type of fence that has been breached
const uint8_t orig_breaches = g2.fence.get_breaches();
const uint8_t orig_breaches = fence.get_breaches();
// check for a breach
new_breaches = g2.fence.check();
new_breaches = fence.check();
// return immediately if motors are not armed
if (!arming.is_armed()) {
@ -17,10 +18,10 @@ void Rover::fence_check() @@ -17,10 +18,10 @@ void Rover::fence_check()
// if there is a new breach take action
if (new_breaches) {
// if the user wants some kind of response and motors are armed
if (g2.fence.get_action() != Failsafe_Action_None) {
if (fence.get_action() != Failsafe_Action_None) {
// if within 100m of the fence, it will take the action specified by the FENCE_ACTION parameter
if (g2.fence.get_breach_distance(new_breaches) <= AC_FENCE_GIVE_UP_DISTANCE) {
switch (g2.fence.get_action()) {
if (fence.get_breach_distance(new_breaches) <= AC_FENCE_GIVE_UP_DISTANCE) {
switch (fence.get_action()) {
case Failsafe_Action_None:
break;
case Failsafe_Action_RTL:
@ -56,4 +57,5 @@ void Rover::fence_check() @@ -56,4 +57,5 @@ void Rover::fence_check()
AP::logger().Write_Error(LogErrorSubsystem::FAILSAFE_FENCE,
LogErrorCode::ERROR_RESOLVED);
}
#endif // AC_FENCE
}

6
Rover/mode_auto.cpp

@ -481,13 +481,15 @@ bool ModeAuto::start_command(const AP_Mission::Mission_Command& cmd) @@ -481,13 +481,15 @@ bool ModeAuto::start_command(const AP_Mission::Mission_Command& cmd)
break;
case MAV_CMD_DO_FENCE_ENABLE:
#if AC_FENCE
if (cmd.p1 == 0) { //disable
g2.fence.enable(false);
rover.fence.enable(false);
gcs().send_text(MAV_SEVERITY_INFO, "Fence Disabled");
} else { //enable fence
g2.fence.enable(true);
rover.fence.enable(true);
gcs().send_text(MAV_SEVERITY_INFO, "Fence Enabled");
}
#endif
break;
case MAV_CMD_DO_GUIDED_LIMITS:

6
Rover/system.cpp

@ -29,8 +29,6 @@ void Rover::init_ardupilot() @@ -29,8 +29,6 @@ void Rover::init_ardupilot()
g2.gripper.init();
#endif
g2.fence.init();
// initialise notify system
notify.init();
notify_mode(control_mode);
@ -222,10 +220,12 @@ bool Rover::set_mode(Mode &new_mode, ModeReason reason) @@ -222,10 +220,12 @@ bool Rover::set_mode(Mode &new_mode, ModeReason reason)
control_mode = &new_mode;
#if AC_FENCE
// pilot requested flight mode change during a fence breach indicates pilot is attempting to manually recover
// this flight mode change could be automatic (i.e. fence, battery, GPS or GCS failsafe)
// but it should be harmless to disable the fence temporarily in these situations as well
g2.fence.manual_recovery_start();
fence.manual_recovery_start();
#endif
#if CAMERA == ENABLED
camera.set_is_auto_mode(control_mode->mode_number() == Mode::Number::AUTO);

1
Rover/wscript

@ -17,7 +17,6 @@ def build(bld): @@ -17,7 +17,6 @@ def build(bld):
'AP_AdvancedFailsafe',
'AP_WheelEncoder',
'AP_SmartRTL',
'AC_Fence',
'AC_AttitudeControl',
'AP_LTM_Telem',
'AP_Devo_Telem',

Loading…
Cancel
Save