Skip to content

Commit

Permalink
FlightTasksAuto/Line: replace BlockParams with module params
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Mannhart committed Apr 11, 2018
1 parent 170f6b2 commit aaf1648
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/lib/FlightTasks/FlightTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int FlightTasks::switchTask(FlightTaskIndex new_task_index)
break;

case FlightTaskIndex::AutoLine:
_current_task = new (&_task_union.autoLine) FlightTaskAutoLine(this, "ALN");
_current_task = new (&_task_union.autoLine) FlightTaskAutoLine();
break;

default:
Expand Down
5 changes: 0 additions & 5 deletions src/lib/FlightTasks/tasks/FlightTaskAuto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@

using namespace matrix;

FlightTaskAuto::FlightTaskAuto(control::SuperBlock *parent, const char *name) :
FlightTask(parent, name),
_mc_cruise_default(this, "MPC_XY_CRUISE", false)
{}

bool FlightTaskAuto::initializeSubscriptions(SubscriptionArray &subscription_array)
{
if (!FlightTask::initializeSubscriptions(subscription_array)) {
Expand Down
9 changes: 6 additions & 3 deletions src/lib/FlightTasks/tasks/FlightTaskAuto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ enum class WaypointType : int {
class FlightTaskAuto : public FlightTask
{
public:
FlightTaskAuto(control::SuperBlock *parent, const char *name);
FlightTaskAuto() = default;

virtual ~FlightTaskAuto() = default;
bool initializeSubscriptions(SubscriptionArray &subscription_array) override;
Expand All @@ -78,9 +78,12 @@ class FlightTaskAuto : public FlightTask
WaypointType _type{WaypointType::idle}; /**< Type of current target triplet. */

private:
control::BlockParamFloat _mc_cruise_default; /**< Default mc cruise speed.*/
map_projection_reference_s _reference; /**< Reference frame from global to local. */
uORB::Subscription<position_setpoint_triplet_s> *_sub_triplet_setpoint{nullptr};

DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTask, (ParamFloat<px4::params::MPC_XY_CRUISE>) _mc_cruise_default); /**< Default mc cruise speed.*/

map_projection_reference_s _reference; /**< Reference frame from global to local. */

map_projection_reference_s _reference_position{}; /**< Structure used to project lat/lon setpoint into local frame. */
float _reference_altitude = 0.0f; /**< Altitude relative to ground. */
hrt_abstime _time_stamp_reference = 0; /**< time stamp when last reference update occured. */
Expand Down
14 changes: 0 additions & 14 deletions src/lib/FlightTasks/tasks/FlightTaskAutoLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,6 @@ using namespace matrix;
#define SIGMA_SINGLE_OP 0.000001f
#define SIGMA_NORM 0.001f

FlightTaskAutoLine::FlightTaskAutoLine(control::SuperBlock *parent, const char *name) :
FlightTaskAuto(parent, name),
_land_speed(parent, "MPC_LAND_SPEED", false),
_vel_max_up(parent, "MPC_Z_VEL_MAX_UP", false),
_vel_max_down(parent, "MPC_Z_VEL_MAX_DN", false),
_acc_max_xy(parent, "MPC_ACC_HOR_MAX", false),
_acc_xy(parent, "MPC_ACC_HOR", false),
_acc_max_up(parent, "MPC_ACC_UP_MAX", false),
_acc_max_down(parent, "MPC_ACC_DOWN_MAX", false),
_cruise_speed_90(parent, "MPC_CRUISE_90", false),
_nav_rad(parent, "NAV_ACC_RAD", false),
_mis_yaw_error(parent, "MIS_YAW_ERR", false)
{}

bool FlightTaskAutoLine::activate()
{
bool ret = FlightTaskAuto::activate();
Expand Down
26 changes: 13 additions & 13 deletions src/lib/FlightTasks/tasks/FlightTaskAutoLine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
class FlightTaskAutoLine : public FlightTaskAuto
{
public:
FlightTaskAutoLine(control::SuperBlock *parent, const char *name);
FlightTaskAutoLine() = default;
virtual ~FlightTaskAutoLine() = default;
bool activate() override;
bool update() override;
Expand All @@ -64,18 +64,18 @@ class FlightTaskAutoLine : public FlightTaskAuto
};
State _current_state{State::none};

control::BlockParamFloat _land_speed; /**< Downward speed during landing. */
control::BlockParamFloat _vel_max_up; /**< Maximum upward velocity. */
control::BlockParamFloat _vel_max_down; /**< Maximum downward velocity. */
control::BlockParamFloat _acc_max_xy; /**< Maximum acceleration in hover. */
control::BlockParamFloat _acc_xy; /**< Maximum acceleration from hover to fast forward flight. */
control::BlockParamFloat _acc_max_up; /**< Max acceleration up. */
control::BlockParamFloat _acc_max_down; /**< Max acceleration down. */
control::BlockParamFloat _cruise_speed_90; /**< Speed when angle is 90 degrees between prev-current/current-next. */

/* None-position control params */
control::BlockParamFloat _nav_rad; /**< Radius that is used by navigator that defines when to update triplets */
control::BlockParamFloat _mis_yaw_error; /**< Yaw threshold during mission to consider yaw as accepted */
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTaskAuto,
(ParamFloat<px4::params::MPC_LAND_SPEED>) _land_speed,
(ParamFloat<px4::params::MPC_Z_VEL_MAX_UP>) _vel_max_up,
(ParamFloat<px4::params::MPC_Z_VEL_MAX_DN>) _vel_max_down,
(ParamFloat<px4::params::MPC_ACC_HOR_MAX>) _acc_max_xy,
(ParamFloat<px4::params::MPC_ACC_HOR>) _acc_xy,
(ParamFloat<px4::params::MPC_ACC_UP_MAX>) _acc_max_up,
(ParamFloat<px4::params::MPC_ACC_DOWN_MAX>) _acc_max_down,
(ParamFloat<px4::params::MPC_CRUISE_90>) _cruise_speed_90,
(ParamFloat<px4::params::NAV_ACC_RAD>) _nav_rad,
(ParamFloat<px4::params::MIS_YAW_ERR>) _mis_yaw_error
)

void _generateIdleSetpoints();
void _generateLandSetpoints();
Expand Down

0 comments on commit aaf1648

Please sign in to comment.