bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::cosim::OdeSubsystem Class Referencefinal

A subsystem given by its equations: the state x moves with dx/dt = f(t, x, u), and the outputs are y = h(x, u). More...

#include <cosim_subsystem.h>

Inheritance diagram for bitsim::cosim::OdeSubsystem:
Collaboration diagram for bitsim::cosim::OdeSubsystem:

Public Types

using rhs_type
using output_type

Public Member Functions

 OdeSubsystem (std::vector< real_t > x0, uint_t n_inputs, uint_t n_outputs, rhs_type f, output_type h, uint_t n_substeps=10)
uint_t n_inputs () const override
uint_t n_outputs () const override
std::vector< real_t > outputs (const std::vector< real_t > &inputs) const override
 The outputs at the present time, with the inputs at the present time.
void do_step (real_t t, real_t H, const std::vector< real_t > &u_begin, const std::vector< real_t > &u_end) override
 Advance from t to t + H, the inputs moving linearly from u_begin to u_end.
void save () override
 Remember the present state.
void restore () override
 Go back to the state save() remembered.
const std::vector< real_t > & state () const noexcept
uint_t n_substeps () const noexcept
Public Member Functions inherited from bitsim::cosim::CoSimSubsystem
virtual ~CoSimSubsystem ()=default

Detailed Description

A subsystem given by its equations: the state x moves with dx/dt = f(t, x, u), and the outputs are y = h(x, u).

do_step() takes n_substeps steps of fourth order Runge-Kutta per macro step, with the inputs interpolated linearly within the step.

Member Typedef Documentation

◆ output_type

Initial value:
std::function<std::vector<real_t>(const std::vector<real_t> &,
const std::vector<real_t> &)>

◆ rhs_type

Initial value:
std::function<std::vector<real_t>(real_t, const std::vector<real_t> &,
const std::vector<real_t> &)>
double real_t
real_t
Definition bitsim_types.h:20

Constructor & Destructor Documentation

◆ OdeSubsystem()

bitsim::cosim::OdeSubsystem::OdeSubsystem ( std::vector< real_t > x0,
uint_t n_inputs,
uint_t n_outputs,
rhs_type f,
output_type h,
uint_t n_substeps = 10 )
Parameters
x0the initial state
n_inputshow many inputs f and h take
n_outputshow many outputs h gives
fthe right-hand side, dx/dt = f(t, x, u)
hthe outputs, y = h(x, u)
n_substepsthe Runge-Kutta steps per macro step

Member Function Documentation

◆ do_step()

void bitsim::cosim::OdeSubsystem::do_step ( real_t t,
real_t H,
const std::vector< real_t > & u_begin,
const std::vector< real_t > & u_end )
overridevirtual

Advance from t to t + H, the inputs moving linearly from u_begin to u_end.

Implements bitsim::cosim::CoSimSubsystem.

◆ n_inputs()

uint_t bitsim::cosim::OdeSubsystem::n_inputs ( ) const
inlineoverridevirtual

◆ n_outputs()

uint_t bitsim::cosim::OdeSubsystem::n_outputs ( ) const
inlineoverridevirtual

◆ n_substeps()

uint_t bitsim::cosim::OdeSubsystem::n_substeps ( ) const
inlinenoexcept

◆ outputs()

std::vector< real_t > bitsim::cosim::OdeSubsystem::outputs ( const std::vector< real_t > & inputs) const
overridevirtual

The outputs at the present time, with the inputs at the present time.

Outputs that depend on the inputs directly, a force computed from a position that comes in, are called direct feedthrough; the master resolves them, see CoSimulation.

Implements bitsim::cosim::CoSimSubsystem.

◆ restore()

void bitsim::cosim::OdeSubsystem::restore ( )
inlineoverridevirtual

Go back to the state save() remembered.

Implements bitsim::cosim::CoSimSubsystem.

◆ save()

void bitsim::cosim::OdeSubsystem::save ( )
inlineoverridevirtual

Remember the present state.

Implements bitsim::cosim::CoSimSubsystem.

◆ state()

const std::vector< real_t > & bitsim::cosim::OdeSubsystem::state ( ) const
inlinenoexcept

The documentation for this class was generated from the following files: