I-Seed drone's onboard service  0.0.9
Public Member Functions | Static Public Attributes | List of all members
mission_state Class Reference

Class to watch the global mission state that will be sent over interconnection. More...

#include <mission_state.h>

Public Member Functions

void mission_path_ready (int32_t event_id)
 The mission path is constructed and ready to be sent to a user for confirmation. More...
 
void mission_path_cancel (int32_t event_id)
 A user request to clear the current mission path. Either the path is invalid, or the user wants to change it. More...
 
bool mission_path_available () const
 The mission path is available in current state. More...
 
void init ()
 Initial fetch of the path before running forward/backward missions. More...
 
void start (int32_t event_id)
 Start mission (either forward or backward). Update events can be processed. More...
 
void pause (int32_t event_id)
 Pause mission. More...
 
void stop ()
 Stop the global mission execution. More...
 
void abort (int32_t event_id)
 Abort mission. Ignore update events. More...
 
void resume (int32_t event_id)
 Resume mission. More...
 
void update_event_id (int32_t event_id)
 Update mission event_id. More...
 
void waypoint_reached () const
 Verify state correctness when waypoint reached. More...
 
bool is_forward () const
 Forward mission is in progress. More...
 
void set_backward ()
 Switch to backward mission. More...
 
bool is_finished () const
 Check if forward/backward mission finished. More...
 
bool is_ready () const
 Check if mission is ready to start. More...
 
bool is_paused () const
 Check if global mission is paused. More...
 
bool user_cmd_accepted () const
 Check if state accepts user's command pause/resume/abort. More...
 
bool update (T_DjiWaypointV2MissionEventPush event_data)
 Process mission event received from Payload SDK. More...
 
std::pair< bool, bool > update (T_DjiWaypointV2MissionStatePush state_data)
 Process state update event received from Payload SDK. More...
 
std::pair< int32_t, interconnection::drone_info::state_t > get_state ()
 Current drone's state to sent to the drone control Android application. More...
 

Static Public Attributes

static constexpr int32_t internal_event_id {-1}
 

Detailed Description

Class to watch the global mission state that will be sent over interconnection.

Since it's thread-safe and used in Payload SDK callbacks, all the methods should return flow control quickly, avoid long wait. Any Payload SDK API related to WaypointV2 mission should be called in mission. Waypoints information should be saved in mission too. Argument event_id indicates a user command.

Member Function Documentation

◆ mission_path_ready()

void mission_state::mission_path_ready ( int32_t  event_id)

The mission path is constructed and ready to be sent to a user for confirmation.

ready -> path_data

◆ mission_path_cancel()

void mission_state::mission_path_cancel ( int32_t  event_id)

A user request to clear the current mission path. Either the path is invalid, or the user wants to change it.

path_data -> ready

Here is the caller graph for this function:

◆ mission_path_available()

auto mission_state::mission_path_available ( ) const

The mission path is available in current state.

Here is the caller graph for this function:

◆ init()

void mission_state::init ( )

Initial fetch of the path before running forward/backward missions.

path -> forward_wait_start

Note
Update events still ignored
Here is the caller graph for this function:

◆ start()

void mission_state::start ( int32_t  event_id)

Start mission (either forward or backward). Update events can be processed.

forward_wait_start -> forward_wait_update

backward_wait_start -> backward_wait_update

◆ pause()

void mission_state::pause ( int32_t  event_id)

Pause mission.

forward_executing or backward_executing

Here is the caller graph for this function:

◆ stop()

void mission_state::stop ( )

Stop the global mission execution.

forward_wait_start -> ready (abort execution)

backward_wait_start -> ready (no objects detected - no backward mission, aborted execution)

backward_finished -> ready (success)

Here is the caller graph for this function:

◆ abort()

void mission_state::abort ( int32_t  event_id)

Abort mission. Ignore update events.

backward_executing -> backward_wait_start

forward_executing -> forward_wait_start

Note
  • forward mission restart on height tweak
  • mission abort on last fake waypoint
  • user mission abort
Here is the caller graph for this function:

◆ resume()

void mission_state::resume ( int32_t  event_id)

Resume mission.

forward_executing or backward_executing

Here is the caller graph for this function:

◆ update_event_id()

void mission_state::update_event_id ( int32_t  event_id)

Update mission event_id.

Here is the caller graph for this function:

◆ waypoint_reached()

void mission_state::waypoint_reached ( ) const

Verify state correctness when waypoint reached.

forward_executing or backward_executing

◆ is_forward()

auto mission_state::is_forward ( ) const

Forward mission is in progress.

Here is the caller graph for this function:

◆ set_backward()

void mission_state::set_backward ( )

Switch to backward mission.

forward_wait_start -> backward_wait_start (last fake waypoint)

forward_finished -> backward_wait_start (forward success)

Here is the caller graph for this function:

◆ is_finished()

auto mission_state::is_finished ( ) const

Check if forward/backward mission finished.

Here is the caller graph for this function:

◆ is_ready()

auto mission_state::is_ready ( ) const

Check if mission is ready to start.

Here is the caller graph for this function:

◆ is_paused()

auto mission_state::is_paused ( ) const

Check if global mission is paused.

Here is the caller graph for this function:

◆ user_cmd_accepted()

auto mission_state::user_cmd_accepted ( ) const

Check if state accepts user's command pause/resume/abort.

Here is the caller graph for this function:

◆ update() [1/2]

auto mission_state::update ( T_DjiWaypointV2MissionEventPush  event_data)

Process mission event received from Payload SDK.

Returns
notify_finished

◆ update() [2/2]

auto mission_state::update ( T_DjiWaypointV2MissionStatePush  state_data)

Process state update event received from Payload SDK.

Returns
auto [mission_started, notify]

◆ get_state()

auto mission_state::get_state ( )

Current drone's state to sent to the drone control Android application.

Returns
auto [event_id, state]
Note
Can change the global state path_data -> path

Member Data Documentation

◆ internal_event_id

constexpr int32_t mission_state::internal_event_id {-1}
staticconstexpr

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