mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 21:43:33 +08:00
Airmode - Add airmode parameter for multicopter mixer
This commit is contained in:
@@ -218,6 +218,13 @@ public:
|
||||
*/
|
||||
virtual void set_thrust_factor(float val) {}
|
||||
|
||||
/**
|
||||
* @brief Set airmode. Airmode allows the mixer to increase the total thrust in order to unsaturate the motors.
|
||||
*
|
||||
* @param[in] airmode Dis/-activate airmode by setting it to false/true
|
||||
*/
|
||||
virtual void set_airmode(bool airmode) {};
|
||||
|
||||
protected:
|
||||
/** client-supplied callback used when fetching control values */
|
||||
ControlCallback _control_cb;
|
||||
@@ -403,6 +410,8 @@ public:
|
||||
*/
|
||||
virtual void set_thrust_factor(float val);
|
||||
|
||||
virtual void set_airmode(bool airmode);
|
||||
|
||||
private:
|
||||
Mixer *_first; /**< linked list of mixers */
|
||||
|
||||
@@ -650,6 +659,8 @@ public:
|
||||
*/
|
||||
virtual void set_thrust_factor(float val) {_thrust_factor = val;}
|
||||
|
||||
virtual void set_airmode(bool airmode);
|
||||
|
||||
union saturation_status {
|
||||
struct {
|
||||
uint16_t valid : 1; // 0 - true when the saturation status is used
|
||||
@@ -675,6 +686,8 @@ private:
|
||||
float _delta_out_max;
|
||||
float _thrust_factor;
|
||||
|
||||
bool _airmode;
|
||||
|
||||
void update_saturation_status(unsigned index, bool clipping_high, bool clipping_low);
|
||||
saturation_status _saturation_status;
|
||||
|
||||
|
||||
@@ -185,7 +185,17 @@ MixerGroup::set_thrust_factor(float val)
|
||||
mixer->set_thrust_factor(val);
|
||||
mixer = mixer->_next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MixerGroup::set_airmode(bool airmode)
|
||||
{
|
||||
Mixer *mixer = _first;
|
||||
|
||||
while (mixer != nullptr) {
|
||||
mixer->set_airmode(airmode);
|
||||
mixer = mixer->_next;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t
|
||||
|
||||
@@ -84,6 +84,7 @@ MultirotorMixer::MultirotorMixer(ControlCallback control_cb,
|
||||
_idle_speed(-1.0f + idle_speed * 2.0f), /* shift to output range here to avoid runtime calculation */
|
||||
_delta_out_max(0.0f),
|
||||
_thrust_factor(0.0f),
|
||||
_airmode(false),
|
||||
_rotor_count(_config_rotor_count[(MultirotorGeometryUnderlyingType)geometry]),
|
||||
_rotors(_config_index[(MultirotorGeometryUnderlyingType)geometry]),
|
||||
_outputs_prev(new float[_rotor_count])
|
||||
@@ -224,6 +225,9 @@ MultirotorMixer::mix(float *outputs, unsigned space)
|
||||
boost = 1.0f - ((max_out - thrust) * roll_pitch_scale + thrust);
|
||||
}
|
||||
|
||||
if (!_airmode) {
|
||||
boost = math::min(boost, 0.0f); // Disable positive boosting if not in air-mode
|
||||
}
|
||||
|
||||
// capture saturation
|
||||
if (min_out < 0.0f) {
|
||||
@@ -425,6 +429,12 @@ MultirotorMixer::update_saturation_status(unsigned index, bool clipping_high, bo
|
||||
_saturation_status.flags.valid = true;
|
||||
}
|
||||
|
||||
void
|
||||
MultirotorMixer::set_airmode(bool airmode)
|
||||
{
|
||||
_airmode = airmode;
|
||||
}
|
||||
|
||||
void
|
||||
MultirotorMixer::groups_required(uint32_t &groups)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user