PX4 Firmware
PX4 Autopilot Software http://px4.io
MissionBlock Class Reference

#include <mission_block.h>

Inheritance diagram for MissionBlock:
Collaboration diagram for MissionBlock:

Public Member Functions

 MissionBlock (Navigator *navigator)
 Constructor. More...
 
virtual ~MissionBlock ()=default
 
 MissionBlock (const MissionBlock &)=delete
 
MissionBlockoperator= (const MissionBlock &)=delete
 
- Public Member Functions inherited from NavigatorMode
 NavigatorMode (Navigator *navigator)
 
virtual ~NavigatorMode ()=default
 
 NavigatorMode (const NavigatorMode &)=delete
 
NavigatorMode operator= (const NavigatorMode &)=delete
 
void run (bool active)
 
virtual void on_inactive ()
 This function is called while the mode is inactive. More...
 
virtual void on_activation ()
 This function is called one time when mode becomes active, pos_sp_triplet must be initialized here. More...
 
virtual void on_inactivation ()
 This function is called one time when mode becomes inactive. More...
 
virtual void on_active ()
 This function is called while the mode is active. More...
 

Static Public Member Functions

static bool item_contains_position (const mission_item_s &item)
 

Protected Member Functions

bool is_mission_item_reached ()
 Check if mission item has been reached. More...
 
void reset_mission_item_reached ()
 Reset all reached flags. More...
 
bool mission_item_to_position_setpoint (const mission_item_s &item, position_setpoint_s *sp)
 Convert a mission item to a position setpoint. More...
 
void set_loiter_item (struct mission_item_s *item, float min_clearance=-1.0f)
 Set a loiter mission item, if possible reuse the position setpoint, otherwise take the current position. More...
 
void set_takeoff_item (struct mission_item_s *item, float abs_altitude, float min_pitch=0.0f)
 Set a takeoff mission item. More...
 
void set_land_item (struct mission_item_s *item, bool at_current_location)
 Set a land mission item. More...
 
void set_idle_item (struct mission_item_s *item)
 Set idle mission item. More...
 
void set_vtol_transition_item (struct mission_item_s *item, const uint8_t new_mode)
 Set vtol transition item. More...
 
void mission_apply_limitation (mission_item_s &item)
 General function used to adjust the mission item based on vehicle specific limitations. More...
 
void issue_command (const mission_item_s &item)
 
float get_time_inside (const mission_item_s &item) const
 
float get_absolute_altitude_for_item (const mission_item_s &mission_item) const
 

Protected Attributes

mission_item_s _mission_item {}
 
bool _waypoint_position_reached {false}
 
bool _waypoint_yaw_reached {false}
 
bool _waypoint_position_reached_previously {false}
 
hrt_abstime _time_first_inside_orbit {0}
 
hrt_abstime _action_start {0}
 
hrt_abstime _time_wp_reached {0}
 
uORB::Publication< actuator_controls_s_actuator_pub {ORB_ID(actuator_controls_2)}
 
- Protected Attributes inherited from NavigatorMode
Navigator_navigator {nullptr}
 

Detailed Description

Definition at line 58 of file mission_block.h.

Constructor & Destructor Documentation

◆ MissionBlock() [1/2]

MissionBlock::MissionBlock ( Navigator navigator)

Constructor.

Definition at line 59 of file mission_block.cpp.

References _mission_item, NavigatorMode::_navigator, mission_item_s::acceptance_radius, mission_item_s::autocontinue, Navigator::get_acceptance_radius(), Navigator::get_loiter_radius(), mission_item_s::lat, mission_item_s::loiter_radius, mission_item_s::lon, mission_item_s::origin, ORIGIN_ONBOARD, mission_item_s::time_inside, and mission_item_s::yaw.

Here is the call graph for this function:

◆ ~MissionBlock()

virtual MissionBlock::~MissionBlock ( )
virtualdefault

◆ MissionBlock() [2/2]

MissionBlock::MissionBlock ( const MissionBlock )
delete

Member Function Documentation

◆ get_absolute_altitude_for_item()

float MissionBlock::get_absolute_altitude_for_item ( const mission_item_s mission_item) const
protected

Definition at line 748 of file mission_block.cpp.

References NavigatorMode::_navigator, home_position_s::alt, mission_item_s::altitude, mission_item_s::altitude_is_relative, and Navigator::get_home_position().

