25 #ifndef SRC_PLANTS_INCLUDE_CORBO_PLANTS_SIMULATED_PLANT_THREADED_H_ 26 #define SRC_PLANTS_INCLUDE_CORBO_PLANTS_SIMULATED_PLANT_THREADED_H_ 65 Ptr getInstance()
const override {
return std::make_shared<SimulatedPlantThreaded>(); }
74 void reset()
override;
89 #ifdef MESSAGE_SUPPORT 90 void toMessage(messages::SimulatedPlantThreaded& message)
const;
93 void fromMessage(
const messages::SimulatedPlantThreaded& message, std::stringstream* issues =
nullptr);
96 void toMessage(messages::Plant& message)
const override { toMessage(*message.mutable_simulated_plant_threaded()); }
98 void fromMessage(
const messages::Plant& message, std::stringstream* issues =
nullptr)
override 100 fromMessage(message.simulated_plant_threaded(), issues);
123 #endif // SRC_PLANTS_INCLUDE_CORBO_PLANTS_SIMULATED_PLANT_THREADED_H_ std::mutex _control_mutex
Ptr getInstance() const override
Return a newly created shared instance of the implemented class.
std::mutex _current_state_mutex
bool setState(const Eigen::Ref< const Eigen::VectorXd > &state) override
Set/move plant to a desired state (if possible)
Interface class for signal targets.
Representation of time stamps.
Adapter class for plant simulation.
std::shared_ptr< SystemOutputInterface > Ptr
bool output(OutputVector &output, const Time &t, SignalTargetInterface *signal_target=nullptr, const std::string &ns="") override
Retrieve current plant output (measurements)
void setSimulationRate(double sim_rate)
Specify rate for the simulation thread.
Eigen::VectorXd StateVector
Eigen::VectorXd ControlVector
#define FACTORY_REGISTER_PLANT(type)
std::shared_ptr< PlantInterface > Ptr
A matrix or vector expression mapping an existing expression.
SimulatedPlantThreaded()
Default constructor.
bool initialize() override
Initialize plant.
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.
Adapter class for plant simulation (threaded version)
Eigen::VectorXd OutputVector
void stop() override
Stop plant (you might probably use this to set the plant into a safe setpoint)
std::thread _worker_thread
std::shared_ptr< const TimeSeries > ConstPtr
Representation of time durations.
virtual ~SimulatedPlantThreaded()
std::shared_ptr< SystemDynamicsInterface > Ptr