AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
SimulationControl.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXSDK_SIMULATION_CONTROL_H
18#define AGXSDK_SIMULATION_CONTROL_H
19
20#include <agx/agx.h>
21#include <agx/Singleton.h>
22#include <agx/String.h>
23#include <agxSDK/Simulation.h>
25
26
27namespace agxMex {
28 class Simulation;
29}
30
31
32namespace agxNet {
33 class CoSimulationClient;
34}
35
36
37
38
39namespace agxSDK {
40
42
45 public:
47 size_t numInputValues, size_t numOutputValues);
48
50 size_t getNumInputValues() const;
51
53 size_t getNumOutputValues() const;
54
55 virtual bool applyInput(const agxSDK::Simulation* simulation, const agx::RealVector& input) const = 0;
56 virtual bool obtainOutput(const agxSDK::Simulation* simulation, const agx::RealVector& output) const = 0;
57
58 protected:
61 };
62
68 {
69
70 public:
71 friend class agxMex::Simulation;
74
75
76
79
80
82 public:
84 void clear();
85 public:
89 };
90
92 public:
94 void clear();
95 public:
99 };
100
101 public:
104
109 void addInputArgument( const agx::String& portName, SimulationControlArgument* inputArgument );
110
115 void addOutputArgument(const agx::String& portName, SimulationControlArgument* outputArgument);
116
122 void addInitInputArgument(const agx::String& portName, SimulationControlArgument* inputArgument);
123
129 void addInitOutputArgument(const agx::String& portName, SimulationControlArgument* outputArgument);
130
138 bool step(const agx::RealVector& inputs, const agx::RealVector& outputs, agxSDK::Simulation* simulation);
139
140
141 bool applyInitInputValues(agxSDK::Simulation* simulation, const agx::RealVector& initInputs) const;
142
143 bool obtainInitOutputValues(agxSDK::Simulation* simulation, const agx::RealVector& initOutputs) const;
144
145
146
149
152
155
158
164 const char* getInputValueName(size_t valueNr);
165
171 const char* getOutputValueName(size_t valueNr);
172
179 const char* getInitInputValueName(size_t valueNr);
180
187 const char* getInitOutputValueName(size_t valueNr);
188
189 void clear();
190
193
194 SINGLETON_CLASSNAME_METHOD();
195
196 protected:
198 void shutdown() override;
200
201 private:
202 static SimulationControl* s_instance;
203 InputArgumentCollection m_inputArguments;
204 OutputArgumentCollection m_outputArguments;
205 InputArgumentCollection m_initInputArguments;
206 OutputArgumentCollection m_initOutputArguments;
207 mutable agx::String m_errorMessage;
208 };
209
210}
211
212#endif // AGXSDK_SIMULATION_CONTROL_H
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXPHYSICS_EXPORT
Class for receiving serialized agxSDK::Simulation:s from remote host.
Base class for input/output arguments.
SimulationControlArgument(size_t numInputValues, size_t numOutputValues)
virtual bool obtainOutput(const agxSDK::Simulation *simulation, const agx::RealVector &output) const =0
virtual bool applyInput(const agxSDK::Simulation *simulation, const agx::RealVector &input) const =0
A class for adding input and output arguments, to be used when running a co-simulation.
agx::Vector< SimulationControlArgumentRef > OutputArgumentRefVector
void addOutputArgument(const agx::String &portName, SimulationControlArgument *outputArgument)
Adds an output argument.
size_t getTotalNumInitInputValues() const
Get total size of input values from all input arguments only for scene initialization.
void addInitOutputArgument(const agx::String &portName, SimulationControlArgument *outputArgument)
Adds an output argument.
size_t getTotalNumInitOutputValues() const
Get total size of output values from all output arguments only for scene initialization.
static SimulationControl * instance()
Gets (and possibly creates) and instance of the singleton.
void addInitInputArgument(const agx::String &portName, SimulationControlArgument *inputArgument)
Adds an input argument.
bool step(const agx::RealVector &inputs, const agx::RealVector &outputs, agxSDK::Simulation *simulation)
Steps the simulation one time step, using inputs and returning outputs.
const char * getInitOutputValueName(size_t valueNr)
Returns name associated to output value only for scene initialization, by the argument it belongs to.
const char * getInputValueName(size_t valueNr)
Returns name associated to input value by the argument it belongs to.
size_t getTotalNumInputValues() const
Get total size of input values from all input arguments.
bool applyInitInputValues(agxSDK::Simulation *simulation, const agx::RealVector &initInputs) const
const char * getInitInputValueName(size_t valueNr)
Returns name associated to input value only for scene initialization, by the argument it belongs to.
void addInputArgument(const agx::String &portName, SimulationControlArgument *inputArgument)
Adds an input argument.
void shutdown() override
Implement this method to cleanup your Singleton class.
agx::String getLastErrorMessage() const
agx::Vector< SimulationControlArgumentRef > InputArgumentRefVector
bool obtainInitOutputValues(agxSDK::Simulation *simulation, const agx::RealVector &initOutputs) const
const char * getOutputValueName(size_t valueNr)
Returns name associated to output value by the argument it belongs to.
size_t getTotalNumOutputValues() const
Get total size of output values from all output arguments.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:130
Base class providing referencing counted objects.
Definition: Referenced.h:120
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:31
Templated vector class.
Definition: agx/Vector.h:53
This namespace contains functionality for using AGX with Matlab/Simulink.
Containins classes for sending/reading data over sockets as well as compression functionality.
Definition: MacUtil.h:23
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31