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

Acceleration based control/feed-forward #14212

Merged
merged 9 commits into from
Mar 30, 2020
3 changes: 0 additions & 3 deletions ROMFS/px4fmu_common/init.d-posix/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ then
param set MPC_XY_VEL_I 0.02
param set MPC_XY_VEL_D 0.016

param set MPC_JERK_MIN 10
param set MPC_JERK_MAX 20
param set MPC_ACC_HOR_MAX 3
param set MPC_SPOOLUP_TIME 0.5
param set MPC_TKO_RAMP_T 1

Expand Down
3 changes: 1 addition & 2 deletions ROMFS/px4fmu_common/init.d/airframes/13014_vtol_babyshark
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ then
param set MPC_ACC_HOR_MAX 2
param set MPC_ACC_UP_MAX 3
param set MC_AIRMODE 1
param set MPC_JERK_AUTO 8
param set MPC_JERK_AUTO 15
param set MPC_JERK_AUTO 4
param set MPC_LAND_SPEED 1
param set MPC_MAN_TILT_MAX 25
param set MPC_MAN_Y_MAX 40
Expand Down
2 changes: 1 addition & 1 deletion ROMFS/px4fmu_common/init.d/rc.vtol_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ set VEHICLE_TYPE vtol

if [ $AUTOCNF = yes ]
then

# to minimize cpu usage on older boards limit inner loop to 400 Hz
param set IMU_GYRO_RATEMAX 400

Expand All @@ -23,6 +22,7 @@ then
param set MPC_XY_CRUISE 3
param set MPC_XY_VEL_MAX 4
param set MPC_Z_VEL_MAX_DN 1.5
param set MPC_JERK_MAX 4.5

param set NAV_ACC_RAD 3

Expand Down
1 change: 0 additions & 1 deletion src/lib/flight_tasks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ list(APPEND flight_tasks_all
ManualPosition
ManualPositionSmooth
ManualPositionSmoothVel
Sport
AutoLineSmoothVel
AutoFollowMe
Offboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool FlightTaskAutoMapper::update()
// vehicle exits idle.

if (_type_previous == WaypointType::idle) {
_thrust_setpoint.setNaN();
_acceleration_setpoint.setNaN();
}

// during mission and reposition, raise the landing gears but only
Expand Down Expand Up @@ -122,7 +122,7 @@ void FlightTaskAutoMapper::_prepareIdleSetpoints()
// Send zero thrust setpoint
_position_setpoint.setNaN(); // Don't require any position/velocity setpoints
_velocity_setpoint.setNaN();
_thrust_setpoint.zero();
_acceleration_setpoint = Vector3f(0.f, 0.f, 100.f); // High downwards acceleration to make sure there's no thrust
}

