Class executable_task
Defined in File executable_task.hpp
Inheritance Relationships
Base Types
public cosm::ta::logical_task
(Class logical_task)public cosm::ta::metrics::execution_metrics
(Class execution_metrics)public rer::client< executable_task >
Derived Type
public cosm::ta::polled_task
(Class polled_task)
Class Documentation
-
class executable_task : public cosm::ta::logical_task, public cosm::ta::metrics::execution_metrics, public rer::client<executable_task>
Represents the executable concept of a task, which encompasses:
A possibly updated estimate of the time it takes to do a task. If a task is only made to be executed once, then this field is unused.
A possibly updated estimate of the interface time for the task. If a task is only made to be executed once, then this field is unused.
A method of decomposing this (possibly decomposable) task into a sequence of simpler tasks. Each “simpler” task can have a parent.
Metrics that can be collected on a task as it runs.
Subclassed by cosm::ta::polled_task
Public Functions
-
executable_task(const std::string &name, const config::src_sigmoid_sel_config *abort, const rmath::config::ema_config *estimation)
-
~executable_task(void) override = default
-
inline double abort_prob(void) const
Get the current abort probability at the specified interface.
-
virtual double abort_prob_calc(void) = 0
Get the probability of aborting an executable task.
Even though this class also has public functions for updating the internally maintained abort probability, this function is still needed in order to provide “gated” abort probabilities (i.e. abort probabilities that are only active when certain conditions are met).
-
inline void abort_prob_update(void)
Update the calculated abort probability for the task. This should be done every timestep, even if there are logical “gates” that will only result in a non-zero abort probability on some timesteps.
-
int active_interface(void) const
Get the ID of the active interface.
- Returns:
The ID, or -1 if there is not currently an active interface.
-
virtual void active_interface_update(int i) = 0
(Possibly) update/change which interface is currently active.
- Parameters:
i – The currently active interface, -1 if none active.
-
inline void exec_estimate_init(const rtypes::timestep &init_measure)
Initialize the execution time estimate for the task. This ignores the value of the alpha parameter for updating estimates.
- Parameters:
init_measure – Initial execution estimate.
-
inline void exec_estimate_update(const rtypes::timestep &last_measure)
Update the current estimate of the task execution time by using a weighted sum of the previous cta::time_estimate and the new value.
- Parameters:
last_measure – The last measured time.
-
inline rtypes::timestep exec_time(void) const
Get the current execution time of the task.
-
inline void exec_time_reset(void)
Reset the execution time for the task.
-
inline rtypes::timestep exec_time_update(void)
Update the calculated execution time for the task.
This is needed for accurate task abort calculations.
-
inline void interface_estimate_update(size_t i, const rtypes::timestep &last_measure)
Update the current estimate of the task interface time by using a weighted sum of the previous cta::time_estimate and the new value.
- Parameters:
i – The interface ID.
last_measure – The last measured time.
-
inline rtypes::timestep interface_time(size_t i) const
Get the current interface time of the task for the specified interface.
- Parameters:
i – The interface ID.
-
inline void interface_time_reset(void)
Because tasks can have multiple interfaces, they need a way to reset their interface time upon leaving/entering an interface.
-
inline void interface_time_update(void)
Update the calculated interface time for the task if the current task has been marked as being at (one of) its task interface(s).
This is needed for accurate task abort calculations.
-
inline bool is_atomic(void) const
Get if a task is currently atomic (i.e. not abortable).
-
inline bool is_partitionable(void) const
Get if a task is partitionable.
-
inline void set_atomic(bool b)
Set a task as atomic, meaning that it cannot be aborted during execution.
-
inline void set_partitionable(bool b)
Set a task as partitionable.
-
inline void task_aborted(bool task_aborted)
-
inline virtual bool task_aborted(void) const final override
This function should return
TRUE
iff the task has been aborted (not completed), and only on the timestep on which it has done so.
-
inline virtual bool task_at_interface(void) const override
If
TRUE
, then the robot is currently at a task interface for this task.
-
inline size_t task_exec_count(void) const
-
inline void task_exec_count_inc(void)
Increment the count of the # of times the task has been executed. Execution may have terminated due to abort or completion, but that is tracked elsewhere.
-
inline virtual const time_estimate &task_exec_estimate(void) const final override
Return the current execution time estimate for a task. Execution estimate should include interface time.
-
virtual void task_execute(void) = 0
The method that all tasks must define that specifies how to execute the task.
-
inline virtual const time_estimate &task_interface_estimate(size_t i) const final override
Return the current interface time estimate for interface i for a task.
-
inline virtual int task_last_active_interface(void) const final override
Get the ID of the last active interface.
- Returns:
The ID, or -1 if an interface has not yet been completed.
-
inline virtual rtypes::timestep task_last_exec_time(void) const override
This function should return the execution time of the most recent execution of this task. Execution time includes interface time.
-
inline virtual rtypes::timestep task_last_interface_time(size_t i) const override
This function should return the interface time of the most recent interface time for the task.
Public Static Attributes
-
static const std::string kAbortSrcExec = "exec"
-
static const std::string kAbortSrcInterface = "interface"
-
static constexpr const size_t kMAX_INTERFACES = 2
Protected Functions
-
virtual rtypes::timestep current_time(void) const = 0
Get the current time.
-
inline void interface_enter(size_t i)
-
inline void interface_exit(size_t i)
-
inline bool interface_in_prog(size_t i) const
-
virtual rtypes::timestep interface_time_calc(size_t i, const rtypes::timestep &start_time) = 0
Calculate the interface time of the current task for use in abort calculations.
- Parameters:
i – The interface ID.
start_time – The timestep upon which the task entered the interface.
-
inline void interface_time_mark_finish(size_t i)
-
inline void interface_time_mark_start(size_t i)
Mark the current timestep as the begin of a task’s interface.