mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 02:11:35 +08:00
mc_pos_control: migrate MPC_*_VEL_* parameter to acceleration scaling
Before #14212 the velocity control gains used in the multicopter position controller were defined as a scale between velocity error in one axis (or it's integral and derivative respectively) and the unit thrust vector. The problem with this is that the normalization of the unit thrust vector changes per vehicle or even vehicle configuration as 0 and 100% thrust get a different physical response. That's why the gains are now defined as scale between velocity error (integral/derivative) and the output acceleration in m/s².
This commit is contained in:
@@ -37,11 +37,12 @@
|
||||
|
||||
#include "Takeoff.hpp"
|
||||
#include <mathlib/mathlib.h>
|
||||
#include <lib/ecl/geo/geo.h>
|
||||
|
||||
void Takeoff::generateInitialRampValue(const float hover_thrust, float velocity_p_gain)
|
||||
void Takeoff::generateInitialRampValue(float velocity_p_gain)
|
||||
{
|
||||
velocity_p_gain = math::max(velocity_p_gain, 0.01f);
|
||||
_takeoff_ramp_vz_init = -hover_thrust / velocity_p_gain;
|
||||
_takeoff_ramp_vz_init = -CONSTANTS_ONE_G / velocity_p_gain;
|
||||
}
|
||||
|
||||
void Takeoff::updateTakeoffState(const bool armed, const bool landed, const bool want_takeoff,
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
* @param hover_thrust normalized thrsut value with which the vehicle hovers
|
||||
* @param velocity_p_gain proportional gain of the velocity controller to calculate the thrust
|
||||
*/
|
||||
void generateInitialRampValue(const float hover_thrust, const float velocity_p_gain);
|
||||
void generateInitialRampValue(const float velocity_p_gain);
|
||||
|
||||
/**
|
||||
* Update the state for the takeoff.
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <Takeoff.hpp>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <lib/ecl/geo/geo.h>
|
||||
|
||||
TEST(TakeoffTest, Initialization)
|
||||
{
|
||||
@@ -46,7 +47,7 @@ TEST(TakeoffTest, RegularTakeoffRamp)
|
||||
Takeoff takeoff;
|
||||
takeoff.setSpoolupTime(1.f);
|
||||
takeoff.setTakeoffRampTime(2.0);
|
||||
takeoff.generateInitialRampValue(.5f, 1.f);
|
||||
takeoff.generateInitialRampValue(CONSTANTS_ONE_G / 0.5f);
|
||||
|
||||
// disarmed, landed, don't want takeoff
|
||||
takeoff.updateTakeoffState(false, true, false, 1.f, false, 0);
|
||||
|
||||
Reference in New Issue
Block a user