DUNE: Uniform Navigational Environment
2.6.0-rc1
|
Public Member Functions | |
Task (const std::string &name, Tasks::Context &ctx) | |
~Task () | |
void | onEntityResolution (void) |
void | onUpdateParameters (void) |
void | onResourceRelease (void) |
void | onResourceAcquisition (void) |
void | onResourceInitialization (void) |
void | consume (const IMC::EstimatedState *msg) |
void | consume (const IMC::ManeuverControlState *msg) |
void | consume (const IMC::PowerOperation *po) |
void | consume (const IMC::RegisterManeuver *msg) |
void | consume (const IMC::EntityInfo *msg) |
void | consume (const IMC::PlanDB *pdb) |
void | consume (const IMC::EntityActivationState *msg) |
void | consume (const IMC::FuelLevel *msg) |
void | openDB (void) |
void | closeDB (void) |
void | consume (const IMC::VehicleCommand *vc) |
void | consume (const IMC::VehicleState *vs) |
void | onVehicleService (const IMC::VehicleState *vs) |
void | onVehicleManeuver (const IMC::VehicleState *vs) |
void | onVehicleError (const IMC::VehicleState *vs) |
void | onVehicleCalibration (const IMC::VehicleState *vs) |
void | onVehicleExternalControl (const IMC::VehicleState *vs) |
void | consume (const IMC::PlanControl *pc) |
void | processRequest (const IMC::PlanControl *pc) |
bool | loadPlan (const std::string &plan_id, const IMC::Message *arg, bool plan_startup=false) |
void | getPlan (void) |
bool | stopPlan (bool plan_startup=false) |
bool | parsePlan (bool plan_startup, IMC::PlanStatistics &ps) |
bool | lookForPlan (const std::string &plan_id, IMC::PlanSpecification &ps) |
bool | parseArg (const std::string &plan_id, const IMC::Message *arg, std::string &info) |
bool | startPlan (const std::string &plan_id, const IMC::Message *spec, uint16_t flags) |
bool | startCalibration (void) |
void | startManeuver (IMC::PlanManeuver *pman) |
void | answer (uint8_t type, const std::string &desc, bool print=true) |
void | onFailure (const std::string &errmsg, bool print=true) |
void | onSuccess (const std::string &msg=DTR("OK"), bool print=true) |
void | changeMode (IMC::PlanControlState::StateEnum s, const std::string &event_desc, const std::string &nid, const IMC::Message *maneuver, bool print=true) |
void | changeMode (IMC::PlanControlState::StateEnum s, const std::string &event_desc, bool print=true) |
void | setInitialState (void) |
void | reportProgress (void) |
void | onMain (void) |
void | vehicleRequest (IMC::VehicleCommand::CommandEnum command, const IMC::Message *arg=0) |
bool | pendingReply (void) |
bool | blockedMode (void) const |
bool | readyMode (void) const |
bool | initMode (void) const |
bool | execMode (void) const |
void | changeLog (const std::string &name) |
Public Member Functions inherited from DUNE::Tasks::Task | |
Task (const std::string &name, Context &context) | |
const char * | getName (void) const |
const char * | getSystemName (void) const |
unsigned int | getSystemId (void) const |
unsigned int | getEntityId (void) const |
unsigned int | resolveEntity (const std::string &label) const |
std::string | resolveEntity (unsigned int id) const |
uint16_t | getActivationTime (void) const |
uint16_t | getDeactivationTime (void) const |
unsigned int | resolveSystemName (const std::string &name) const |
const char * | resolveSystemId (unsigned int id) const |
void | loadConfig (void) |
void | setPriority (unsigned int value) |
unsigned int | getPriority (void) const |
void | inf (const char *format,...) DUNE_PRINTF_FORMAT(2 |
void void | war (const char *format,...) DUNE_PRINTF_FORMAT(2 |
void void void | err (const char *format,...) DUNE_PRINTF_FORMAT(2 |
void void void void | cri (const char *format,...) DUNE_PRINTF_FORMAT(2 |
void void void void void | debug (const char *format,...) DUNE_PRINTF_FORMAT(2 |
void void void void void void | trace (const char *format,...) DUNE_PRINTF_FORMAT(2 |
void void void void void void void | spew (const char *format,...) DUNE_PRINTF_FORMAT(2 |
void void void void void void void void | dispatch (IMC::Message *msg, unsigned int flags=0) |
void | dispatch (IMC::Message &msg, unsigned int flags=0) |
void | dispatchReply (const IMC::Message &original, IMC::Message &msg, unsigned int flags=0) |
void | receive (const IMC::Message *msg) |
void | reserveEntities (void) |
void | resolveEntities (void) |
void | acquireResources (void) |
void | releaseResources (void) |
void | initializeResources (void) |
void | updateParameters (bool act_deact=true) |
void | writeParamsXML (std::ostream &os) const |
Public Member Functions inherited from DUNE::Tasks::AbstractTask | |
AbstractTask (void) | |
virtual | ~AbstractTask (void) |
Public Member Functions inherited from DUNE::Concurrency::Thread | |
Thread (void) | |
virtual | ~Thread (void) |
int | getProcessorUsage (void) |
Public Member Functions inherited from DUNE::Concurrency::Runnable | |
Runnable (void) | |
virtual | ~Runnable (void) |
void | start (void) |
void | stop (void) |
void | join (void) |
void | stopAndJoin (void) |
void | setPriority (Scheduler::Policy policy, unsigned priority) |
State | getState (void) |
bool | isCreated (void) |
bool | isStopping (void) |
bool | isRunning (void) |
bool | isStarting (void) |
bool | isDead (void) |
Public Attributes | |
Plan * | m_plan |
IMC::PlanControlState | m_pcs |
IMC::PlanControl | m_reply |
std::string | m_last_event |
uint16_t | m_vreq_ctr |
double | m_vc_reply_deadline |
double | m_last_vstate |
IMC::VehicleCommand | m_vc |
IMC::PlanSpecification | m_spec |
std::set< uint16_t > | m_supported_maneuvers |
Database::Connection * | m_db |
Database::Statement * | m_get_plan_stmt |
IMC::LoggingControl | m_lc |
IMC::EstimatedState | m_state |
IMC::ManeuverControlState | m_mcs |
Time::Counter< float > | m_report_timer |
std::map< std::string, IMC::EntityInfo > | m_cinfo |
unsigned | m_eid_imu |
bool | m_imu_enabled |
std::queue< IMC::PlanControl > | m_requests |
Arguments | m_args |
Additional Inherited Members | |
Public Types inherited from DUNE::Concurrency::Runnable | |
enum | State { StateStarting, StateRunning, StateStopping, StateDead, StateUnknown } |
Protected Member Functions inherited from DUNE::Tasks::Task | |
const char * | getEntityLabel (void) const |
void | setEntityLabel (const std::string &label) |
void | setEntityState (IMC::EntityState::StateEnum state, Status::Code code) |
void | setEntityState (IMC::EntityState::StateEnum state, const std::string &description) |
IMC::EntityState::StateEnum | getEntityState (void) const |
unsigned int | reserveEntity (const std::string &label) |
bool | stopping (void) |
bool | isActive (void) const |
bool | isActivating (void) const |
bool | isDeactivating (void) const |
void | waitForMessages (double timeout) |
void | consumeMessages (void) |
template<typename T > | |
Parameter & | param (const std::string &name, T &var) |
template<typename Y , typename T > | |
Parameter & | param (const std::string &name, T &var) |
template<typename T > | |
bool | paramChanged (T &var) |
void | paramActive (Parameter::Scope def_scope, Parameter::Visibility def_visibility, bool def_value=false) |
void | setParamSectionEditor (const std::string &name) |
template<typename M , typename T > | |
void | bind (T *task_obj, void(T::*consumer)(const M *)=&T::consume) |
template<typename T > | |
void | bind (T *task_obj, const std::vector< uint32_t > &list) |
template<typename T , typename M > | |
void | bind (T *task_obj, const std::vector< uint32_t > &list, void(T::*consumer)(const M *)=&T::consume) |
template<typename T > | |
void | bind (T *task_obj, const std::vector< std::string > &list) |
void | requestActivation (void) |
void | requestDeactivation (void) |
void | activate (void) |
void | activationFailed (const std::string &reason) |
void | deactivate (void) |
void | deactivationFailed (const std::string &reason) |
virtual void | onEntityReservation (void) |
virtual void | onReportEntityState (void) |
virtual void | onRequestActivation (void) |
virtual void | onRequestDeactivation (void) |
virtual void | onActivation (void) |
virtual void | onDeactivation (void) |
Protected Member Functions inherited from DUNE::Concurrency::Thread | |
void | startImpl (void) |
void | stopImpl (void) |
void | joinImpl (void) |
void | setPriorityImpl (Scheduler::Policy policy, unsigned priority) |
Protected Attributes inherited from DUNE::Tasks::Task | |
Context & | m_ctx |
|
inline |
References Plan::Engine::Arguments::actfail_abort, Plan::Engine::Arguments::calibration_time, DUNE::Tasks::Parameter::defaultValue(), Plan::Engine::Arguments::do_calib, Plan::Engine::Arguments::fpredict, Plan::Engine::Arguments::label_imu, m_args, DUNE::Tasks::Task::param(), Plan::Engine::Arguments::progress, Plan::Engine::Arguments::sk_calib, Plan::Engine::Arguments::sk_radius, Plan::Engine::Arguments::sk_rpm, and Plan::Engine::Arguments::speriod.
|
inlinevirtual |
|
inline |
Answer to the plan control request.
[in] | type | type of reply (same field as plan control message) |
[in] | desc | description for the answer |
[in] | true if output should be printed out |
References Plan::Engine::c_op_desc, DUNE::Tasks::Task::dispatch(), DUNE::Tasks::Task::err(), DUNE::Tasks::Task::inf(), and m_reply.
Referenced by onFailure(), and onSuccess().
|
inline |
References m_pcs.
Referenced by onVehicleCalibration(), onVehicleExternalControl(), and startCalibration().
|
inline |
References DUNE::Tasks::Task::dispatch(), and m_lc.
Referenced by changeMode(), and startPlan().
|
inline |
Change the current plan control state mode.
[in] | s | plan control state to switch to |
[in] | event_desc | description of the event that motivated the change |
[in] | nid | id of the maneuver if any |
[in] | maneuver | pointer to maneuver message |
[in] | true if the messages should be printed to output |
References Plan::Engine::c_state_desc, changeLog(), DUNE::Tasks::Task::debug(), DUNE::Tasks::Task::dispatch(), execMode(), initMode(), m_last_event, m_pcs, m_plan, Plan::Engine::Plan::planStopped(), and DUNE::Tasks::Task::war().
Referenced by changeMode(), consume(), loadPlan(), onMain(), onVehicleCalibration(), onVehicleError(), onVehicleExternalControl(), onVehicleManeuver(), onVehicleService(), startManeuver(), startPlan(), and stopPlan().
|
inline |
Change the current plan control state mode.
[in] | s | plan control state to switch to |
[in] | event_desc | description of the event that motivated the change |
[in] | true if the messages should be printed to output |
References changeMode().
|
inline |
References DUNE::Tasks::Task::debug(), m_db, and m_get_plan_stmt.
|
inline |
References DUNE::Tasks::Task::getSystemId(), and m_state.
|
inline |
References m_mcs, m_plan, and Plan::Engine::Plan::maneuverDone().
|
inline |
References closeDB(), DUNE::Tasks::Task::getSystemId(), openDB(), and DUNE::Tasks::Task::setEntityState().
|
inline |
References m_supported_maneuvers.
|
inline |
References m_cinfo.
|
inline |
References openDB().
|
inline |
|
inline |
References m_plan, and Plan::Engine::Plan::onFuelLevel().
|
inline |
|
inline |
References changeMode(), Plan::Engine::Plan::getCalibrationInfo(), DUNE::Tasks::Task::getEntityState(), Plan::Engine::Plan::hasCalibrationFailed(), initMode(), Plan::Engine::Plan::isCalibrationDone(), Plan::Engine::Plan::loadStartManeuver(), m_last_vstate, m_plan, m_reply, m_spec, onFailure(), onVehicleCalibration(), onVehicleError(), onVehicleExternalControl(), onVehicleManeuver(), onVehicleService(), pendingReply(), startManeuver(), and Plan::Engine::Plan::updateCalibration().
|
inline |
References DUNE::Tasks::Task::debug(), m_requests, pendingReply(), and processRequest().
|
inline |
References m_pcs.
Referenced by changeMode(), consume(), getPlan(), loadPlan(), onVehicleError(), onVehicleManeuver(), reportProgress(), startPlan(), and stopPlan().
|
inline |
Get current plan.
References execMode(), initMode(), m_reply, m_spec, onFailure(), and onSuccess().
Referenced by processRequest().
|
inline |
References m_pcs.
Referenced by changeMode(), consume(), getPlan(), loadPlan(), onVehicleCalibration(), onVehicleError(), reportProgress(), startPlan(), and stopPlan().
|
inline |
Load a plan into the vehicle.
[in] | plan_id | name of the plan |
[in] | arg | argument which may either be a maneuver or a plan specification |
[in] | plan_startup | true if a plan will start right after |
References changeMode(), execMode(), initMode(), m_pcs, m_reply, m_spec, onFailure(), onSuccess(), parseArg(), and parsePlan().
Referenced by processRequest(), and startPlan().
|
inline |
Look for a plan in the database.
[in] | plan_id | name of the plan |
[in] | ps | plan specification message |
References m_get_plan_stmt, and onFailure().
Referenced by parseArg().
|
inlinevirtual |
Called when the task is instructed to resolve all the entity identifiers it needs for normal execution.
See resolveEntity(). Derived classes that need to resolve entity identifiers should override this function.
Reimplemented from DUNE::Tasks::Task.
References Plan::Engine::Arguments::label_imu, m_args, m_eid_imu, and DUNE::Tasks::Task::resolveEntity().
|
inline |
Answer to the reply with a failure message.
[in] | errmsg | text error message to send |
[in] | true if the message should be printed to output |
References answer(), and m_pcs.
Referenced by consume(), getPlan(), loadPlan(), lookForPlan(), onVehicleError(), onVehicleService(), parsePlan(), processRequest(), startCalibration(), startPlan(), and stopPlan().
|
inlinevirtual |
Implements DUNE::Tasks::Task.
References Plan::Engine::c_vs_timeout, changeMode(), DUNE::Tasks::Task::dispatch(), DUNE::Tasks::Task::err(), DUNE::Tasks::Task::getEntityState(), m_args, m_last_vstate, m_pcs, m_report_timer, m_requests, m_vc_reply_deadline, m_vreq_ctr, pendingReply(), processRequest(), Plan::Engine::Arguments::progress, reportProgress(), setInitialState(), DUNE::Tasks::Task::stopping(), and DUNE::Tasks::Task::waitForMessages().
|
inlinevirtual |
Called when the task is instructed to acquire resources whose configuration is defined by run-time parameters.
Reimplemented from DUNE::Tasks::Task.
References Plan::Engine::Arguments::calibration_time, DUNE::Tasks::Context::config, Plan::Engine::Arguments::fpredict, m_args, DUNE::Tasks::Task::m_ctx, m_plan, m_spec, Plan::Engine::Plan, and Plan::Engine::Arguments::progress.
|
inlinevirtual |
Called when the task is instructed to initialize resources acquired previously or whose initialization depends on run-time parameters.
Reimplemented from DUNE::Tasks::Task.
References m_args, m_report_timer, and Plan::Engine::Arguments::speriod.
|
inlinevirtual |
Called when the task is instructed to release resources.
Derived classes that override this function must not assume that any resource was previously acquired. This function must be implemented in such a way that it can be called at any time.
Reimplemented from DUNE::Tasks::Task.
References m_plan.
|
inline |
Answer to the reply with a success message.
[in] | msg | text message to send |
[in] | true if the message should be printed to output |
References answer(), and m_pcs.
Referenced by getPlan(), loadPlan(), onVehicleManeuver(), and startPlan().
|
inlinevirtual |
Called when the task is instructed to update its run-time parameters.
Derived classes that need to compute auxiliary values based on run-time parameters should override this function.
Reimplemented from DUNE::Tasks::Task.
References Plan::Engine::Arguments::calibration_time, m_args, m_plan, DUNE::Tasks::Task::paramChanged(), Plan::Engine::Arguments::progress, and Plan::Engine::Arguments::speriod.
|
inline |
References blockedMode(), changeMode(), and initMode().
Referenced by consume().
|
inline |
References changeMode(), execMode(), initMode(), m_last_event, m_reply, m_spec, onFailure(), pendingReply(), and vehicleRequest().
Referenced by consume().
|
inline |
References blockedMode(), and changeMode().
Referenced by consume().
|
inline |
References changeMode(), execMode(), Plan::Engine::Plan::isDone(), Plan::Engine::Plan::loadNextManeuver(), m_pcs, m_plan, m_reply, m_spec, onSuccess(), pendingReply(), startManeuver(), and vehicleRequest().
Referenced by consume().
|
inline |
References changeMode(), Plan::Engine::Plan::loadStartManeuver(), m_pcs, m_plan, m_reply, m_spec, onFailure(), pendingReply(), and startManeuver().
Referenced by consume().
|
inline |
References DUNE::Tasks::Task::debug(), DUNE::Tasks::Context::dir_db, DUNE::Tasks::Task::m_ctx, m_db, m_get_plan_stmt, and DUNE::Tasks::Task::setEntityState().
Referenced by consume().
|
inline |
Get the PlanSpecification from IMC::Message.
[in] | plan_id | ID of the plan |
[in] | arg | pointer to arg message |
[out] | info | string with the error in case of failure |
References DUNE::Tasks::Task::getEntityId(), lookForPlan(), m_reply, and m_spec.
Referenced by loadPlan().
|
inline |
Parse a given plan.
[in] | plan_startup | true if the plan is starting up |
[out] | ps | reference to PlanStatistics message |
References Plan::Engine::Plan::clear(), m_cinfo, m_imu_enabled, m_plan, m_state, m_supported_maneuvers, onFailure(), and Plan::Engine::Plan::parse().
Referenced by loadPlan().
|
inline |
References m_vc_reply_deadline.
Referenced by consume(), onMain(), onVehicleError(), onVehicleManeuver(), and onVehicleService().
|
inline |
|
inline |
References m_pcs.
|
inline |
Report progress.
References execMode(), Plan::Engine::Plan::getETA(), initMode(), m_mcs, m_pcs, m_plan, and Plan::Engine::Plan::updateProgress().
Referenced by onMain().
|
inline |
Set task's initial state.
References DUNE::Tasks::Task::dispatch(), m_last_event, m_last_vstate, m_pcs, m_vc_reply_deadline, and m_vreq_ctr.
Referenced by onMain().
|
inline |
Send a request to start calibration procedures.
References blockedMode(), m_args, m_state, onFailure(), Plan::Engine::Arguments::sk_calib, Plan::Engine::Arguments::sk_radius, Plan::Engine::Arguments::sk_rpm, and vehicleRequest().
Referenced by startPlan().
|
inline |
Start a maneuver by name.
[in] | pman | pointer to plan maneuver message |
References changeMode(), Plan::Engine::Plan::getCurrentId(), m_plan, Plan::Engine::Plan::maneuverStarted(), and vehicleRequest().
Referenced by consume(), onVehicleManeuver(), onVehicleService(), and startPlan().
|
inline |
Start a given plan.
[in] | plan_id | name of the plan to execute |
[in] | spec | plan specification message if any |
[in] | flags | plan control flags |
References changeLog(), changeMode(), DUNE::Tasks::Task::dispatch(), Plan::Engine::Arguments::do_calib, execMode(), initMode(), loadPlan(), Plan::Engine::Plan::loadStartManeuver(), m_args, m_last_event, m_plan, m_spec, onFailure(), onSuccess(), Plan::Engine::Plan::planStarted(), Plan::Engine::Plan::planStopped(), startCalibration(), startManeuver(), and stopPlan().
Referenced by processRequest().
|
inline |
Stop current plan being executed.
[in] | plan_startup | true if a plan will start right after this stop |
References changeMode(), DUNE::Tasks::Task::debug(), execMode(), initMode(), m_pcs, m_reply, m_spec, onFailure(), and vehicleRequest().
Referenced by processRequest(), and startPlan().
|
inline |
References Plan::Engine::c_vc_reply_timeout, Plan::Engine::Plan::calibrationStarted(), DUNE::Tasks::Task::dispatch(), Plan::Engine::Plan::getEstimatedCalibrationTime(), m_plan, m_vc, m_vc_reply_deadline, and m_vreq_ctr.
Referenced by onVehicleError(), onVehicleManeuver(), processRequest(), startCalibration(), startManeuver(), and stopPlan().
Arguments Plan::Engine::Task::m_args |
Task arguments.
Referenced by consume(), onEntityResolution(), onMain(), onResourceAcquisition(), onResourceInitialization(), onUpdateParameters(), startCalibration(), startPlan(), and Task().
std::map<std::string, IMC::EntityInfo> Plan::Engine::Task::m_cinfo |
Map of component names to entityinfo.
Referenced by consume(), and parsePlan().
Database::Connection* Plan::Engine::Task::m_db |
unsigned Plan::Engine::Task::m_eid_imu |
Source entity of the IMU.
Referenced by consume(), and onEntityResolution().
Database::Statement* Plan::Engine::Task::m_get_plan_stmt |
Referenced by closeDB(), lookForPlan(), and openDB().
bool Plan::Engine::Task::m_imu_enabled |
IMU is enabled or not.
Referenced by consume(), and parsePlan().
std::string Plan::Engine::Task::m_last_event |
Last event description.
Referenced by changeMode(), onVehicleError(), setInitialState(), and startPlan().
double Plan::Engine::Task::m_last_vstate |
Referenced by consume(), onMain(), and setInitialState().
IMC::LoggingControl Plan::Engine::Task::m_lc |
Misc.
Referenced by changeLog().
IMC::ManeuverControlState Plan::Engine::Task::m_mcs |
ManeuverControlState message.
Referenced by consume(), and reportProgress().
IMC::PlanControlState Plan::Engine::Task::m_pcs |
Plan control interface.
Referenced by blockedMode(), changeMode(), execMode(), initMode(), loadPlan(), onFailure(), onMain(), onSuccess(), onVehicleManeuver(), onVehicleService(), readyMode(), reportProgress(), setInitialState(), and stopPlan().
Plan* Plan::Engine::Task::m_plan |
Pointer to Plan class.
Referenced by changeMode(), consume(), onResourceAcquisition(), onResourceRelease(), onUpdateParameters(), onVehicleManeuver(), onVehicleService(), parsePlan(), reportProgress(), startManeuver(), startPlan(), and vehicleRequest().
IMC::PlanControl Plan::Engine::Task::m_reply |
Referenced by answer(), consume(), getPlan(), loadPlan(), onVehicleError(), onVehicleManeuver(), onVehicleService(), parseArg(), processRequest(), and stopPlan().
Time::Counter<float> Plan::Engine::Task::m_report_timer |
Timer counter for state report period.
Referenced by onMain(), and onResourceInitialization().
std::queue<IMC::PlanControl> Plan::Engine::Task::m_requests |
IMC::PlanSpecification Plan::Engine::Task::m_spec |
PlanSpecification message.
Referenced by consume(), getPlan(), loadPlan(), onResourceAcquisition(), onVehicleError(), onVehicleManeuver(), onVehicleService(), parseArg(), startPlan(), and stopPlan().
IMC::EstimatedState Plan::Engine::Task::m_state |
Referenced by consume(), parsePlan(), and startCalibration().
std::set<uint16_t> Plan::Engine::Task::m_supported_maneuvers |
List of supported maneuvers.
Referenced by consume(), and parsePlan().
IMC::VehicleCommand Plan::Engine::Task::m_vc |
Referenced by vehicleRequest().
double Plan::Engine::Task::m_vc_reply_deadline |
Referenced by consume(), onMain(), pendingReply(), setInitialState(), and vehicleRequest().
uint16_t Plan::Engine::Task::m_vreq_ctr |
Vehicle interface.
Referenced by consume(), onMain(), setInitialState(), and vehicleRequest().