58 #define SEC2USEC 1000000.0f    60 #define STATE_TIMEOUT 10000000 // [us] Maximum time to spend in any state    64     ModuleParams(navigator)
    66     _handle_param_acceleration_hor = 
param_find(
"MPC_ACC_HOR");
    91         PX4_WARN(
"Resetting landing position to current position");
   164     ModuleParams::updateParams();
   186             PX4_ERR(
"Can't switch to search or fallback landing");
   195     if (dist < _navigator->get_acceptance_radius()) {
   201         if (_param_pld_srch_tout.get() > 0) {
   206                         PX4_ERR(
"Can't switch to search or fallback landing");
   213                 PX4_ERR(
"Can't switch to search or fallback landing");
   226         PX4_WARN(
"Lost landing target while landing (horizontal approach).");
   235                 PX4_ERR(
"Can't switch to fallback landing");
   257         PX4_ERR(
"Precision landing took too long during horizontal approach phase.");
   263         PX4_ERR(
"Can't switch to fallback landing");
   278     pos_sp_triplet->
current.
type = position_setpoint_s::SETPOINT_TYPE_POSITION;
   291             PX4_WARN(
"Lost landing target while landing (descending).");
   300                     PX4_ERR(
"Can't switch to fallback landing");
   315     pos_sp_triplet->
current.
type = position_setpoint_s::SETPOINT_TYPE_LAND;
   352         PX4_WARN(
"Search timed out");
   355             PX4_ERR(
"Can't switch to fallback landing");
   371         pos_sp_triplet->
current.
type = position_setpoint_s::SETPOINT_TYPE_POSITION;
   428     PX4_INFO(
"Climbing to search altitude.");
   432     pos_sp_triplet->
current.
alt = vehicle_local_position->
ref_alt + _param_pld_srch_alt.get();
   433     pos_sp_triplet->
current.
type = position_setpoint_s::SETPOINT_TYPE_POSITION;
   446     PX4_WARN(
"Falling back to normal land.");
   451     pos_sp_triplet->
current.
type = position_setpoint_s::SETPOINT_TYPE_LAND;
   480                 && fabsf(
_target_pose.
y_abs - vehicle_local_position->
y) < _param_pld_hacc_rad.get()) {
   576     sp_vel = (sp_curr - 
_sp_pev) / dt; 
   578     if (sp_vel.
length() > max_spd) {
 uint64_t _state_start_time
time when we entered current state 
#define PARAM_INVALID
Handle returned when a parameter cannot be found. 
void run_state_fallback()
bool _target_pose_valid
whether we have received a landing target position message 
uint64_t _target_acquired_time
time when we first saw the landing target during search 
PrecLand(Navigator *navigator)
Helper class to do precision landing with a landing target. 
Helper class to access missions. 
__EXPORT int param_get(param_t param, void *val)
Copy the value of a parameter. 
API for the uORB lightweight object broker. 
bool map_projection_initialized(const struct map_projection_reference_s *ref)
Checks if projection given as argument was initialized. 
float get_distance_to_next_waypoint(double lat_now, double lon_now, double lat_next, double lon_next)
Returns the distance to the next waypoint in meters. 
reference for local/global projections 
struct position_setpoint_s next
bool switch_to_state_search()
int _search_cnt
counter of how many times we had to search for the landing target 
bool switch_to_state_fallback()
struct vehicle_land_detected_s * get_land_detected()
uORB::Subscription _target_pose_sub
bool switch_to_state_start()
bool switch_to_state_horizontal_approach()
bool switch_to_state_done()
float _param_acceleration_hor
bool _target_pose_updated
wether the landing target position message is updated 
bool switch_to_state_final_approach()
Vector normalized() const
struct position_setpoint_s current
int map_projection_reproject(const struct map_projection_reference_s *ref, float x, float y, double *lat, double *lon)
Transforms a point in the local azimuthal equidistant plane to the geographic coordinate system using...
struct vehicle_global_position_s * get_global_position()
void on_active() override
This function is called while the mode is active. 
uint64_t _point_reached_time
time when we reached a setpoint 
Vector2< float > Vector2f
static hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
Compute the delta between a timestamp taken in the past and now. 
void slewrate(float &sp_x, float &sp_y)
bool check_state_conditions(PrecLandState state)
void run_state_descend_above_target()
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
param_t _handle_param_xy_vel_cruise
matrix::Vector2f _sp_pev_prev
float _param_xy_vel_cruise
void run_state_horizontal_approach()
__EXPORT param_t param_find(const char *name)
Look up a parameter by name. 
struct position_setpoint_triplet_s * get_position_setpoint_triplet()
void on_activation() override
This function is called one time when mode becomes active, pos_sp_triplet must be initialized here...
float _approach_alt
altitude at which to stay during horizontal approach 
landing_target_pose_s _target_pose
precision landing target position 
int map_projection_project(const struct map_projection_reference_s *ref, double lat, double lon, float *x, float *y)
void updateParams() override
bool switch_to_state_descend_above_target()
void run_state_final_approach()
bool update(void *dst)
Update the struct. 
uint64_t _last_slewrate_time
time when we last limited setpoint changes 
int map_projection_init(struct map_projection_reference_s *ref, double lat_0, double lon_0)
Initializes the map transformation given by the argument and sets the timestamp to now...
void set_position_setpoint_triplet_updated()
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap). 
struct vehicle_local_position_s * get_local_position()