simulated_plant.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
25 #ifndef SRC_PLANTS_INCLUDE_CORBO_PLANTS_SIMULATED_PLANT_H_
26 #define SRC_PLANTS_INCLUDE_CORBO_PLANTS_SIMULATED_PLANT_H_
27 
29 
35 
36 #include <memory>
37 
38 namespace corbo {
39 
57 {
58  public:
59  using StateVector = Eigen::VectorXd;
60 
65 
66  // implements interface method
67  Ptr getInstance() const override { return std::make_shared<SimulatedPlant>(); }
68  // implements interface method
69  int getInputDimension() const override { return _dynamics ? _dynamics->getInputDimension() : 0; }
70  // implements interface method
71  int getOutputDimension() const override;
72  // implements interface method
73  bool requiresFutureControls() const override { return false; }
74  // implements interface method
75  bool requiresFutureStates() const override { return false; }
76 
77  // implements interface method
78  // bool control(const ControlVector& u, const Duration& dt, const Time& t, SignalTargetInterface* signal_target = nullptr) override;
79 
80  // implements interface method
81  bool control(const TimeSeries::ConstPtr& u_sequence, const TimeSeries::ConstPtr& x_sequence, const Duration& dt, const Time& t,
82  SignalTargetInterface* signal_target = nullptr, const std::string& ns = "") override;
83 
84  // implements interface method
85  bool output(OutputVector& output, const Time& t, SignalTargetInterface* signal_target = nullptr, const std::string& ns = "") override;
86 
87  // implements interface method
88  void reset() override;
89 
90  // implements interface method
91  bool setState(const Eigen::Ref<const Eigen::VectorXd>& state) override { return setInitialState(state); }
92 
105 
107  bool setInitialState(const StateVector& x_init);
108 
109  // implements interface method
110  void getAvailableSignals(SignalTargetInterface& signal_target, const std::string& ns = "") const override;
111 
112 #ifdef MESSAGE_SUPPORT
113  void toMessage(messages::SimulatedPlant& message) const;
116  void fromMessage(const messages::SimulatedPlant& message, std::stringstream* issues = nullptr);
117 
118  // implements interface method
119  void toMessage(messages::Plant& message) const override { toMessage(*message.mutable_simulated_plant()); }
120  // implements interface method
121  void fromMessage(const messages::Plant& message, std::stringstream* issues = nullptr) override { fromMessage(message.simulated_plant(), issues); }
122 #endif
123 
124  protected:
127 
129 
133 
135 
136  StateVector _initial_state; // just a cache to allow resetting
139 };
140 
142 
143 } // namespace corbo
144 
145 #endif // SRC_PLANTS_INCLUDE_CORBO_PLANTS_SIMULATED_PLANT_H_
void setOutputDisturbance(DisturbanceInterface::Ptr disturbance)
Set plant output disturbance model.
Ptr getInstance() const override
Return a newly created shared instance of the implemented class.
bool setInitialState(const StateVector &x_init)
Specify an initial state x0 [SystemDynamicsInterface::getStateDimension() x 1].
DisturbanceInterface::Ptr _state_disturbance
bool setState(const Eigen::Ref< const Eigen::VectorXd > &state) override
Set/move plant to a desired state (if possible)
void setIntegrator(NumericalIntegratorExplicitInterface::Ptr integrator)
Set a numerical integrator for continuous-time dynamics.
bool control(const TimeSeries::ConstPtr &u_sequence, const TimeSeries::ConstPtr &x_sequence, const Duration &dt, const Time &t, SignalTargetInterface *signal_target=nullptr, const std::string &ns="") override
Send commands to plant.
void setSystemDynamics(SystemDynamicsInterface::Ptr dynamics)
Set the system dynamics of the simulated plant.
Time Delay Object for Piecewise-Constant Signals.
SystemOutputInterface::Ptr _output
NumericalIntegratorExplicitInterface::Ptr _integrator
Interface class for signal targets.
Representation of time stamps.
Definition: time.h:251
Adapter class for plant simulation.
std::shared_ptr< SystemOutputInterface > Ptr
DisturbanceInterface::Ptr _output_disturbance
bool output(OutputVector &output, const Time &t, SignalTargetInterface *signal_target=nullptr, const std::string &ns="") override
Retrieve current plant output (measurements)
void getAvailableSignals(SignalTargetInterface &signal_target, const std::string &ns="") const override
Retrieve available signals from the plant.
void setStateDisturbance(DisturbanceInterface::Ptr disturbance)
Set plant state disturbance model.
std::shared_ptr< DisturbanceInterface > Ptr
bool requiresFutureStates() const override
Eigen::VectorXd StateVector
TimeValueBuffer _time_value_buffer
bool requiresFutureControls() const override
Eigen::VectorXd ControlVector
#define FACTORY_REGISTER_PLANT(type)
std::shared_ptr< PlantInterface > Ptr
std::shared_ptr< NumericalIntegratorExplicitInterface > Ptr
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:192
SystemDynamicsInterface::Ptr _dynamics
int getOutputDimension() const override
Return the plant output dimension (y)
void setInputDisturbance(DisturbanceInterface::Ptr disturbance)
Set plant input disturbance model.
DisturbanceInterface::Ptr _input_disturbance
Eigen::VectorXd OutputVector
SimulatedPlant()
Default constructor.
void setOutputFunction(SystemOutputInterface::Ptr output)
Set the output function of the simulated plant.
std::shared_ptr< const TimeSeries > ConstPtr
Definition: time_series.h:65
int getInputDimension() const override
Return the plant input dimension (u)
Representation of time durations.
Definition: time.h:106
ControlVector _current_control
std::shared_ptr< SystemDynamicsInterface > Ptr
Interface class for plants.


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:07:20