Referenced by Mission::altitude_sp_foh_update(), Mission::calculate_takeoff_altitude(), Mission::do_abort_landing(), Mission::index_closest_mission_item(), and mission_item_to_position_setpoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_time_inside()

float MissionBlock::get_time_inside ( const mission_item_s item) const
protected

Definition at line 483 of file mission_block.cpp.

References NavigatorMode::_navigator, Navigator::get_vstatus(), math::max(), mission_item_s::nav_cmd, NAV_CMD_DELAY, NAV_CMD_LOITER_TIME_LIMIT, NAV_CMD_WAYPOINT, mission_item_s::time_inside, and vehicle_status_s::vehicle_type.

Referenced by is_mission_item_reached(), Mission::set_mission_items(), and RTL::set_rtl_item().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_mission_item_reached()

bool MissionBlock::is_mission_item_reached ( )
protected

Check if mission item has been reached.

Returns
true if successfully reached

Definition at line 73 of file mission_block.cpp.

References _action_start, _mission_item, NavigatorMode::_navigator, _time_first_inside_orbit, _time_wp_reached, _waypoint_position_reached, _waypoint_position_reached_previously, _waypoint_yaw_reached, mission_item_s::acceptance_radius, home_position_s::alt, vehicle_global_position_s::alt, position_setpoint_s::alt, mission_item_s::altitude, mission_item_s::altitude_is_relative, math::constrain(), position_setpoint_triplet_s::current, f(), FLT_EPSILON, mission_item_s::force_heading, Navigator::get_acceptance_radius(), Navigator::get_altitude_acceptance_radius(), get_bearing_to_next_waypoint(), Navigator::get_default_altitude_acceptance_radius(), get_distance_to_next_waypoint(), get_distance_to_point_global_wgs84(), Navigator::get_global_position(), Navigator::get_home_position(), Navigator::get_land_detected(), Navigator::get_local_position(), Navigator::get_loiter_radius(), Navigator::get_position_setpoint_triplet(), get_time_inside(), Navigator::get_vstatus(), Navigator::get_vtol_back_trans_deceleration(), Navigator::get_vtol_reverse_delay(), Navigator::get_yaw_acceptance(), Navigator::get_yaw_threshold(), Navigator::get_yaw_timeout(), hrt_absolute_time(), hrt_abstime, vehicle_status_s::in_transition_mode, vehicle_land_detected_s::landed, vehicle_global_position_s::lat, position_setpoint_s::lat, mission_item_s::lat, position_setpoint_s::loiter_direction, mission_item_s::loiter_exit_xtrack, position_setpoint_s::loiter_radius, mission_item_s::loiter_radius, vehicle_global_position_s::lon, position_setpoint_s::lon, mission_item_s::lon, mission_item_s::nav_cmd, NAV_CMD_DELAY, NAV_CMD_DO_CHANGE_SPEED, NAV_CMD_DO_DIGICAM_CONTROL, NAV_CMD_DO_LAND_START, NAV_CMD_DO_MOUNT_CONFIGURE, NAV_CMD_DO_MOUNT_CONTROL, NAV_CMD_DO_SET_CAM_TRIGG_DIST, NAV_CMD_DO_SET_CAM_TRIGG_INTERVAL, NAV_CMD_DO_SET_HOME, NAV_CMD_DO_SET_ROI, NAV_CMD_DO_SET_ROI_LOCATION, NAV_CMD_DO_SET_ROI_NONE, NAV_CMD_DO_SET_ROI_WPNEXT_OFFSET, NAV_CMD_DO_SET_SERVO, NAV_CMD_DO_TRIGGER_CONTROL, NAV_CMD_DO_VTOL_TRANSITION, NAV_CMD_IDLE, NAV_CMD_IMAGE_START_CAPTURE, NAV_CMD_IMAGE_STOP_CAPTURE, NAV_CMD_LAND, NAV_CMD_LOITER_TIME_LIMIT, NAV_CMD_LOITER_TO_ALT, NAV_CMD_LOITER_UNLIMITED, NAV_CMD_SET_CAMERA_MODE, NAV_CMD_TAKEOFF, NAV_CMD_VIDEO_START_CAPTURE, NAV_CMD_VIDEO_STOP_CAPTURE, NAV_CMD_VTOL_LAND, NAV_CMD_VTOL_TAKEOFF, NAV_CMD_WAYPOINT, NAV_EPSILON_POSITION, position_setpoint_triplet_s::next, Navigator::set_mission_failure(), Navigator::set_position_setpoint_triplet_updated(), position_setpoint_s::type, position_setpoint_s::valid, vehicle_status_s::vehicle_type, VEHICLE_TYPE_FIXED_WING, vehicle_global_position_s::vel_e, vehicle_global_position_s::vel_n, velocity, mission_item_s::vtol_back_transition, vehicle_local_position_s::vx, vehicle_local_position_s::vy, waypoint_from_heading_and_distance(), matrix::wrap_pi(), vehicle_global_position_s::yaw, and mission_item_s::yaw.

