Base class#

#include "navground/sim/task.h"
struct Task : public virtual navground::core::HasRegister<Task>#

This class describe the high-level task control that provides navigation goals.

Subclassed by navground::sim::DirectionTask, navground::sim::WaypointsTask

Public Types

using TaskCallback = std::function<void(const std::vector<ng_float_t> &data)>#

The type of callbacks called when the task publishes data related to an event.

The task must publish data of the same size, see get_log_size.

Param data:

[in] The event payload

Public Functions

inline virtual size_t get_log_size() const#

The size of the data passed to callbacks when events occur, see TaskCallback and add_callback.

Returns:

The size of the data vector.

inline void add_callback(const TaskCallback &value)#

Adds a callback called to log task events.

Parameters:

value[in] The desired callback

inline void clear_callbacks()#

Remove any callbacks.

inline virtual bool done() const#

Returns whether the task is done.

Returns:

True if the task has finished.

Protected Functions

inline virtual void update(Agent *agent, World *world, ng_float_t time)#

Tick the task, possibly updating the navigation goal of the agent.

Parameters:
  • agent – The agent ticking the task

  • world – The world the agent is part of

  • time[in] The simulation time

inline virtual void prepare(Agent *agent, World *world)#

Setup the task. Called before starting a simulation.

Parameters:
  • agent – The agent owning the task

  • world[in] The world the agent is part of

inline void log_event(const std::vector<ng_float_t> log) const#

Log an event, forwarding data to registered callbacks.

Parameters:

log[in] The logged data