mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 21:43:33 +08:00
Navigator remove unnecessary calls to updateParams
- the SuperBlock already does this
This commit is contained in:
committed by
Lorenz Meier
parent
6227139df1
commit
25c7a03a8b
@@ -54,8 +54,6 @@
|
||||
#include "navigator.h"
|
||||
#include "datalinkloss.h"
|
||||
|
||||
#define DELAY_SIGMA 0.01f
|
||||
|
||||
DataLinkLoss::DataLinkLoss(Navigator *navigator, const char *name) :
|
||||
MissionBlock(navigator, name),
|
||||
_param_commsholdwaittime(this, "CH_T"),
|
||||
@@ -69,12 +67,6 @@ DataLinkLoss::DataLinkLoss(Navigator *navigator, const char *name) :
|
||||
_param_numberdatalinklosses(this, "N"),
|
||||
_param_skipcommshold(this, "CHSK"),
|
||||
_dll_state(DLL_STATE_NONE)
|
||||
{
|
||||
/* initial reset */
|
||||
on_inactive();
|
||||
}
|
||||
|
||||
DataLinkLoss::~DataLinkLoss()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -40,28 +40,21 @@
|
||||
#ifndef NAVIGATOR_DATALINKLOSS_H
|
||||
#define NAVIGATOR_DATALINKLOSS_H
|
||||
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
|
||||
#include <uORB/Subscription.hpp>
|
||||
|
||||
#include "navigator_mode.h"
|
||||
#include "mission_block.h"
|
||||
|
||||
class Navigator;
|
||||
|
||||
class DataLinkLoss : public MissionBlock
|
||||
class DataLinkLoss final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
DataLinkLoss(Navigator *navigator, const char *name);
|
||||
|
||||
~DataLinkLoss();
|
||||
~DataLinkLoss() = default;
|
||||
|
||||
virtual void on_inactive();
|
||||
|
||||
virtual void on_activation();
|
||||
|
||||
virtual void on_active();
|
||||
void on_inactive() override;
|
||||
void on_activation() override;
|
||||
void on_active() override;
|
||||
|
||||
private:
|
||||
/* Params */
|
||||
@@ -82,7 +75,7 @@ private:
|
||||
DLL_STATE_FLYTOAIRFIELDHOMEWP = 2,
|
||||
DLL_STATE_TERMINATE = 3,
|
||||
DLL_STATE_END = 4
|
||||
} _dll_state;
|
||||
} _dll_state{DLL_STATE_NONE};
|
||||
|
||||
/**
|
||||
* Set the DLL item
|
||||
|
||||
@@ -52,17 +52,9 @@
|
||||
#include "navigator.h"
|
||||
#include "enginefailure.h"
|
||||
|
||||
#define DELAY_SIGMA 0.01f
|
||||
|
||||
EngineFailure::EngineFailure(Navigator *navigator, const char *name) :
|
||||
MissionBlock(navigator, name),
|
||||
_ef_state(EF_STATE_NONE)
|
||||
{
|
||||
/* initial reset */
|
||||
on_inactive();
|
||||
}
|
||||
|
||||
EngineFailure::~EngineFailure()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -40,34 +40,26 @@
|
||||
#ifndef NAVIGATOR_ENGINEFAILURE_H
|
||||
#define NAVIGATOR_ENGINEFAILURE_H
|
||||
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
|
||||
#include <uORB/Subscription.hpp>
|
||||
|
||||
#include "navigator_mode.h"
|
||||
#include "mission_block.h"
|
||||
|
||||
class Navigator;
|
||||
|
||||
class EngineFailure : public MissionBlock
|
||||
class EngineFailure final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
EngineFailure(Navigator *navigator, const char *name);
|
||||
~EngineFailure() = default;
|
||||
|
||||
~EngineFailure();
|
||||
|
||||
virtual void on_inactive();
|
||||
|
||||
virtual void on_activation();
|
||||
|
||||
virtual void on_active();
|
||||
void on_inactive() override;
|
||||
void on_activation() override;
|
||||
void on_active() override;
|
||||
|
||||
private:
|
||||
enum EFState {
|
||||
EF_STATE_NONE = 0,
|
||||
EF_STATE_LOITERDOWN = 1,
|
||||
} _ef_state;
|
||||
} _ef_state{EF_STATE_NONE};
|
||||
|
||||
/**
|
||||
* Set the DLL item
|
||||
|
||||
@@ -60,28 +60,11 @@ constexpr float FollowTarget::_follow_position_matricies[4][9];
|
||||
|
||||
FollowTarget::FollowTarget(Navigator *navigator, const char *name) :
|
||||
MissionBlock(navigator, name),
|
||||
_navigator(navigator),
|
||||
_param_min_alt(this, "NAV_MIN_FT_HT", false),
|
||||
_param_tracking_dist(this, "NAV_FT_DST", false),
|
||||
_param_tracking_side(this, "NAV_FT_FS", false),
|
||||
_param_tracking_resp(this, "NAV_FT_RS", false),
|
||||
_param_yaw_auto_max(this, "MC_YAWRAUTO_MAX", false),
|
||||
_follow_target_state(SET_WAIT_FOR_TARGET_POSITION),
|
||||
_follow_target_position(FOLLOW_FROM_BEHIND),
|
||||
_follow_target_sub(-1),
|
||||
_step_time_in_ms(0.0f),
|
||||
_follow_offset(OFFSET_M),
|
||||
_target_updates(0),
|
||||
_last_update_time(0),
|
||||
_current_target_motion(),
|
||||
_previous_target_motion(),
|
||||
_yaw_rate(0.0F),
|
||||
_responsiveness(0.0F),
|
||||
_yaw_auto_max(0.0F),
|
||||
_yaw_angle(0.0F)
|
||||
_param_tracking_resp(this, "NAV_FT_RS", false)
|
||||
{
|
||||
_current_target_motion = {};
|
||||
_previous_target_motion = {};
|
||||
_current_vel.zero();
|
||||
_step_vel.zero();
|
||||
_est_target_vel.zero();
|
||||
@@ -90,10 +73,6 @@ FollowTarget::FollowTarget(Navigator *navigator, const char *name) :
|
||||
_target_position_delta.zero();
|
||||
}
|
||||
|
||||
FollowTarget::~FollowTarget()
|
||||
{
|
||||
}
|
||||
|
||||
void FollowTarget::on_inactive()
|
||||
{
|
||||
reset_target_validity();
|
||||
@@ -105,8 +84,6 @@ void FollowTarget::on_activation()
|
||||
|
||||
_responsiveness = math::constrain((float) _param_tracking_resp.get(), .1F, 1.0F);
|
||||
|
||||
_yaw_auto_max = math::radians(_param_yaw_auto_max.get());
|
||||
|
||||
_follow_target_position = _param_tracking_side.get();
|
||||
|
||||
if ((_follow_target_position > FOLLOW_FROM_LEFT) || (_follow_target_position < FOLLOW_FROM_RIGHT)) {
|
||||
@@ -230,11 +207,7 @@ void FollowTarget::on_active()
|
||||
_current_target_motion.lat,
|
||||
_current_target_motion.lon);
|
||||
|
||||
_yaw_rate = (_yaw_angle - _navigator->get_global_position()->yaw) / (dt_ms / 1000.0F);
|
||||
|
||||
_yaw_rate = _wrap_pi(_yaw_rate);
|
||||
|
||||
_yaw_rate = math::constrain(_yaw_rate, -1.0F * _yaw_auto_max, _yaw_auto_max);
|
||||
_yaw_rate = _wrap_pi((_yaw_angle - _navigator->get_global_position()->yaw) / (dt_ms / 1000.0f));
|
||||
|
||||
} else {
|
||||
_yaw_angle = _yaw_rate = NAN;
|
||||
|
||||
@@ -40,24 +40,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
#include <lib/mathlib/math/Vector.hpp>
|
||||
#include <lib/mathlib/math/Matrix.hpp>
|
||||
#include <mathlib/mathlib.h>
|
||||
|
||||
#include "navigator_mode.h"
|
||||
#include "mission_block.h"
|
||||
|
||||
#include <uORB/topics/follow_target.h>
|
||||
|
||||
class FollowTarget : public MissionBlock
|
||||
class FollowTarget final : public MissionBlock
|
||||
{
|
||||
|
||||
public:
|
||||
FollowTarget(Navigator *navigator, const char *name);
|
||||
|
||||
FollowTarget(const FollowTarget &) = delete;
|
||||
FollowTarget &operator=(const FollowTarget &) = delete;
|
||||
|
||||
~FollowTarget();
|
||||
~FollowTarget() = default;
|
||||
|
||||
void on_inactive() override;
|
||||
void on_activation() override;
|
||||
@@ -112,23 +107,20 @@ private:
|
||||
}; // follow left side
|
||||
|
||||
|
||||
Navigator *_navigator;
|
||||
control::BlockParamFloat _param_min_alt;
|
||||
control::BlockParamFloat _param_tracking_dist;
|
||||
control::BlockParamInt _param_tracking_side;
|
||||
control::BlockParamFloat _param_tracking_resp;
|
||||
control::BlockParamFloat _param_yaw_auto_max;
|
||||
|
||||
FollowTargetState _follow_target_state{SET_WAIT_FOR_TARGET_POSITION};
|
||||
int _follow_target_position{FOLLOW_FROM_BEHIND};
|
||||
|
||||
FollowTargetState _follow_target_state;
|
||||
int _follow_target_position;
|
||||
int _follow_target_sub{-1};
|
||||
float _step_time_in_ms{0.0f};
|
||||
float _follow_offset{OFFSET_M};
|
||||
|
||||
int _follow_target_sub;
|
||||
float _step_time_in_ms;
|
||||
float _follow_offset;
|
||||
|
||||
uint64_t _target_updates;
|
||||
uint64_t _last_update_time;
|
||||
uint64_t _target_updates{0};
|
||||
uint64_t _last_update_time{0};
|
||||
|
||||
math::Vector<3> _current_vel;
|
||||
math::Vector<3> _step_vel;
|
||||
@@ -138,15 +130,14 @@ private:
|
||||
math::Vector<3> _target_position_delta;
|
||||
math::Vector<3> _filtered_target_position_delta;
|
||||
|
||||
follow_target_s _current_target_motion;
|
||||
follow_target_s _previous_target_motion;
|
||||
float _yaw_rate;
|
||||
float _responsiveness;
|
||||
float _yaw_auto_max;
|
||||
float _yaw_angle;
|
||||
follow_target_s _current_target_motion{};
|
||||
follow_target_s _previous_target_motion{};
|
||||
|
||||
float _yaw_rate{0.0f};
|
||||
float _responsiveness{0.0f};
|
||||
float _yaw_angle{0.0f};
|
||||
|
||||
// Mavlink defined motion reporting capabilities
|
||||
|
||||
enum {
|
||||
POS = 0,
|
||||
VEL = 1,
|
||||
@@ -155,6 +146,7 @@ private:
|
||||
};
|
||||
|
||||
math::Matrix<3, 3> _rot_matrix;
|
||||
|
||||
void track_target_position();
|
||||
void track_target_velocity();
|
||||
bool target_velocity_valid();
|
||||
|
||||
@@ -51,19 +51,13 @@
|
||||
using matrix::Eulerf;
|
||||
using matrix::Quatf;
|
||||
|
||||
static constexpr float DELAY_SIGMA = 0.01f;
|
||||
|
||||
GpsFailure::GpsFailure(Navigator *navigator, const char *name) :
|
||||
MissionBlock(navigator, name),
|
||||
_param_loitertime(this, "LT"),
|
||||
_param_openlooploiter_roll(this, "R"),
|
||||
_param_openlooploiter_pitch(this, "P"),
|
||||
_param_openlooploiter_thrust(this, "TR"),
|
||||
_gpsf_state(GPSF_STATE_NONE),
|
||||
_timestamp_activation(0)
|
||||
_param_openlooploiter_thrust(this, "TR")
|
||||
{
|
||||
/* initial reset */
|
||||
on_inactive();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -40,18 +40,11 @@
|
||||
#ifndef NAVIGATOR_GPSFAILURE_H
|
||||
#define NAVIGATOR_GPSFAILURE_H
|
||||
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/vehicle_attitude_setpoint.h>
|
||||
|
||||
#include "mission_block.h"
|
||||
|
||||
class Navigator;
|
||||
|
||||
class GpsFailure : public MissionBlock
|
||||
class GpsFailure final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
GpsFailure(Navigator *navigator, const char *name);
|
||||
|
||||
@@ -38,18 +38,6 @@
|
||||
* @author Andreas Antener <andreas@uaventure.com>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <systemlib/err.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/position_setpoint_triplet.h>
|
||||
|
||||
#include "land.h"
|
||||
#include "navigator.h"
|
||||
|
||||
@@ -58,15 +46,6 @@ Land::Land(Navigator *navigator, const char *name) :
|
||||
{
|
||||
}
|
||||
|
||||
Land::~Land()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Land::on_inactive()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Land::on_activation()
|
||||
{
|
||||
|
||||
@@ -41,25 +41,17 @@
|
||||
#ifndef NAVIGATOR_LAND_H
|
||||
#define NAVIGATOR_LAND_H
|
||||
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
|
||||
#include "navigator_mode.h"
|
||||
#include "mission_block.h"
|
||||
|
||||
class Land : public MissionBlock
|
||||
class Land final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
Land(Navigator *navigator, const char *name);
|
||||
~Land() = default;
|
||||
|
||||
~Land();
|
||||
|
||||
virtual void on_inactive();
|
||||
|
||||
virtual void on_activation();
|
||||
|
||||
virtual void on_active();
|
||||
|
||||
void on_activation() override;
|
||||
void on_active() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,31 +39,12 @@
|
||||
* @author Anton Babushkin <anton.babushkin@me.com>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <geo/geo.h>
|
||||
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <systemlib/err.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/position_setpoint_triplet.h>
|
||||
|
||||
#include "loiter.h"
|
||||
#include "navigator.h"
|
||||
|
||||
Loiter::Loiter(Navigator *navigator, const char *name) :
|
||||
MissionBlock(navigator, name),
|
||||
_param_yawmode(this, "MIS_YAWMODE", false),
|
||||
_loiter_pos_set(false)
|
||||
{
|
||||
}
|
||||
|
||||
Loiter::~Loiter()
|
||||
_param_yawmode(this, "MIS_YAWMODE", false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -41,25 +41,20 @@
|
||||
#ifndef NAVIGATOR_LOITER_H
|
||||
#define NAVIGATOR_LOITER_H
|
||||
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
|
||||
#include "navigator_mode.h"
|
||||
#include "mission_block.h"
|
||||
|
||||
class Loiter : public MissionBlock
|
||||
class Loiter final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
Loiter(Navigator *navigator, const char *name);
|
||||
~Loiter() = default;
|
||||
|
||||
~Loiter();
|
||||
|
||||
virtual void on_inactive();
|
||||
|
||||
virtual void on_activation();
|
||||
|
||||
virtual void on_active();
|
||||
void on_inactive() override;
|
||||
void on_activation() override;
|
||||
void on_active() override;
|
||||
|
||||
// TODO: share this with mission
|
||||
enum mission_yaw_mode {
|
||||
MISSION_YAWMODE_NONE = 0,
|
||||
MISSION_YAWMODE_FRONT_TO_WAYPOINT = 1,
|
||||
@@ -81,7 +76,8 @@ private:
|
||||
void set_loiter_position();
|
||||
|
||||
control::BlockParamInt _param_yawmode;
|
||||
bool _loiter_pos_set;
|
||||
|
||||
bool _loiter_pos_set{false};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,8 +51,6 @@
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <dataman/dataman.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <uORB/topics/home_position.h>
|
||||
@@ -66,7 +64,7 @@
|
||||
|
||||
class Navigator;
|
||||
|
||||
class Mission : public MissionBlock
|
||||
class Mission final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
Mission(Navigator *navigator, const char *name);
|
||||
|
||||
@@ -55,11 +55,7 @@
|
||||
#include <uORB/topics/vtol_vehicle_status.h>
|
||||
|
||||
MissionBlock::MissionBlock(Navigator *navigator, const char *name) :
|
||||
NavigatorMode(navigator, name),
|
||||
_param_yaw_timeout(this, "MIS_YAW_TMT", false),
|
||||
_param_yaw_err(this, "MIS_YAW_ERR", false),
|
||||
_param_back_trans_dec_mss(this, "VT_B_DEC_MSS", false),
|
||||
_param_reverse_delay(this, "VT_B_REV_DEL", false)
|
||||
NavigatorMode(navigator, name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -293,9 +289,11 @@ MissionBlock::is_mission_item_reached()
|
||||
float velocity = sqrtf(_navigator->get_local_position()->vx * _navigator->get_local_position()->vx +
|
||||
_navigator->get_local_position()->vy * _navigator->get_local_position()->vy);
|
||||
|
||||
if (_param_back_trans_dec_mss.get() > FLT_EPSILON && velocity > FLT_EPSILON) {
|
||||
mission_acceptance_radius = ((velocity / _param_back_trans_dec_mss.get() / 2) * velocity) + _param_reverse_delay.get() *
|
||||
velocity;
|
||||
const float back_trans_dec = _navigator->get_vtol_back_trans_deceleration();
|
||||
const float reverse_delay = _navigator->get_vtol_reverse_delay();
|
||||
|
||||
if (back_trans_dec > FLT_EPSILON && velocity > FLT_EPSILON) {
|
||||
mission_acceptance_radius = ((velocity / back_trans_dec / 2) * velocity) + reverse_delay * velocity;
|
||||
|
||||
}
|
||||
|
||||
@@ -328,16 +326,16 @@ MissionBlock::is_mission_item_reached()
|
||||
float yaw_err = _wrap_pi(_mission_item.yaw - cog);
|
||||
|
||||
/* accept yaw if reached or if timeout is set in which case we ignore not forced headings */
|
||||
if (fabsf(yaw_err) < math::radians(_param_yaw_err.get())
|
||||
|| (_param_yaw_timeout.get() >= FLT_EPSILON && !_mission_item.force_heading)) {
|
||||
if (fabsf(yaw_err) < math::radians(_navigator->get_yaw_threshold())
|
||||
|| (_navigator->get_yaw_timeout() >= FLT_EPSILON && !_mission_item.force_heading)) {
|
||||
|
||||
_waypoint_yaw_reached = true;
|
||||
}
|
||||
|
||||
/* if heading needs to be reached, the timeout is enabled and we don't make it, abort mission */
|
||||
if (!_waypoint_yaw_reached && _mission_item.force_heading &&
|
||||
(_param_yaw_timeout.get() >= FLT_EPSILON) &&
|
||||
(now - _time_wp_reached >= (hrt_abstime)_param_yaw_timeout.get() * 1e6f)) {
|
||||
(_navigator->get_yaw_timeout() >= FLT_EPSILON) &&
|
||||
(now - _time_wp_reached >= (hrt_abstime)_navigator->get_yaw_timeout() * 1e6f)) {
|
||||
|
||||
_navigator->set_mission_failure("unable to reach heading within timeout");
|
||||
}
|
||||
|
||||
@@ -42,8 +42,12 @@
|
||||
#define NAVIGATOR_MISSION_BLOCK_H
|
||||
|
||||
#include "navigator_mode.h"
|
||||
#include "navigation.h"
|
||||
|
||||
#include <navigator/navigation.h>
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <uORB/topics/mission.h>
|
||||
#include <uORB/topics/position_setpoint_triplet.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
@@ -59,7 +63,7 @@ public:
|
||||
* Constructor
|
||||
*/
|
||||
MissionBlock(Navigator *navigator, const char *name);
|
||||
~MissionBlock() = default;
|
||||
virtual ~MissionBlock() = default;
|
||||
|
||||
MissionBlock(const MissionBlock &) = delete;
|
||||
MissionBlock &operator=(const MissionBlock &) = delete;
|
||||
@@ -130,13 +134,6 @@ protected:
|
||||
hrt_abstime _time_wp_reached{0};
|
||||
|
||||
orb_advert_t _actuator_pub{nullptr};
|
||||
|
||||
control::BlockParamFloat _param_yaw_timeout;
|
||||
control::BlockParamFloat _param_yaw_err;
|
||||
|
||||
// VTOL parameters
|
||||
control::BlockParamFloat _param_back_trans_dec_mss;
|
||||
control::BlockParamFloat _param_reverse_delay;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
#include <uORB/topics/position_setpoint_triplet.h>
|
||||
#include <uORB/topics/vehicle_attitude_setpoint.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/vehicle_global_position.h>
|
||||
#include <uORB/topics/vehicle_gps_position.h>
|
||||
#include <uORB/topics/vehicle_land_detected.h>
|
||||
@@ -250,6 +251,13 @@ public:
|
||||
|
||||
// Param access
|
||||
float get_loiter_min_alt() const { return _param_loiter_min_alt.get(); }
|
||||
float get_takeoff_min_alt() const { return _param_takeoff_min_alt.get(); }
|
||||
float get_yaw_timeout() const { return _param_yaw_timeout.get(); }
|
||||
float get_yaw_threshold() const { return _param_yaw_err.get(); }
|
||||
|
||||
float get_vtol_back_trans_deceleration() const { return _param_back_trans_dec_mss.get(); }
|
||||
float get_vtol_reverse_delay() const { return _param_reverse_delay.get(); }
|
||||
|
||||
bool force_vtol() const { return _vstatus.is_vtol && !_vstatus.is_rotary_wing && _param_force_vtol.get(); }
|
||||
|
||||
private:
|
||||
@@ -330,7 +338,15 @@ private:
|
||||
control::BlockParamInt _param_traffic_avoidance_mode; /**< avoiding other aircraft is enabled */
|
||||
|
||||
// non-navigator parameters
|
||||
// Mission (MIS_*)
|
||||
control::BlockParamFloat _param_loiter_min_alt;
|
||||
control::BlockParamFloat _param_takeoff_min_alt;
|
||||
control::BlockParamFloat _param_yaw_timeout;
|
||||
control::BlockParamFloat _param_yaw_err;
|
||||
|
||||
// VTOL parameters TODO: get these out of navigator
|
||||
control::BlockParamFloat _param_back_trans_dec_mss;
|
||||
control::BlockParamFloat _param_reverse_delay;
|
||||
|
||||
float _mission_cruising_speed_mc{-1.0f};
|
||||
float _mission_cruising_speed_fw{-1.0f};
|
||||
|
||||
@@ -105,7 +105,12 @@ Navigator::Navigator() :
|
||||
_param_force_vtol(this, "FORCE_VT"),
|
||||
_param_traffic_avoidance_mode(this, "TRAFF_AVOID"),
|
||||
// non-navigator params
|
||||
_param_loiter_min_alt(this, "MIS_LTRMIN_ALT", false)
|
||||
_param_loiter_min_alt(this, "MIS_LTRMIN_ALT", false),
|
||||
_param_takeoff_min_alt(this, "MIS_TAKEOFF_ALT", false),
|
||||
_param_yaw_timeout(this, "MIS_YAW_TMT", false),
|
||||
_param_yaw_err(this, "MIS_YAW_ERR", false),
|
||||
_param_back_trans_dec_mss(this, "VT_B_DEC_MSS", false),
|
||||
_param_reverse_delay(this, "VT_B_REV_DEL", false)
|
||||
{
|
||||
/* Create a list of our possible navigation types */
|
||||
_navigation_mode_array[0] = &_mission;
|
||||
|
||||
@@ -42,15 +42,9 @@
|
||||
#ifndef NAVIGATOR_MODE_H
|
||||
#define NAVIGATOR_MODE_H
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
|
||||
#include <dataman/dataman.h>
|
||||
|
||||
#include <uORB/topics/position_setpoint_triplet.h>
|
||||
|
||||
class Navigator;
|
||||
|
||||
class NavigatorMode : public control::SuperBlock
|
||||
|
||||
@@ -53,18 +53,10 @@
|
||||
#include "navigator.h"
|
||||
#include "datalinkloss.h"
|
||||
|
||||
#define DELAY_SIGMA 0.01f
|
||||
|
||||
RCLoss::RCLoss(Navigator *navigator, const char *name) :
|
||||
MissionBlock(navigator, name),
|
||||
_param_loitertime(this, "LT"),
|
||||
_rcl_state(RCL_STATE_NONE)
|
||||
{
|
||||
/* initial reset */
|
||||
on_inactive();
|
||||
}
|
||||
|
||||
RCLoss::~RCLoss()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -40,28 +40,20 @@
|
||||
#ifndef NAVIGATOR_RCLOSS_H
|
||||
#define NAVIGATOR_RCLOSS_H
|
||||
|
||||
#include <controllib/blocks.hpp>
|
||||
#include <controllib/block/BlockParam.hpp>
|
||||
|
||||
#include <uORB/Subscription.hpp>
|
||||
|
||||
#include "navigator_mode.h"
|
||||
#include "mission_block.h"
|
||||
|
||||
class Navigator;
|
||||
|
||||
class RCLoss : public MissionBlock
|
||||
class RCLoss final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
RCLoss(Navigator *navigator, const char *name);
|
||||
~RCLoss() = default;
|
||||
|
||||
~RCLoss();
|
||||
|
||||
virtual void on_inactive();
|
||||
|
||||
virtual void on_activation();
|
||||
|
||||
virtual void on_active();
|
||||
void on_inactive() override;
|
||||
void on_activation() override;
|
||||
void on_active() override;
|
||||
|
||||
private:
|
||||
/* Params */
|
||||
@@ -72,7 +64,7 @@ private:
|
||||
RCL_STATE_LOITER = 1,
|
||||
RCL_STATE_TERMINATE = 2,
|
||||
RCL_STATE_END = 3
|
||||
} _rcl_state;
|
||||
} _rcl_state{RCL_STATE_NONE};
|
||||
|
||||
/**
|
||||
* Set the RCL item
|
||||
|
||||
@@ -167,7 +167,7 @@ RTL::set_rtl_item()
|
||||
_mission_item.origin = ORIGIN_ONBOARD;
|
||||
|
||||
mavlink_and_console_log_info(_navigator->get_mavlink_log_pub(), "RTL: climb to %d m (%d m above home)",
|
||||
(int)(climb_alt), (int)(climb_alt - _navigator->get_home_position()->alt));
|
||||
(int)ceilf(climb_alt), (int)ceilf(climb_alt - _navigator->get_home_position()->alt));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ RTL::set_rtl_item()
|
||||
_mission_item.origin = ORIGIN_ONBOARD;
|
||||
|
||||
mavlink_and_console_log_info(_navigator->get_mavlink_log_pub(), "RTL: return at %d m (%d m above home)",
|
||||
(int)(_mission_item.altitude), (int)(_mission_item.altitude - home.alt));
|
||||
(int)ceilf(_mission_item.altitude), (int)ceilf(_mission_item.altitude - home.alt));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ RTL::set_rtl_item()
|
||||
pos_sp_triplet->previous.valid = false;
|
||||
|
||||
mavlink_and_console_log_info(_navigator->get_mavlink_log_pub(), "RTL: descend to %d m (%d m above home)",
|
||||
(int)(_mission_item.altitude), (int)(_mission_item.altitude - home.alt));
|
||||
(int)ceilf(_mission_item.altitude), (int)ceilf(_mission_item.altitude - home.alt));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
class Navigator;
|
||||
|
||||
class RTL : public MissionBlock
|
||||
class RTL final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
RTL(Navigator *navigator, const char *name);
|
||||
|
||||
@@ -38,33 +38,11 @@
|
||||
* @author Lorenz Meier <lorenz@px4.io
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <systemlib/err.h>
|
||||
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/position_setpoint_triplet.h>
|
||||
|
||||
#include "takeoff.h"
|
||||
#include "navigator.h"
|
||||
|
||||
Takeoff::Takeoff(Navigator *navigator, const char *name) :
|
||||
MissionBlock(navigator, name),
|
||||
_param_min_alt(this, "MIS_TAKEOFF_ALT", false)
|
||||
{
|
||||
}
|
||||
|
||||
Takeoff::~Takeoff()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Takeoff::on_inactive()
|
||||
MissionBlock(navigator, name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -106,10 +84,10 @@ Takeoff::set_takeoff_position()
|
||||
float min_abs_altitude;
|
||||
|
||||
if (_navigator->home_position_valid()) { //only use home position if it is valid
|
||||
min_abs_altitude = _navigator->get_global_position()->alt + _param_min_alt.get();
|
||||
min_abs_altitude = _navigator->get_global_position()->alt + _navigator->get_takeoff_min_alt();
|
||||
|
||||
} else { //e.g. flow
|
||||
min_abs_altitude = _param_min_alt.get();
|
||||
min_abs_altitude = _navigator->get_takeoff_min_alt();
|
||||
}
|
||||
|
||||
// Use altitude if it has been set. If home position is invalid use min_abs_altitude
|
||||
@@ -120,22 +98,21 @@ Takeoff::set_takeoff_position()
|
||||
if (abs_altitude < min_abs_altitude) {
|
||||
abs_altitude = min_abs_altitude;
|
||||
mavlink_log_critical(_navigator->get_mavlink_log_pub(),
|
||||
"Using minimum takeoff altitude: %.2f m", (double)_param_min_alt.get());
|
||||
"Using minimum takeoff altitude: %.2f m", (double)_navigator->get_takeoff_min_alt());
|
||||
}
|
||||
|
||||
} else {
|
||||
// Use home + minimum clearance but only notify.
|
||||
abs_altitude = min_abs_altitude;
|
||||
mavlink_log_info(_navigator->get_mavlink_log_pub(),
|
||||
"Using minimum takeoff altitude: %.2f m", (double)_param_min_alt.get());
|
||||
"Using minimum takeoff altitude: %.2f m", (double)_navigator->get_takeoff_min_alt());
|
||||
}
|
||||
|
||||
|
||||
if (abs_altitude < _navigator->get_global_position()->alt) {
|
||||
// If the suggestion is lower than our current alt, let's not go down.
|
||||
abs_altitude = _navigator->get_global_position()->alt;
|
||||
mavlink_log_critical(_navigator->get_mavlink_log_pub(),
|
||||
"Already higher than takeoff altitude");
|
||||
mavlink_log_critical(_navigator->get_mavlink_log_pub(), "Already higher than takeoff altitude");
|
||||
}
|
||||
|
||||
// set current mission item to takeoff
|
||||
|
||||
@@ -47,21 +47,16 @@
|
||||
#include "navigator_mode.h"
|
||||
#include "mission_block.h"
|
||||
|
||||
class Takeoff : public MissionBlock
|
||||
class Takeoff final : public MissionBlock
|
||||
{
|
||||
public:
|
||||
Takeoff(Navigator *navigator, const char *name);
|
||||
~Takeoff() = default;
|
||||
|
||||
~Takeoff();
|
||||
|
||||
virtual void on_inactive();
|
||||
|
||||
virtual void on_activation();
|
||||
|
||||
virtual void on_active();
|
||||
void on_activation() override;
|
||||
void on_active() override;
|
||||
|
||||
private:
|
||||
control::BlockParamFloat _param_min_alt;
|
||||
|
||||
void set_takeoff_position();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user