Referenced by Takeoff::on_active(), EngineFailure::on_active(), RCLoss::on_active(), DataLinkLoss::on_active(), FollowTarget::on_active(), RTL::on_active(), and Mission::on_active().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ issue_command()

◆ item_contains_position()

◆ mission_apply_limitation()

void MissionBlock::mission_apply_limitation ( mission_item_s item)
protected

General function used to adjust the mission item based on vehicle specific limitations.

Definition at line 719 of file mission_block.cpp.

References NavigatorMode::_navigator, home_position_s::alt, vehicle_land_detected_s::alt_max, mission_item_s::altitude, mission_item_s::altitude_is_relative, Navigator::get_home_position(), and Navigator::get_land_detected().

Referenced by Mission::do_abort_landing(), Land::on_activation(), Takeoff::on_active(), EngineFailure::set_ef_item(), Loiter::set_loiter_position(), Mission::set_mission_items(), RCLoss::set_rcl_item(), RTL::set_rtl_item(), Takeoff::set_takeoff_position(), and FollowTarget::update_position_sp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mission_item_to_position_setpoint()

bool MissionBlock::mission_item_to_position_setpoint ( const mission_item_s item,
position_setpoint_s sp 
)
protected

Convert a mission item to a position setpoint.

Parameters
themission item to convert
theposition setpoint that needs to be set

Definition at line 512 of file mission_block.cpp.

References NavigatorMode::_navigator, position_setpoint_s::acceptance_radius, mission_item_s::acceptance_radius, vehicle_global_position_s::alt, home_position_s::alt, position_setpoint_s::alt, vehicle_status_s::arming_state, position_setpoint_s::cruising_speed, position_setpoint_s::cruising_throttle, get_absolute_altitude_for_item(), Navigator::get_cruising_speed(), Navigator::get_cruising_throttle(), Navigator::get_default_acceptance_radius(), Navigator::get_global_position(), Navigator::get_home_position(), Navigator::get_land_detected(), Navigator::get_loiter_min_alt(), Navigator::get_loiter_radius(), Navigator::get_vstatus(), hrt_absolute_time(), item_contains_position(), vehicle_land_detected_s::landed, position_setpoint_s::lat, mission_item_s::lat, position_setpoint_s::loiter_direction, position_setpoint_s::loiter_radius, mission_item_s::loiter_radius, position_setpoint_s::lon, mission_item_s::lon, math::max(), vehicle_land_detected_s::maybe_landed, mission_item_s::nav_cmd, NAV_CMD_IDLE, NAV_CMD_LAND, NAV_CMD_LOITER_TIME_LIMIT, NAV_CMD_LOITER_TO_ALT, NAV_CMD_LOITER_UNLIMITED, NAV_CMD_TAKEOFF, NAV_CMD_VTOL_LAND, NAV_CMD_VTOL_TAKEOFF, NAV_EPSILON_POSITION, position_setpoint_s::pitch_min, mission_item_s::pitch_min, position_setpoint_s::timestamp, position_setpoint_s::type, position_setpoint_s::valid, position_setpoint_s::yaw, mission_item_s::yaw, and position_setpoint_s::yaw_valid.

Referenced by Mission::do_abort_landing(), Land::on_activation(), Land::on_active(), Takeoff::on_active(), DataLinkLoss::set_dll_item(), EngineFailure::set_ef_item(), Loiter::set_loiter_position(), Mission::set_mission_items(), RCLoss::set_rcl_item(), RTL::set_rtl_item(), Takeoff::set_takeoff_position(), and FollowTarget::update_position_sp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

