Class TestAlgorithm

Inheritance Relationships

Base Type

  • public IAlgorithm

Class Documentation

class mimir::algorithm::TestAlgorithm : public IAlgorithm

Test algorithm with first order response.

Implements a first order response \(\dat x=\frac{x-x_d}{T}\), where \(x_d\) the is desired output, given by inputs:signal:topic DDS signal in the YAML file, and \(T=5\) is the time constant in seconds. The differential equation is integrated using [17] and its output is published to outputs:response:topic every time_step_ms milliseconds.

Name

Symbol

Description

Causality

Variability

signal

\(u\)

Desired output.

input

discrete

response

\(y\)

Output response.

output

continuous

Public Functions

explicit TestAlgorithm(const YAML::Node &config, boost::statechart::fifo_scheduler<> &scheduler, boost::statechart::fifo_scheduler<>::processor_handle machine, dds::pub::Publisher publisher, dds::sub::Subscriber subscriber)

TestAlgorithm 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 TestAlgorithm 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
inputs:
  signal:                # DDS type: fkin::IdVec1d
    topic: test_signal
    id: Test
    max_age_ms: -1
outputs:                 # DDS type: fkin::IdVec1d
  response:
    topic: test_output
    id: Test

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 ~TestAlgorithm()

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)

Helper function that queues event to state machine.

Private Functions

inline void step_time()

March simulation time one time step ahead.

TestAlgorithm() = 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.

const YAML::Node m_config

YAML configuration for algorithm.