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

add parachute-unavailable code #26128

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
2 changes: 1 addition & 1 deletion ArduCopter/Copter.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class Copter : public AP_Vehicle {
#endif

// Parachute release
#if PARACHUTE == ENABLED
#if PARACHUTE == ENABLED || AP_PARACHUTE_UNAVAILABLE_ENABLED
AP_Parachute parachute;
#endif

Expand Down
2 changes: 1 addition & 1 deletion ArduCopter/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ const AP_Param::Info Copter::var_info[] = {
GOBJECT(relay, "RELAY", AP_Relay),
#endif

#if PARACHUTE == ENABLED
#if PARACHUTE == ENABLED || AP_PARACHUTE_UNAVAILABLE_ENABLED
// @Group: CHUTE_
// @Path: ../libraries/AP_Parachute/AP_Parachute.cpp
GOBJECT(parachute, "CHUTE_", AP_Parachute),
Expand Down
4 changes: 4 additions & 0 deletions ArduCopter/land_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ void Copter::update_land_and_crash_detectors()
#if PARACHUTE == ENABLED
// check parachute
parachute_check();
#elif AP_PARACHUTE_UNAVAILABLE_ENABLED
if (AP::parachute()->mistakenly_enabled() && !motors->armed()) {
AP_BoardConfig::config_error("CHUTE_ENABLED=1 but not compiled in");
}
#endif

crash_check();
Expand Down
2 changes: 1 addition & 1 deletion ArduPlane/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ const AP_Param::Info Plane::var_info[] = {
GOBJECT(relay, "RELAY", AP_Relay),
#endif

#if PARACHUTE == ENABLED
#if PARACHUTE == ENABLED || AP_PARACHUTE_UNAVAILABLE_ENABLED
// @Group: CHUTE_
// @Path: ../libraries/AP_Parachute/AP_Parachute.cpp
GOBJECT(parachute, "CHUTE_", AP_Parachute),
Expand Down
2 changes: 1 addition & 1 deletion ArduPlane/Plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class Plane : public AP_Vehicle {
FUNCTOR_BIND_MEMBER(&Plane::exit_mission_callback, void)};


#if PARACHUTE == ENABLED
#if PARACHUTE == ENABLED || AP_PARACHUTE_UNAVAILABLE_ENABLED
AP_Parachute parachute;
#endif

Expand Down
4 changes: 4 additions & 0 deletions ArduPlane/parachute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ void Plane::parachute_check()
#if PARACHUTE == ENABLED
parachute.update();
parachute.check_sink_rate();
#elif AP_PARACHUTE_UNAVAILABLE_ENABLED
if (AP::parachute()->mistakenly_enabled() && !AP::arming().is_armed()) {
AP_BoardConfig::config_error("CHUTE_ENABLED=1 but not compiled in");
}
#endif
}

Expand Down
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/BETAFPV-F405/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,7 @@ define HAL_FRAME_TYPE_DEFAULT 12
AUTOBUILD_TARGETS Copter

include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/BeastF7/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,8 @@ define STM32_PWM_USE_ADVANCED TRUE
# save some flash
include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

define DEFAULT_NTF_LED_TYPES 257
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/BeastF7v2/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ define HAL_BARO_ALLOW_INIT_NO_BARO 1
# save some flash
include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

define DEFAULT_NTF_LED_TYPES 257
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/F35Lightning/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,7 @@ define HAL_DEFAULT_INS_FAST_SAMPLE 1
# no space for bootloader in firmware image:
include ../include/minimize_fpv_osd.inc
include ../include/no_bootloader_DFU.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1
6 changes: 6 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/FlywooF405Pro/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,10 @@ define HAL_DEFAULT_INS_FAST_SAMPLE 3
define HAL_FRAME_TYPE_DEFAULT 12

include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

AUTOBUILD_TARGETS Copter

4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/FlywooF405S-AIO/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,8 @@ define DEFAULT_NTF_LED_TYPES 257
# save some flash space
include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

AUTOBUILD_TARGETS Copter
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/HEEWING-F405/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,8 @@ define AP_BATTMON_SMBUS_ENABLE 0
include ../include/minimize_fpv_osd.inc
include ../include/save_some_flash.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

AUTOBUILD_TARGETS Plane
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/KakuteF4/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,8 @@ ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin
# minimal drivers to reduce flash usage
include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

define DEFAULT_NTF_LED_TYPES 256
3 changes: 3 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/KakuteF4Mini/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ define HAL_MOUNT_ENABLED 0

undef DEFAULT_NTF_LED_TYPES
define DEFAULT_NTF_LED_TYPES 257

# KakuteF4Mini has never had a parachute, so we don't need to warn about it
undef AP_PARACHUTE_UNAVAILABLE_ENABLED
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/MambaF405US-I2C/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,7 @@ ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin
# no space for bootloader:
include ../include/minimize_fpv_osd.inc
include ../include/no_bootloader_DFU.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/MambaF405v2/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,7 @@ DMA_PRIORITY TIM2* TIM3*

# minimal drivers to reduce flash usage
include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/OmnibusNanoV6/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,7 @@ define HAL_MOUNT_ENABLED 0

# minimal drivers to reduce flash usage
include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/SpeedyBeeF405Mini/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,9 @@ define HAL_DEFAULT_INS_FAST_SAMPLE 3
# Motor order implies Betaflight/X for standard ESCs
define HAL_FRAME_TYPE_DEFAULT 12

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

include ../include/minimize_fpv_osd.inc
AUTOBUILD_TARGETS Copter
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/omnibusf4v6/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,9 @@ define OSD_ENABLED 1
#font for the osd
ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

# minimal drivers to reduce flash usage
include ../include/minimize_fpv_osd.inc
5 changes: 5 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/revo-mini-i2c/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,10 @@ define HAL_GYROFFT_ENABLED 0

# bootloader embedding / bootloader flashing not available
define AP_BOOTLOADER_FLASHING_ENABLED 0

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

include ../include/minimize_fpv_osd.inc

4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/revo-mini/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@ define HAL_LOGGING_DATAFLASH_ENABLED 1

define HAL_GYROFFT_ENABLED 0

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

include ../include/minimize_fpv_osd.inc
5 changes: 5 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/speedybeef4/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,10 @@ ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin
# minimal drivers to reduce flash usage
include ../include/minimize_fpv_osd.inc
include ../include/no_bootloader_DFU.inc

undef AP_BATTERY_SYNTHETIC_CURRENT_ENABLED
define AP_BATTERY_SYNTHETIC_CURRENT_ENABLED 0

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1
5 changes: 5 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/speedybeef4v3/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin
# minimal drivers to reduce flash usage
include ../include/minimize_fpv_osd.inc
include ../include/no_bootloader_DFU.inc

undef AP_BATTERY_SYNTHETIC_CURRENT_ENABLED
define AP_BATTERY_SYNTHETIC_CURRENT_ENABLED 0

define DEFAULT_NTF_LED_TYPES 257

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1
4 changes: 4 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/speedybeef4v4/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,8 @@ define HAL_OS_FATFS_IO 1
# minimal drivers to reduce flash usage
include ../include/minimize_fpv_osd.inc

# defines to transition minimize-fpv-osd boards to parachute-not-compiled-in:
define HAL_PARACHUTE_ENABLED 0
define AP_PARACHUTE_UNAVAILABLE_ENABLED 1

define DEFAULT_NTF_LED_TYPES 257
46 changes: 36 additions & 10 deletions libraries/AP_Parachute/AP_Parachute.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#include "AP_Parachute_config.h"

#if HAL_PARACHUTE_ENABLED || AP_PARACHUTE_UNAVAILABLE_ENABLED

#include "AP_Parachute.h"

#if HAL_PARACHUTE_ENABLED
/*
* This is not standard parameter conversion code; it is
* compatability code we are using to remove parachute support from
* 1MB boards without leaving users that *are* using parachutes on
* 1MB boards with a sneakily broken parachute system. We enable
* just enough of the parachute library to check if the enable
* parameter is set; if it is we throw a config error, making the
* vehicle non-flyable.
*/
// PARAMETER_CONVERSION - Added: Feb-2024

#include <AP_Relay/AP_Relay.h>
#include <AP_Math/AP_Math.h>
#include <RC_Channel/RC_Channel.h>
#include <SRV_Channel/SRV_Channel.h>
#include <AP_Notify/AP_Notify.h>
#include <AP_HAL/AP_HAL.h>
#include <AP_Logger/AP_Logger.h>
#include <GCS_MAVLink/GCS.h>
#include <AP_Param/AP_Param.h>

extern const AP_HAL::HAL& hal;

Expand All @@ -22,6 +28,7 @@ const AP_Param::GroupInfo AP_Parachute::var_info[] = {
// @User: Standard
AP_GROUPINFO_FLAGS("ENABLED", 0, AP_Parachute, _enabled, 0, AP_PARAM_FLAG_ENABLE),

#if HAL_PARACHUTE_ENABLED
// @Param: TYPE
// @DisplayName: Parachute release mechanism type (relay or servo)
// @Description: Parachute release mechanism type (relay number in versions prior to 4.5, or servo). Values 0-3 all are relay. Relay number used for release is set by RELAYx_FUNCTION in 4.5 or later.
Expand Down Expand Up @@ -81,10 +88,24 @@ const AP_Param::GroupInfo AP_Parachute::var_info[] = {
// @Bitmask: 0:hold open forever after release
// @User: Standard
AP_GROUPINFO("OPTIONS", 7, AP_Parachute, _options, 0),
#endif // HAL_PARACHUTE_ENABLED

AP_GROUPEND
};

#endif // HAL_PARACHUTE_ENABLED || AP_PARACHUTE_UNAVAILABLE_ENABLED

#if HAL_PARACHUTE_ENABLED

#include <AP_Relay/AP_Relay.h>
#include <AP_Math/AP_Math.h>
#include <RC_Channel/RC_Channel.h>
#include <SRV_Channel/SRV_Channel.h>
#include <AP_Notify/AP_Notify.h>
#include <AP_HAL/AP_HAL.h>
#include <AP_Logger/AP_Logger.h>
#include <GCS_MAVLink/GCS.h>

/// enabled - enable or disable parachute release
void AP_Parachute::enabled(bool on_off)
{
Expand Down Expand Up @@ -249,6 +270,10 @@ bool AP_Parachute::get_legacy_relay_index(int8_t &index) const
}
#endif

#endif // HAL_PARACHUTE_ENABLED

#if HAL_PARACHUTE_ENABLED || AP_PARACHUTE_UNAVAILABLE_ENABLED

// singleton instance
AP_Parachute *AP_Parachute::_singleton;

Expand All @@ -260,4 +285,5 @@ AP_Parachute *parachute()
}

}
#endif // HAL_PARACHUTE_ENABLED

#endif // HAL_PARACHUTE_ENABLED || AP_PARACHUTE_UNAVAILABLE_ENABLED
51 changes: 44 additions & 7 deletions libraries/AP_Parachute/AP_Parachute.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
/// @brief Parachute release library
#pragma once

#include "AP_Parachute_config.h"

#if HAL_PARACHUTE_ENABLED

#include <AP_Param/AP_Param.h>
#include <AP_Common/AP_Common.h>

Expand All @@ -21,13 +25,6 @@

#define AP_PARACHUTE_CRITICAL_SINK_DEFAULT 0 // default critical sink speed in m/s to trigger emergency parachute

#ifndef HAL_PARACHUTE_ENABLED
// default to parachute enabled to match previous configs
#define HAL_PARACHUTE_ENABLED 1
#endif

#if HAL_PARACHUTE_ENABLED

/// @class AP_Parachute
/// @brief Class managing the release of a parachute
class AP_Parachute {
Expand Down Expand Up @@ -124,4 +121,44 @@ namespace AP {
AP_Parachute *parachute();
};

#elif AP_PARACHUTE_UNAVAILABLE_ENABLED

/*
* minimal class definition for a shim AP_Parachute. just enough to be
* able to interpret the "enabled" parameter.
*/

#include <AP_Param/AP_Param.h>
class AP_Parachute {
public:
/// Constructor
AP_Parachute()
{
_singleton = this;
AP_Param::setup_object_defaults(this, var_info);

AP_Param::setup_object_defaults(this, var_info);
}

/* Do not allow copies */
CLASS_NO_COPY(AP_Parachute);

AP_Int8 _enabled; // 1 if parachute release is enabled

static const struct AP_Param::GroupInfo var_info[];

/// returns true if parachute is enabled but compiled out of the code
bool mistakenly_enabled() const { return _enabled != 0; }

// get singleton instance
static AP_Parachute *get_singleton() { return _singleton; }

private:
static AP_Parachute *_singleton;
};

namespace AP {
AP_Parachute *parachute();
};

#endif // HAL_PARACHUTE_ENABLED
12 changes: 12 additions & 0 deletions libraries/AP_Parachute/AP_Parachute_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <AP_HAL/AP_HAL_Boards.h>

#ifndef HAL_PARACHUTE_ENABLED
// default to parachute enabled to match previous configs
#define HAL_PARACHUTE_ENABLED 1
#endif

#ifndef AP_PARACHUTE_UNAVAILABLE_ENABLED
#define AP_PARACHUTE_UNAVAILABLE_ENABLED 0
#endif
Loading