MissionBlock& MissionBlock::operator= ( const MissionBlock )
delete

◆ reset_mission_item_reached()

void MissionBlock::reset_mission_item_reached ( )
protected

◆ set_idle_item()

void MissionBlock::set_idle_item ( struct mission_item_s item)
protected

Set idle mission item.

Definition at line 694 of file mission_block.cpp.

References NavigatorMode::_navigator, mission_item_s::acceptance_radius, home_position_s::alt, mission_item_s::altitude, mission_item_s::altitude_is_relative, mission_item_s::autocontinue, Navigator::get_acceptance_radius(), Navigator::get_home_position(), Navigator::get_loiter_radius(), home_position_s::lat, mission_item_s::lat, mission_item_s::loiter_radius, home_position_s::lon, mission_item_s::lon, mission_item_s::nav_cmd, NAV_CMD_IDLE, mission_item_s::origin, ORIGIN_ONBOARD, mission_item_s::time_inside, and mission_item_s::yaw.

Referenced by Land::on_active(), and RTL::set_rtl_item().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_land_item()

void MissionBlock::set_land_item ( struct mission_item_s item,
bool  at_current_location 
)
protected

◆ set_loiter_item()

void MissionBlock::set_loiter_item ( struct mission_item_s item,
float  min_clearance = -1.0f 
)
protected

◆ set_takeoff_item()

void MissionBlock::set_takeoff_item ( struct mission_item_s item,
float  abs_altitude,
float  min_pitch = 0.0f 
)
protected

Set a takeoff mission item.

Definition at line 638 of file mission_block.cpp.

References NavigatorMode::_navigator, mission_item_s::altitude, mission_item_s::altitude_is_relative, mission_item_s::autocontinue, Navigator::get_global_position(), Navigator::get_loiter_radius(), vehicle_global_position_s::lat, mission_item_s::lat, mission_item_s::loiter_radius, vehicle_global_position_s::lon, mission_item_s::lon, mission_item_s::nav_cmd, NAV_CMD_TAKEOFF, mission_item_s::origin, ORIGIN_ONBOARD, mission_item_s::pitch_min, vehicle_global_position_s::yaw, and mission_item_s::yaw.

Referenced by Takeoff::set_takeoff_position().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_vtol_transition_item()

void MissionBlock::set_vtol_transition_item ( struct mission_item_s item,
const uint8_t  new_mode 
)
protected

Set vtol transition item.

Definition at line 710 of file mission_block.cpp.

References NavigatorMode::_navigator, mission_item_s::autocontinue, Navigator::get_global_position(), mission_item_s::nav_cmd, NAV_CMD_DO_VTOL_TRANSITION, mission_item_s::params, vehicle_global_position_s::yaw, and mission_item_s::yaw.

Referenced by Mission::set_execution_mode(), Mission::set_mission_items(), and RTL::set_rtl_item().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _action_start

hrt_abstime MissionBlock::_action_start {0}
protected

Definition at line 135 of file mission_block.h.

Referenced by is_mission_item_reached(), and issue_command().

◆ _actuator_pub

uORB::Publication<actuator_controls_s> MissionBlock::_actuator_pub {ORB_ID(actuator_controls_2)}
protected

Definition at line 138 of file mission_block.h.

Referenced by issue_command().

◆ _mission_item

◆ _time_first_inside_orbit

hrt_abstime MissionBlock::_time_first_inside_orbit {0}
protected

Definition at line 134 of file mission_block.h.

Referenced by is_mission_item_reached(), and reset_mission_item_reached().

◆ _time_wp_reached

hrt_abstime MissionBlock::_time_wp_reached {0}
protected

Definition at line 136 of file mission_block.h.

Referenced by is_mission_item_reached(), and reset_mission_item_reached().

◆ _waypoint_position_reached

bool MissionBlock::_waypoint_position_reached {false}
protected

◆ _waypoint_position_reached_previously

bool MissionBlock::_waypoint_position_reached_previously {false}
protected

Definition at line 132 of file mission_block.h.

Referenced by is_mission_item_reached().

◆ _waypoint_yaw_reached

bool MissionBlock::_waypoint_yaw_reached {false}
protected

Definition at line 131 of file mission_block.h.

Referenced by is_mission_item_reached(), and reset_mission_item_reached().


The documentation for this class was generated from the following files: