Class Leadline¶
Defined in File Leadline.hpp
Class Documentation¶
-
class mimir::algorithm::Leadline : public IAlgorithm¶
Leadline predicted response.
This algorithm calculates an expected depth response of the leadline based on the provided input parameters. The output is the solution to the initial value problem over a prediction horizon of
prediction_horizon_sec
seconds, with discretization step equal totime_step_ms
milliseconds.Let \(x(t) \in \mathbb{R}\) be the depth in meters at a given time \(t\). Let \(x_d \in \mathbb{R}\) and \(\tau \in \mathbb{R}_{>0}\) be a setpoint depth [m] and time constant [s], respectively. Suppose \(t_f>0\) is the prediction horizon and \(\delta t\) is a descretization the step size. Define the set of discretized time points as \(\mathcal{T} := \{ t : t = k\delta t\, \forall k \in \mathbb{Z}_{\geq 0}, t \in [0, t_f] \}\). The solution to the initial value problem
\begin{align} \dat x(t) &= \frac{x(t)-x_d}{\tau} \\ x(0) &= 0 \end{align}is \(x(t)\) and the solution set \(\mathcal{X} := \{ z : z = x(t)\, \forall t \in \mathcal{T} \}\).
The algorithm solution provides \((\mathcal{T},\mathcal{X})\) given \((x_d,\tau)\).
Public Functions
-
explicit Leadline(const YAML::Node &config, boost::statechart::fifo_scheduler<> &scheduler, boost::statechart::fifo_scheduler<>::processor_handle machine, dds::pub::Publisher publisher, dds::sub::Subscriber subscriber)¶
Leadline constructor.
The constructor parses the specification from the given YAML node. It establishes data structures and sets up DDS readers and writers according to the input/output scheme of the algorithm. The following YAML code block shows the expected layout of the
Leadline
map of a input config file. The inputs, outputs, and initial conditions are communicated with DDS communication. Common is their DDS topic and DDS identifier. The specification is deemed self-explanatory.time_step_ms: 200 prediction_horizon_sec: 1000 inputs: parameters: # DDS type: fkin::IdVec2d topic: leadline_parameters id: Leadline default: [350, 160] outputs: # DDS type: fkin::BatchIdVec1d depth: topic: leadline_response id: Leadline
- Parameters
config – [in] YAML configuration from input file.
scheduler – [in] State machine scheduler, needed to post events to state machine.
machine – [in] State machine processor handle, needed to post events to state machine.
publisher – DDS data writer to send data.
subscriber – DDS data reader to receive data.
-
virtual ~Leadline()¶
Destructor.
-
virtual void solve(const std::atomic<bool> &cancel_token)¶
See base class.
-
virtual void initialize(const std::atomic<bool> &cancel_token)¶
See base class.
-
virtual void timer(const std::atomic<bool> &cancel_token)¶
See base class.
-
inline virtual const char *name()¶
Name identifier of algorithm.
-
void event(boost::statechart::event_base *const event)¶
Private Functions
-
inline void step_time()¶
March simulation time one time step ahead.
-
Leadline() = delete¶
Private Members
-
std::unique_ptr<Impl> m_impl¶
Holds the implementation of the algorithm.
-
boost::statechart::fifo_scheduler &m_scheduler¶
Members for state machine.
-
boost::statechart::fifo_scheduler::processor_handle m_stateMachine¶
Member for state machine.
-
const std::chrono::milliseconds m_time_step¶
Discrete time step.
-
std::chrono::steady_clock::time_point m_next_step¶
Simulation time point.
-
std::chrono::system_clock::time_point m_now¶
-
const YAML::Node m_config¶
YAML configuration for algorithm.
-
explicit Leadline(const YAML::Node &config, boost::statechart::fifo_scheduler<> &scheduler, boost::statechart::fifo_scheduler<>::processor_handle machine, dds::pub::Publisher publisher, dds::sub::Subscriber subscriber)¶