AGX Dynamics  2.37.2.0
SimulationControl.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx 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>
24 #include <agx/agxPhysics_export.h>
25 
26 
27 namespace agxMex {
28  class Simulation;
29 }
30 
31 
32 namespace agxNet {
33  class CoSimulationClient;
34 }
35 
36 
37 
38 
39 namespace 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:
86  InputArgumentRefVector arguments;
89  };
90 
92  public:
94  void clear();
95  public:
96  OutputArgumentRefVector arguments;
99  };
100 
101  public:
103  static SimulationControl* instance();
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 
148  size_t getTotalNumInputValues() const;
149 
151  size_t getTotalNumOutputValues() const;
152 
154  size_t getTotalNumInitInputValues() const;
155 
157  size_t getTotalNumInitOutputValues() const;
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 
192  agx::String getLastErrorMessage() const;
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
Containins classes for sending/reading data over sockets as well as compression functionality.
Definition: MacUtil.h:22
AGXTERRAIN_EXPORT void clear()
void AGXPHYSICS_EXPORT shutdown()
Shutdown of the AGX Dynamics API will be done when the number of shutdown matches the number of calls...
A class for adding input and output arguments, to be used when running a co-simulation.
This namespace contains functionality for using AGX with Matlab/Simulink.
#define AGXPHYSICS_EXPORT
agx::Vector< SimulationControlArgumentRef > InputArgumentRefVector
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Class for receiving serialized agxSDK::Simulation:s from remote host.
Base class providing referencing counted objects.
Definition: Referenced.h:119
agx::Vector< SimulationControlArgumentRef > OutputArgumentRefVector
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
Base class for input/output arguments.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:30