AGXDynamics  2.31.1.0
MeasurementOperations.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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 AGXCONTROL_MEASUREMENT_OPERATIONS_H
18 #define AGXCONTROL_MEASUREMENT_OPERATIONS_H
19 
20 #include <agxControl/SensorEvent.h>
21 #include <agxControl/EventSensor.h>
22 
27 namespace agxControl
28 {
29 
35  {
36  public:
38  DataFilter(agx::Real samplingTime);
39 
41  virtual void filterValue(agx::Real inValue) = 0;
42 
44  agx::Real getFilteredValue() const;
45 
47  virtual bool setSamplingTime(agx::Real samplingTime);
48 
49  protected:
51  virtual ~DataFilter();
52 
54  // Variables
56  protected:
57  agx::Real m_filteredValue; // Current filtered value
58  agx::Real m_samplingTime; // Discrete sampling time
59  };
60 
62 
69  {
70  public:
72  ExponentialFilter( agx::Real samplingTime, agx::Real periodTime );
73 
75  void filterValue(agx::Real inValue) override;
76 
78  bool setSamplingTime(agx::Real samplingTime) override;
79 
81  bool setPeriodTime(agx::Real periodTime);
82 
83  protected:
85  virtual ~ExponentialFilter();
86 
87  void calculateConstant();
88 
90  // Variables
92  protected:
93  agx::Real m_periodTime; // Period Time
94  agx::Real m_a; // Time constant
95  };
96 
97  /*
98  * Base class of operations used by the measurement sensor. Handles filters for data smoothing.
99  */
102  {
103  public:
106 
107  virtual void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override = 0;
108 
110  agx::Real getFilteredValue() const;
111 
113  agx::Real getRawValue() const;
114 
116  void setFilter(DataFilter * filter);
117 
119  DataFilter* getFilter();
120 
121  protected:
123  virtual ~MeasurementSensorOperation();
124 
126  virtual agx::Real getValue() const = 0;
127 
129  void updateFilter();
130 
132  // Variables
134  protected:
136  };
137 
138  /*
139  * This operations calculates the total mass of the bodies _inside_ the sensor geometry.
140  */
143  {
144  public:
146  CalculateTotalMass(const agx::Name& name = agx::Name());
147 
148  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
149 
151  agx::Real getTotalMass() const;
152 
153  protected:
155  virtual ~CalculateTotalMass() {}
156 
157  virtual agx::Real getValue() const override;
158 
160  // Variables
162  protected:
164  };
165 
166  /*
167  * This operations calculates the total volume of the bodies _inside_ the sensor geometry.
168  */
171  {
172  public:
174  VolumeCalculator(const agx::Name& name = agx::Name());
175 
176  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
177 
179  agx::Real getTotalVolume() const;
180 
182  agx::Real getPackingFractionInSensor() const;
183 
184  protected:
186  virtual ~VolumeCalculator() {}
187 
188  virtual agx::Real getValue() const override;
189 
191  // Variables
193  protected:
197  };
198 
199  /*
200  * Operation that calculates the average mass flow _inside_ the sensor volume
201  */
204  {
205  public:
207  CalculateTotalMassFlow(const agx::Name& name = agx::Name());
208 
209  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
210 
212  agx::Real getTotalMassFlow() const;
213 
214  protected:
217 
218  virtual agx::Real getValue() const override;
219 
221  // Variables
223  protected:
225  };
226 
227  /*
228  * This operations calculates the total mass of the bodies _inside_ the sensor geometry.
229  */
232  {
233  public:
236 
237  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
238 
240  agx::Real getTotalMass() const;
241 
242  protected:
245 
246  virtual agx::Real getValue() const override;
247 
249  // Variables
251  protected:
253  };
254 
255  /*
256  * Operation that calculates the average mass flow _inside_ the sensor volume
257  */
260  {
261  public:
264 
265  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
266 
268  agx::Real getTotalMassFlow() const;
269 
270  protected:
273 
274  virtual agx::Real getValue() const override;
275 
277  // Variables
279  protected:
281  };
282 
283 
284  /*
285  * This operations calculates the total volume of the bodies _inside_ the sensor geometry.
286  */
289  {
290  public:
293 
294  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
295 
297  agx::Real getTotalVolume() const;
298 
300  agx::Real getPackingFractionInSensor() const;
301 
302  protected:
305 
306  virtual agx::Real getValue() const override;
307 
309  // Variables
311  protected:
315  };
316 }
317 
318 #endif
agx::Real getFilteredValue() const
Returns the current filtered value.
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:63
This is a sensor class that can be attached to an geometry in the simulation.
Definition: EventSensor.h:47
Exponential filter that smoothes values in the form: x_filter(t) = a * x_filter(t-1) + ( 1 - a ) * x_...
Base class providing referencing counted objects.
Definition: Referenced.h:113
virtual ~VolumeCalculator()
Default destructor.
virtual ~CalculateTotalRigidBodyDEMMassFlow()
Default destructor.
virtual ~CalculateTotalRigidBodyDEMMass()
Default destructor.
This file defines a set of operations used internally by the measurement sensor to calculate differen...
Definition: EventSensor.h:33
virtual ~CalculateTotalMassFlow()
Default destructor.
virtual ~RigidBodyDEMVolumeCalculator()
Default destructor.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:121
double Real
Definition: Real.h:42
Virtual base class of a data filter for data smoothing.
A specific type of sensor event that triggers a change in the simulation when activated by a contact...
Definition: SensorEvent.h:117
virtual ~CalculateTotalMass()
Default destructor.