Skip to content

Commit 11007dc

Browse files
sfuhrermahima-yoga
andauthored
FW auto launch: Add option to lock selected surfaces before/during launch (#25799)
* FWModeManager: add option to set flag for disabling actuators during launch Signed-off-by: Silvan <[email protected]> * Allocation: add option to each control surface to be locked for launch Signed-off-by: Silvan <[email protected]> * FW rate control: reset integral while control surfaces are locked Signed-off-by: Silvan <[email protected]> --------- Signed-off-by: Silvan <[email protected]> Co-authored-by: mahima-yoga <[email protected]>
1 parent fd4b958 commit 11007dc

File tree

12 files changed

+105
-4
lines changed

12 files changed

+105
-4
lines changed

docs/en/flight_modes_fw/takeoff.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ The vehicle always respects normal FW max/min throttle settings during takeoff (
8585
In _catapult/hand-launch mode_ the vehicle waits to detect launch (based on acceleration trigger).
8686
On launch it enables the motor(s) and climbs with the maximum climb rate [FW_T_CLMB_MAX](#FW_T_CLMB_MAX) while keeping the pitch setpoint above [FW_TKO_PITCH_MIN](#FW_TKO_PITCH_MIN).
8787
Once it reaches [MIS_TAKEOFF_ALT](#MIS_TAKEOFF_ALT) it will automatically switch to [Hold mode](../flight_modes_fw/hold.md) and loiter.
88+
It is possible to delay the activation of the motors and control surfaces separately, see parameters [FW_LAUN_MOT_DEL](#FW_LAUN_MOT_DEL), [FW_LAUN_CS_LK_DY](#FW_LAUN_CS_LK_DY) and [CA_CS_LAUN_LK](#CA_CS_LAUN_LK). The later is also exposed in the actuator configuration page under the advanced view.
8889

8990
All RC stick movement is ignored during the full takeoff sequence.
9091

@@ -104,7 +105,9 @@ The _launch detector_ is affected by the following parameters:
104105
| <a id="FW_LAUN_DETCN_ON"></a>[FW_LAUN_DETCN_ON](../advanced_config/parameter_reference.md#FW_LAUN_DETCN_ON) | Enable automatic launch detection. If disabled motors spin up on arming already |
105106
| <a id="FW_LAUN_AC_THLD"></a>[FW_LAUN_AC_THLD](../advanced_config/parameter_reference.md#FW_LAUN_AC_THLD) | Acceleration threshold (acceleration in body-forward direction must be above this value) |
106107
| <a id="FW_LAUN_AC_T"></a>[FW_LAUN_AC_T](../advanced_config/parameter_reference.md#FW_LAUN_AC_T) | Trigger time (acceleration must be above threshold for this amount of seconds) |
107-
| <a id="FW_LAUN_MOT_DEL"></a>[FW_LAUN_MOT_DEL](../advanced_config/parameter_reference.md#FW_LAUN_MOT_DEL) | Delay from launch detection to motor spin up |
108+
| <a id="FW_LAUN_MOT_DEL"></a>[FW_LAUN_MOT_DEL](../advanced_config/parameter_reference.md#FW_LAUN_MOT_DEL) | Delay from launch detection to motor spin up
109+
| <a id="FW_LAUN_CS_LK_DY"></a>[FW_LAUN_CS_LK_DY](../advanced_config/parameter_reference.md#FW_LAUN_CS_LK_DY) | Delay from launch detection to unlocking the control surfaces
110+
| <a id="CA_CS_LAUN_LK"></a>[CA_CS_LAUN_LK](../advanced_config/parameter_reference.md#CA_CS_LAUN_LK) | Bitmask to select which control surfaces are to be locked during launch |
108111

109112
## Runway Takeoff {#runway_launch}
110113

msg/LaunchDetectionStatus.msg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ uint8 STATE_LAUNCH_DETECTED_DISABLED_MOTOR = 1 # launch detected, but keep moto
77
uint8 STATE_FLYING = 2 # launch detected, use normal takeoff/flying configuration
88

99
uint8 launch_detection_state
10+
11+
bool selected_control_surface_disarmed # [-] flag indicating whether selected actuators should kept disarmed (have to be configured in control allocation)

src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ ActuatorEffectivenessControlSurfaces::ActuatorEffectivenessControlSurfaces(Modul
6363
_spoilers_setpoint_with_slewrate.setSlewRate(kSpoilersSlewRate);
6464

6565
_count_handle = param_find("CA_SV_CS_COUNT");
66+
_param_handle_ca_cs_laun_lk = param_find("CA_CS_LAUN_LK");
6667
updateParams();
6768
}
6869

@@ -112,6 +113,8 @@ void ActuatorEffectivenessControlSurfaces::updateParams()
112113
}
113114
}
114115

116+
param_get(_param_handle_ca_cs_laun_lk, &_param_ca_cs_laun_lk);
117+
115118
for (int i = 0; i < _count; i++) {
116119
param_get(_param_handles[i].type, (int32_t *)&_params[i].type);
117120

@@ -234,3 +237,14 @@ void ActuatorEffectivenessControlSurfaces::applySpoilers(float spoilers_control,
234237
actuator_sp(i + first_actuator_idx) += _spoilers_setpoint_with_slewrate.getState() * _params[i].scale_spoiler;
235238
}
236239
}
240+
241+
void ActuatorEffectivenessControlSurfaces::applyLaunchLock(int first_actuator_idx,
242+
ActuatorVector &actuator_sp)
243+
{
244+
for (int i = 0; i < _count; ++i) {
245+
246+
if (_param_ca_cs_laun_lk & (1u << i)) {
247+
actuator_sp(i + first_actuator_idx) = NAN;
248+
}
249+
}
250+
}

src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ActuatorEffectivenessControlSurfaces : public ModuleParams, public Actuato
9090

9191
void applyFlaps(float flaps_control, int first_actuator_idx, float dt, ActuatorVector &actuator_sp);
9292
void applySpoilers(float spoilers_control, int first_actuator_idx, float dt, ActuatorVector &actuator_sp);
93+
void applyLaunchLock(int first_actuator_idx, ActuatorVector &actuator_sp);
9394

9495
private:
9596
void updateParams() override;
@@ -104,9 +105,11 @@ class ActuatorEffectivenessControlSurfaces : public ModuleParams, public Actuato
104105
};
105106
ParamHandles _param_handles[MAX_COUNT];
106107
param_t _count_handle;
108+
param_t _param_handle_ca_cs_laun_lk;
107109

108110
Params _params[MAX_COUNT] {};
109111
int32_t _count{0};
112+
int32_t _param_ca_cs_laun_lk{0};
110113

111114
SlewRate<float> _flaps_setpoint_with_slewrate;
112115
SlewRate<float> _spoilers_setpoint_with_slewrate;

src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessFixedWing.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ void ActuatorEffectivenessFixedWing::updateSetpoint(const matrix::Vector<float,
6565
ActuatorVector &actuator_sp, const ActuatorVector &actuator_min, const ActuatorVector &actuator_max)
6666
{
6767
stopMaskedMotorsWithZeroThrust(_forwards_motors_mask, actuator_sp);
68+
69+
// disable selected control surfaces during launch
70+
launch_detection_status_s launch_detection_status;
71+
72+
if (_launch_detection_status_sub.copy(&launch_detection_status)) {
73+
if (launch_detection_status.selected_control_surface_disarmed
74+
&& hrt_elapsed_time(&launch_detection_status.timestamp) < 100_ms) {
75+
76+
_control_surfaces.applyLaunchLock(_first_control_surface_idx, actuator_sp);
77+
78+
}
79+
}
6880
}
6981

7082
void ActuatorEffectivenessFixedWing::allocateAuxilaryControls(const float dt, int matrix_index,

src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessFixedWing.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "ActuatorEffectivenessControlSurfaces.hpp"
3939

4040
#include <uORB/topics/normalized_unsigned_setpoint.h>
41+
#include <uORB/topics/launch_detection_status.h>
4142

4243
class ActuatorEffectivenessFixedWing : public ModuleParams, public ActuatorEffectiveness
4344
{
@@ -60,6 +61,7 @@ class ActuatorEffectivenessFixedWing : public ModuleParams, public ActuatorEffec
6061

6162
uORB::Subscription _flaps_setpoint_sub{ORB_ID(flaps_setpoint)};
6263
uORB::Subscription _spoilers_setpoint_sub{ORB_ID(spoilers_setpoint)};
64+
uORB::Subscription _launch_detection_status_sub{ORB_ID(launch_detection_status)};
6365

6466
int _first_control_surface_idx{0}; ///< applies to matrix 1
6567

src/modules/control_allocator/module.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,22 @@ parameters:
356356
instance_start: 0
357357
default: 0
358358

359+
CA_CS_LAUN_LK:
360+
description:
361+
short: Control surface launch lock enabled
362+
long: If actuator launch lock is enabled, this surface is kept at the disarmed value.
363+
type: bitmask
364+
bit:
365+
0: Control Surface 1
366+
1: Control Surface 2
367+
2: Control Surface 3
368+
3: Control Surface 4
369+
4: Control Surface 5
370+
5: Control Surface 6
371+
6: Control Surface 7
372+
7: Control Surface 8
373+
default: 0
374+
359375
# Tilts
360376
CA_SV_TL_COUNT:
361377
description:
@@ -659,7 +675,7 @@ mixer:
659675

660676
rules:
661677
- select_identifier: 'servo-type' # restrict torque based on servo type
662-
apply_identifiers: ['servo-torque-roll', 'servo-torque-pitch', 'servo-torque-yaw', 'servo-scale-flap', 'servo-scale-spoiler']
678+
apply_identifiers: ['servo-torque-roll', 'servo-torque-pitch', 'servo-torque-yaw', 'servo-scale-flap', 'servo-scale-spoiler', 'servo-launch-lock']
663679
items:
664680
# Convention: horizontal surfaces: up=positive, vertical: right=positive, mixed: up=positive.
665681
# By default the scale is set to 1/N, where N is the amount of actuators with an effect on
@@ -858,6 +874,12 @@ mixer:
858874
label: 'Spoiler Scale'
859875
advanced: true
860876
identifier: 'servo-scale-spoiler'
877+
- name: 'CA_CS_LAUN_LK'
878+
label: 'Launch Lock'
879+
advanced: true
880+
identifier: 'servo-launch-lock'
881+
index_offset: 0
882+
show_as: 'bitset'
861883

862884
2: # Standard VTOL
863885
title: 'Standard VTOL'

src/modules/fw_mode_manager/FixedWingModeManager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ FixedWingModeManager::control_auto_takeoff(const hrt_abstime &now, const float c
12071207
_takeoff_init_position = global_position;
12081208
_takeoff_ground_alt = _current_altitude;
12091209
_launch_current_yaw = _yaw;
1210+
_time_launch_detected = now;
12101211
}
12111212

12121213
const Vector2f launch_local_position = _global_local_proj_ref.project(_takeoff_init_position(0),
@@ -1282,6 +1283,9 @@ FixedWingModeManager::control_auto_takeoff(const hrt_abstime &now, const float c
12821283
launch_detection_status_s launch_detection_status;
12831284
launch_detection_status.timestamp = now;
12841285
launch_detection_status.launch_detection_state = _launchDetector.getLaunchDetected();
1286+
launch_detection_status.selected_control_surface_disarmed =
1287+
hrt_elapsed_time(&_time_launch_detected) < _param_fw_laun_cs_lk_dy.get() * 1_s
1288+
|| _time_launch_detected == 0;
12851289
_launch_detection_status_pub.publish(launch_detection_status);
12861290
}
12871291

@@ -1377,6 +1381,7 @@ FixedWingModeManager::control_auto_takeoff_no_nav(const hrt_abstime &now, const
13771381
if (!_launch_detected && _launchDetector.getLaunchDetected() > launch_detection_status_s::STATE_WAITING_FOR_LAUNCH) {
13781382
_launch_detected = true;
13791383
_takeoff_ground_alt = _current_altitude;
1384+
_time_launch_detected = now;
13801385
}
13811386

13821387
/* Launch has been detected, hence we have to control the plane. */
@@ -1408,6 +1413,9 @@ FixedWingModeManager::control_auto_takeoff_no_nav(const hrt_abstime &now, const
14081413
launch_detection_status_s launch_detection_status;
14091414
launch_detection_status.timestamp = now;
14101415
launch_detection_status.launch_detection_state = _launchDetector.getLaunchDetected();
1416+
launch_detection_status.selected_control_surface_disarmed =
1417+
hrt_elapsed_time(&_time_launch_detected) < _param_fw_laun_cs_lk_dy.get() * 1_s
1418+
|| _time_launch_detected == 0;
14111419
_launch_detection_status_pub.publish(launch_detection_status);
14121420
}
14131421

@@ -2312,6 +2320,8 @@ FixedWingModeManager::reset_takeoff_state()
23122320

23132321
_launch_detected = false;
23142322

2323+
_time_launch_detected = 0;
2324+
23152325
_takeoff_ground_alt = _current_altitude;
23162326
}
23172327

src/modules/fw_mode_manager/FixedWingModeManager.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ class FixedWingModeManager final : public ModuleBase<FixedWingModeManager>, publ
298298
// true if a launch, specifically using the launch detector, has been detected
299299
bool _launch_detected{false};
300300

301+
// [us] time stamp of (runway/catapult) launch detection
302+
hrt_abstime _time_launch_detected{0};
303+
301304
// [deg] global position of the vehicle at the time launch is detected (using launch detector) or takeoff is started (runway)
302305
Vector2d _takeoff_init_position{0, 0};
303306

@@ -865,6 +868,10 @@ class FixedWingModeManager final : public ModuleBase<FixedWingModeManager>, publ
865868
(ParamFloat<px4::params::FW_GPSF_R>) _param_nav_gpsf_r,
866869
(ParamFloat<px4::params::FW_T_SPDWEIGHT>) _param_t_spdweight,
867870

871+
// Launch detection parameters
872+
(ParamBool<px4::params::FW_LAUN_DETCN_ON>) _param_fw_laun_detcn_on,
873+
(ParamFloat<px4::params::FW_LAUN_CS_LK_DY>) _param_fw_laun_cs_lk_dy,
874+
868875
// external parameters
869876
(ParamBool<px4::params::FW_USE_AIRSPD>) _param_fw_use_airspd,
870877
(ParamFloat<px4::params::NAV_LOITER_RAD>) _param_nav_loiter_rad,
@@ -881,7 +888,6 @@ class FixedWingModeManager final : public ModuleBase<FixedWingModeManager>, publ
881888
(ParamInt<px4::params::FW_LND_ABORT>) _param_fw_lnd_abort,
882889
(ParamFloat<px4::params::FW_TKO_AIRSPD>) _param_fw_tko_airspd,
883890
(ParamFloat<px4::params::RWTO_PSP>) _param_rwto_psp,
884-
(ParamBool<px4::params::FW_LAUN_DETCN_ON>) _param_fw_laun_detcn_on,
885891
(ParamFloat<px4::params::FW_AIRSPD_MAX>) _param_fw_airspd_max,
886892
(ParamFloat<px4::params::FW_AIRSPD_MIN>) _param_fw_airspd_min,
887893
(ParamFloat<px4::params::FW_AIRSPD_TRIM>) _param_fw_airspd_trim,

src/modules/fw_mode_manager/fw_mode_manager_params.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,21 @@ PARAM_DEFINE_INT32(FW_LND_ABORT, 3);
580580
*/
581581
PARAM_DEFINE_INT32(FW_LAUN_DETCN_ON, 0);
582582

583+
/**
584+
* Control surface launch delay
585+
*
586+
* Locks control surfaces during pre-launch (armed) and until this time since launch has passed.
587+
* Only affects control surfaces that have corresponding flag set, and not active for runway takeoff.
588+
* Set to 0 to disable any surface locking after arming.
589+
*
590+
* @unit s
591+
* @min 0.0
592+
* @decimal 1
593+
* @increment 0.1
594+
* @group FW Auto Takeoff
595+
*/
596+
PARAM_DEFINE_FLOAT(FW_LAUN_CS_LK_DY, 0.f);
597+
583598
/**
584599
* Flaps setting during take-off
585600
*

0 commit comments

Comments
 (0)