void FlightTaskAutoMapper::_prepareLandSetpoints()
Expand Down
8 changes: 4 additions & 4 deletions src/lib/flight_tasks/tasks/Descend/FlightTaskDescend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool FlightTaskDescend::activate(vehicle_local_position_setpoint_s last_setpoint
{
bool ret = FlightTask::activate(last_setpoint);
// stay level to minimize horizontal drift
_thrust_setpoint = matrix::Vector3f(0.0f, 0.0f, NAN);
_acceleration_setpoint = matrix::Vector3f(0.f, 0.f, NAN);
// keep heading
_yaw_setpoint = _yaw;
return ret;
Expand All @@ -51,12 +51,12 @@ bool FlightTaskDescend::update()
if (PX4_ISFINITE(_velocity(2))) {
// land with landspeed
_velocity_setpoint(2) = _param_mpc_land_speed.get();
_thrust_setpoint(2) = NAN;
_acceleration_setpoint(2) = NAN;

} else {
// descend with constant thrust (crash landing)
// descend with constant acceleration (crash landing)
_velocity_setpoint(2) = NAN;
_thrust_setpoint(2) = -_param_mpc_thr_hover.get() * 0.7f;
_acceleration_setpoint(2) = .3f;
}

return true;
Expand Down
17 changes: 8 additions & 9 deletions src/lib/flight_tasks/tasks/Failsafe/FlightTaskFailsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,36 @@ bool FlightTaskFailsafe::activate(vehicle_local_position_setpoint_s last_setpoin
bool ret = FlightTask::activate(last_setpoint);
_position_setpoint = _position;
_velocity_setpoint.zero();
_thrust_setpoint = matrix::Vector3f(0.0f, 0.0f, -_param_mpc_thr_hover.get() * 0.6f);
_acceleration_setpoint = matrix::Vector3f(0.f, 0.f, .3f);
_yaw_setpoint = _yaw;
_yawspeed_setpoint = 0.0f;
_yawspeed_setpoint = 0.f;
return ret;
}

bool FlightTaskFailsafe::update()
{
if (PX4_ISFINITE(_position(0)) && PX4_ISFINITE(_position(1))) {
// stay at current position setpoint
_velocity_setpoint(0) = _velocity_setpoint(1) = 0.0f;
_thrust_setpoint(0) = _thrust_setpoint(1) = 0.0f;
_velocity_setpoint(0) = _velocity_setpoint(1) = 0.f;
_acceleration_setpoint(0) = _acceleration_setpoint(1) = 0.f;

} else if (PX4_ISFINITE(_velocity(0)) && PX4_ISFINITE(_velocity(1))) {
// don't move along xy
_position_setpoint(0) = _position_setpoint(1) = NAN;
_thrust_setpoint(0) = _thrust_setpoint(1) = NAN;
_acceleration_setpoint(0) = _acceleration_setpoint(1) = NAN;
}

if (PX4_ISFINITE(_position(2))) {
// stay at current altitude setpoint
_velocity_setpoint(2) = 0.0f;
_thrust_setpoint(2) = NAN;
_velocity_setpoint(2) = 0.f;
_acceleration_setpoint(2) = NAN;

} else if (PX4_ISFINITE(_velocity(2))) {
// land with landspeed
_velocity_setpoint(2) = _param_mpc_land_speed.get();
_position_setpoint(2) = NAN;
_thrust_setpoint(2) = NAN;
_acceleration_setpoint(2) = NAN;
}

return true;

}
4 changes: 1 addition & 3 deletions src/lib/flight_tasks/tasks/Failsafe/FlightTaskFailsafe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class FlightTaskFailsafe : public FlightTask

private:
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTask,
(ParamFloat<px4::params::MPC_LAND_SPEED>) _param_mpc_land_speed,
(ParamFloat<px4::params::MPC_THR_HOVER>)
_param_mpc_thr_hover /**< throttle value at which vehicle is at hover equilibrium */
(ParamFloat<px4::params::MPC_LAND_SPEED>) _param_mpc_land_speed
)
};
5 changes: 3 additions & 2 deletions src/lib/flight_tasks/tasks/FlightTask/FlightTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ const vehicle_local_position_setpoint_s FlightTask::getPositionSetpoint()

_acceleration_setpoint.copyTo(vehicle_local_position_setpoint.acceleration);
_jerk_setpoint.copyTo(vehicle_local_position_setpoint.jerk);
_thrust_setpoint.copyTo(vehicle_local_position_setpoint.thrust);
vehicle_local_position_setpoint.yaw = _yaw_setpoint;
vehicle_local_position_setpoint.yawspeed = _yawspeed_setpoint;

// deprecated, only kept for output logging
matrix::Vector3f(NAN, NAN, NAN).copyTo(vehicle_local_position_setpoint.thrust);

return vehicle_local_position_setpoint;
}

Expand All @@ -109,7 +111,6 @@ void FlightTask::_resetSetpoints()
_velocity_setpoint.setNaN();
_acceleration_setpoint.setNaN();
_jerk_setpoint.setNaN();
_thrust_setpoint.setNaN();
_yaw_setpoint = _yawspeed_setpoint = NAN;
}

Expand Down
10 changes: 6 additions & 4 deletions src/lib/flight_tasks/tasks/FlightTask/FlightTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ class FlightTask : public ModuleParams
virtual void setYawHandler(WeatherVane *ext_yaw_handler) {}

void updateVelocityControllerIO(const matrix::Vector3f &vel_sp,
const matrix::Vector3f &thrust_sp) {_velocity_setpoint_feedback = vel_sp; _thrust_setpoint_feedback = thrust_sp; }
const matrix::Vector3f &acc_sp)
{
_velocity_setpoint_feedback = vel_sp;
_acceleration_setpoint_feedback = acc_sp;
}

