mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-18 00:08:22 +08:00
FlightTaskManualAltitude: use StickTiltXY for horizontal stick mapping
This commit is contained in:
@@ -240,7 +240,7 @@ void FlightTaskAuto::_prepareLandSetpoints()
|
||||
// User input assisted landing
|
||||
if (_param_mpc_land_rc_help.get() && _sticks.checkAndUpdateStickInputs()) {
|
||||
// Stick full up -1 -> stop, stick full down 1 -> double the speed
|
||||
vertical_speed *= (1 + _sticks.getPositionExpo()(2));
|
||||
vertical_speed *= (1 - _sticks.getThrottleZeroCenteredExpo());
|
||||
|
||||
// Only set a yawrate setpoint if weather vane is not active or the yaw stick is out of its dead-zone
|
||||
if (!_weathervane.isActive() || fabsf(_sticks.getYawExpo()) > FLT_EPSILON) {
|
||||
@@ -248,7 +248,7 @@ void FlightTaskAuto::_prepareLandSetpoints()
|
||||
_deltatime);
|
||||
}
|
||||
|
||||
_stick_acceleration_xy.generateSetpoints(_sticks.getPositionExpo().slice<2, 1>(0, 0), _yaw, _land_heading, _position,
|
||||
_stick_acceleration_xy.generateSetpoints(_sticks.getPitchRollExpo(), _yaw, _land_heading, _position,
|
||||
_velocity_setpoint_feedback.xy(), _deltatime);
|
||||
_stick_acceleration_xy.getSetpoints(_land_position, _velocity_setpoint, _acceleration_setpoint);
|
||||
|
||||
|
||||
+1
-2
@@ -66,8 +66,7 @@ bool FlightTaskManualAcceleration::update()
|
||||
_stick_yaw.generateYawSetpoint(_yawspeed_setpoint, _yaw_setpoint, _sticks.getYawExpo(), _yaw, _is_yaw_good_for_control,
|
||||
_deltatime);
|
||||
|
||||
_stick_acceleration_xy.generateSetpoints(_sticks.getPositionExpo().slice<2, 1>(0, 0), _yaw, _yaw_setpoint,
|
||||
_position,
|
||||
_stick_acceleration_xy.generateSetpoints(_sticks.getPitchRollExpo(), _yaw, _yaw_setpoint, _position,
|
||||
_velocity_setpoint_feedback.xy(), _deltatime);
|
||||
_stick_acceleration_xy.getSetpoints(_position_setpoint, _velocity_setpoint, _acceleration_setpoint);
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ void FlightTaskManualAltitude::_updateAltitudeLock()
|
||||
float spd_xy = Vector2f(_velocity).length();
|
||||
|
||||
// Use presence of horizontal stick inputs as a transition criteria
|
||||
float stick_xy = Vector2f(_sticks.getPositionExpo().slice<2, 1>(0, 0)).length();
|
||||
float stick_xy = Vector2f(_sticks.getPitchRollExpo()).length();
|
||||
bool stick_input = stick_xy > 0.001f;
|
||||
|
||||
if (_terrain_hold) {
|
||||
@@ -326,25 +326,8 @@ void FlightTaskManualAltitude::_ekfResetHandlerHeading(float delta_psi)
|
||||
void FlightTaskManualAltitude::_updateSetpoints()
|
||||
{
|
||||
_updateHeadingSetpoints(); // get yaw setpoint
|
||||
|
||||
// Thrust in xy are extracted directly from stick inputs. A magnitude of
|
||||
// 1 means that maximum thrust along xy is demanded. A magnitude of 0 means no
|
||||
// thrust along xy is demanded. The maximum thrust along xy depends on the thrust
|
||||
// setpoint along z-direction, which is computed in PositionControl.cpp.
|
||||
|
||||
Vector2f sp(_sticks.getPosition().slice<2, 1>(0, 0));
|
||||
|
||||
_man_input_filter.setParameters(_deltatime, _param_mc_man_tilt_tau.get());
|
||||
_man_input_filter.update(sp);
|
||||
sp = _man_input_filter.getState();
|
||||
_rotateIntoHeadingFrame(sp);
|
||||
|
||||
if (sp.longerThan(1.0f)) {
|
||||
sp.normalize();
|
||||
}
|
||||
|
||||
_acceleration_setpoint.xy() = sp * tanf(math::radians(_param_mpc_man_tilt_max.get())) * CONSTANTS_ONE_G;
|
||||
|
||||
_acceleration_setpoint.xy() = _stick_tilt_xy.generateAccelerationSetpoints(_sticks.getPitchRoll(), _deltatime, _yaw,
|
||||
_yaw_setpoint);
|
||||
_updateAltitudeLock();
|
||||
_respectGroundSlowdown();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "FlightTask.hpp"
|
||||
#include <lib/mathlib/math/filter/AlphaFilter.hpp>
|
||||
#include "Sticks.hpp"
|
||||
#include "StickTiltXY.hpp"
|
||||
#include "StickYaw.hpp"
|
||||
#include <uORB/Subscription.hpp>
|
||||
|
||||
@@ -75,7 +76,9 @@ protected:
|
||||
void _updateAltitudeLock();
|
||||
|
||||
Sticks _sticks{this};
|
||||
StickTiltXY _stick_tilt_xy{this};
|
||||
StickYaw _stick_yaw{this};
|
||||
|
||||
bool _sticks_data_required = true; ///< let inherited task-class define if it depends on stick data
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTask,
|
||||
@@ -89,8 +92,7 @@ protected:
|
||||
(ParamFloat<px4::params::MPC_LAND_SPEED>)
|
||||
_param_mpc_land_speed, /**< desired downwards speed when approaching the ground */
|
||||
(ParamFloat<px4::params::MPC_TKO_SPEED>)
|
||||
_param_mpc_tko_speed, /**< desired upwards speed when still close to the ground */
|
||||
(ParamFloat<px4::params::MC_MAN_TILT_TAU>) _param_mc_man_tilt_tau
|
||||
_param_mpc_tko_speed /**< desired upwards speed when still close to the ground */
|
||||
)
|
||||
private:
|
||||
bool _isYawInput();
|
||||
@@ -138,6 +140,4 @@ private:
|
||||
* _dist_to_ground_lock.
|
||||
*/
|
||||
float _dist_to_ground_lock = NAN;
|
||||
|
||||
AlphaFilter<matrix::Vector2f> _man_input_filter;
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ void FlightTaskManualPosition::_scaleSticks()
|
||||
/* Use same scaling as for FlightTaskManualAltitude */
|
||||
FlightTaskManualAltitude::_scaleSticks();
|
||||
|
||||
Vector2f stick_xy = _sticks.getPositionExpo().slice<2, 1>(0, 0);
|
||||
Vector2f stick_xy = _sticks.getPitchRollExpo();
|
||||
|
||||
Sticks::limitStickUnitLengthXY(stick_xy);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user