plant_interface.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_PLANT_INTERFACE_H_
26 #define SRC_PLANTS_INCLUDE_CORBO_PLANTS_PLANT_INTERFACE_H_
27 
28 #include <corbo-core/factory.h>
30 #include <corbo-core/types.h>
31 
32 #ifdef MESSAGE_SUPPORT
33 #include <corbo-communication/messages/plants/plant.pb.h>
34 #endif
35 
36 #include <memory>
37 
38 namespace corbo {
39 
55 {
56  public:
57  using Ptr = std::shared_ptr<PlantInterface>;
58  using ControlVector = Eigen::VectorXd;
59  using StateVector = Eigen::VectorXd;
60  using OutputVector = Eigen::VectorXd;
61 
63  virtual ~PlantInterface() {}
64 
66  virtual Ptr getInstance() const = 0;
67 
70 
72  virtual int getInputDimension() const = 0;
74  virtual int getOutputDimension() const = 0;
75 
76  virtual bool requiresFutureControls() const = 0;
77 
78  virtual bool requiresFutureStates() const = 0;
79 
81  virtual bool initialize() { return true; }
82 
84  virtual void stop() {}
85 
86  virtual void reset() {}
87 
98  virtual bool control(const ControlVector& u, const Duration& dt, const Time& t, SignalTargetInterface* signal_target = nullptr,
99  const std::string& ns = "");
100 
112  virtual bool control(const TimeSeries::ConstPtr& u_sequence, const TimeSeries::ConstPtr& x_sequence, const Duration& dt, const Time& t,
113  SignalTargetInterface* signal_target = nullptr, const std::string& ns = "") = 0;
114 
124  virtual bool output(OutputVector& output, const Time& t, SignalTargetInterface* signal_target = nullptr, const std::string& ns = "") = 0;
125 
135  virtual void getAvailableSignals(SignalTargetInterface& signal_target, const std::string& ns = "") const {}
136 
142  virtual bool setState(const Eigen::Ref<const Eigen::VectorXd>& state) { return false; }
143 
144 #ifdef MESSAGE_SUPPORT
145  virtual void toMessage(messages::Plant& message) const {}
148  virtual void fromMessage(const messages::Plant& message, std::stringstream* issues = nullptr) {}
149 #endif
150 };
151 
153 #define FACTORY_REGISTER_PLANT(type) FACTORY_REGISTER_OBJECT(type, PlantInterface)
154 
155 } // namespace corbo
156 
157 #endif // SRC_PLANTS_INCLUDE_CORBO_PLANTS_PLANT_INTERFACE_H_
Generic factory object.
Definition: factory.h:68
virtual Ptr getInstance() const =0
Return a newly created shared instance of the implemented class.
virtual void getAvailableSignals(SignalTargetInterface &signal_target, const std::string &ns="") const
Retrieve available signals from the plant.
virtual bool requiresFutureStates() const =0
virtual void stop()
Stop plant (you might probably use this to set the plant into a safe setpoint)
static Factory< PlantInterface > & getFactory()
Get access to the associated factory.
Interface class for signal targets.
Representation of time stamps.
Definition: time.h:251
virtual int getInputDimension() const =0
Return the plant input dimension (u)
virtual bool requiresFutureControls() const =0
Eigen::VectorXd StateVector
virtual ~PlantInterface()
Virtual destructor.
static Factory & instance()
< Retrieve static instance of the factory
Definition: factory.h:72
Eigen::VectorXd ControlVector
std::shared_ptr< PlantInterface > Ptr
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:192
virtual bool initialize()
Initialize plant.
virtual int getOutputDimension() const =0
Return the plant output dimension (y)
virtual bool setState(const Eigen::Ref< const Eigen::VectorXd > &state)
Set/move plant to a desired state (if possible)
virtual bool control(const ControlVector &u, const Duration &dt, const Time &t, SignalTargetInterface *signal_target=nullptr, const std::string &ns="")
Send commands to plant.
Eigen::VectorXd OutputVector
virtual bool output(OutputVector &output, const Time &t, SignalTargetInterface *signal_target=nullptr, const std::string &ns="")=0
Retrieve current plant output (measurements)
virtual void reset()
std::shared_ptr< const TimeSeries > ConstPtr
Definition: time_series.h:65
Representation of time durations.
Definition: time.h:106
Interface class for plants.


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