1#ifndef BITSIM_COSIM_COSIM_SUBSYSTEM_H
2#define BITSIM_COSIM_COSIM_SUBSYSTEM_H
43 virtual std::vector<real_t>
outputs(
const std::vector<real_t> &inputs)
const = 0;
49 const std::vector<real_t> &u_end) = 0;
72 using rhs_type = std::function<std::vector<real_t>(
real_t,
const std::vector<real_t> &,
73 const std::vector<real_t> &)>;
74 using output_type = std::function<std::vector<real_t>(
const std::vector<real_t> &,
75 const std::vector<real_t> &)>;
92 std::vector<real_t>
outputs(
const std::vector<real_t> &inputs)
const override;
95 const std::vector<real_t> &u_end)
override;
97 void save()
override { saved_ = x_; }
101 const std::vector<real_t> &
state() const noexcept {
return x_; }
106 std::vector<real_t> x_;
107 std::vector<real_t> saved_;
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
A part of a coupled system that a co-simulation steps on its own: a robot, a trailer,...
Definition cosim_subsystem.h:29
virtual uint_t n_outputs() const =0
virtual std::vector< real_t > outputs(const std::vector< real_t > &inputs) const =0
The outputs at the present time, with the inputs at the present time.
virtual void do_step(real_t t, real_t H, const std::vector< real_t > &u_begin, const std::vector< real_t > &u_end)=0
Advance from t to t + H, the inputs moving linearly from u_begin to u_end.
virtual uint_t n_inputs() const =0
virtual ~CoSimSubsystem()=default
virtual void restore()=0
Go back to the state save() remembered.
virtual void save()=0
Remember the present state.
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)
Definition cosim_subsystem.cpp:11
void save() override
Remember the present state.
Definition cosim_subsystem.h:97
uint_t n_outputs() const override
Definition cosim_subsystem.h:90
const std::vector< real_t > & state() const noexcept
Definition cosim_subsystem.h:101
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.
Definition cosim_subsystem.cpp:22
std::function< std::vector< real_t >(real_t, const std::vector< real_t > &, const std::vector< real_t > &)> rhs_type
Definition cosim_subsystem.h:72
std::function< std::vector< real_t >(const std::vector< real_t > &, const std::vector< real_t > &)> output_type
Definition cosim_subsystem.h:74
uint_t n_inputs() const override
Definition cosim_subsystem.h:88
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.
Definition cosim_subsystem.cpp:32
uint_t n_substeps() const noexcept
Definition cosim_subsystem.h:103
void restore() override
Go back to the state save() remembered.
Definition cosim_subsystem.h:99
Definition co_simulation.cpp:9
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20