protected:
uORB::SubscriptionData<vehicle_local_position_s> _sub_vehicle_local_position{ORB_ID(vehicle_local_position)};
Expand Down Expand Up @@ -225,12 +229,10 @@ class FlightTask : public ModuleParams
matrix::Vector3f _velocity_setpoint;
matrix::Vector3f _acceleration_setpoint;
matrix::Vector3f _jerk_setpoint;
matrix::Vector3f _thrust_setpoint;
float _yaw_setpoint{};
float _yawspeed_setpoint{};

matrix::Vector3f _velocity_setpoint_feedback;
matrix::Vector3f _thrust_setpoint_feedback;
matrix::Vector3f _acceleration_setpoint_feedback;

/* Counters for estimator local position resets */
struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "FlightTaskManualAltitude.hpp"
#include <float.h>
#include <mathlib/mathlib.h>
#include <ecl/geo/geo.h>

using namespace matrix;

Expand All @@ -53,10 +54,10 @@ bool FlightTaskManualAltitude::activate(vehicle_local_position_setpoint_s last_s
{
bool ret = FlightTaskManual::activate(last_setpoint);
_yaw_setpoint = NAN;
_yawspeed_setpoint = 0.0f;
_thrust_setpoint = matrix::Vector3f(0.0f, 0.0f, NAN); // altitude is controlled from position/velocity
_yawspeed_setpoint = 0.f;
_acceleration_setpoint = Vector3f(0.f, 0.f, NAN); // altitude is controlled from position/velocity
_position_setpoint(2) = _position(2);
_velocity_setpoint(2) = 0.0f;
_velocity_setpoint(2) = 0.f;
_setDefaultConstraints();

_constraints.tilt = math::radians(_param_mpc_man_tilt_max.get());
Expand Down Expand Up @@ -348,7 +349,7 @@ void FlightTaskManualAltitude::_updateSetpoints()
sp.normalize();
}

_thrust_setpoint.xy() = sp;
_acceleration_setpoint.xy() = sp * tanf(math::radians(_param_mpc_man_tilt_max.get())) * CONSTANTS_ONE_G;

_updateAltitudeLock();
_respectGroundSlowdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ void FlightTaskManualPosition::_updateXYlock()
void FlightTaskManualPosition::_updateSetpoints()
{
FlightTaskManualAltitude::_updateSetpoints(); // needed to get yaw and setpoints in z-direction
_acceleration_setpoint.setNaN(); // don't use the horizontal setpoints from FlightTaskAltitude

_updateXYlock(); // check for position lock

Expand All @@ -177,8 +178,5 @@ void FlightTaskManualPosition::_updateSetpoints()
// vehicle is steady
_yawspeed_setpoint += _weathervane_yaw_handler->get_weathervane_yawrate();
}

}

_thrust_setpoint.setAll(NAN); // don't require any thrust setpoints
}
10 changes: 6 additions & 4 deletions src/lib/flight_tasks/tasks/Offboard/FlightTaskOffboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ bool FlightTaskOffboard::update()

// IDLE
if (_sub_triplet_setpoint.get().current.type == position_setpoint_s::SETPOINT_TYPE_IDLE) {
_thrust_setpoint.zero();
_position_setpoint.setNaN(); // Don't require any position/velocity setpoints
_velocity_setpoint.setNaN();
_acceleration_setpoint = Vector3f(0.f, 0.f, 100.f); // High downwards acceleration to make sure there's no thrust
return true;
}

Expand Down Expand Up @@ -228,9 +230,9 @@ bool FlightTaskOffboard::update()
// Acceleration
// Note: this is not supported yet and will be mapped to normalized thrust directly.
if (_sub_triplet_setpoint.get().current.acceleration_valid) {
_thrust_setpoint(0) = _sub_triplet_setpoint.get().current.a_x;
_thrust_setpoint(1) = _sub_triplet_setpoint.get().current.a_y;
_thrust_setpoint(2) = _sub_triplet_setpoint.get().current.a_z;
_acceleration_setpoint(0) = _sub_triplet_setpoint.get().current.a_x;
_acceleration_setpoint(1) = _sub_triplet_setpoint.get().current.a_y;
_acceleration_setpoint(2) = _sub_triplet_setpoint.get().current.a_z;
}

// use default conditions of upwards position or velocity to take off
Expand Down
43 changes: 0 additions & 43 deletions src/lib/flight_tasks/tasks/Sport/CMakeLists.txt

This file was deleted.

64 changes: 0 additions & 64 deletions src/lib/flight_tasks/tasks/Sport/FlightTaskSport.hpp

This file was deleted.

Loading