AGX Dynamics  2.37.3.2
MeasurementOperations.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 AGXCONTROL_MEASUREMENT_OPERATIONS_H
18 #define AGXCONTROL_MEASUREMENT_OPERATIONS_H
19 
20 #include <agxControl/SensorEvent.h>
21 #include <agxControl/EventSensor.h>
22 
23 namespace agxControl
24 {
25 
31  {
32  public:
34  DataFilter(agx::Real samplingTime);
35 
37  virtual void filterValue(agx::Real inValue) = 0;
38 
40  agx::Real getFilteredValue() const;
41 
43  virtual bool setSamplingTime(agx::Real samplingTime);
44 
45  protected:
47  virtual ~DataFilter();
48 
50  // Variables
52  protected:
53  agx::Real m_filteredValue; // Current filtered value
54  agx::Real m_samplingTime; // Discrete sampling time
55  };
56 
58 
65  {
66  public:
68  ExponentialFilter( agx::Real samplingTime, agx::Real periodTime );
69 
71  void filterValue(agx::Real inValue) override;
72 
74  bool setSamplingTime(agx::Real samplingTime) override;
75 
77  bool setPeriodTime(agx::Real periodTime);
78 
79  protected:
81  virtual ~ExponentialFilter();
82 
83  void calculateConstant();
84 
86  // Variables
88  protected:
89  agx::Real m_periodTime; // Period Time
90  agx::Real m_a; // Time constant
91  };
92 
93  /*
94  * Base class of operations used by the measurement sensor. Handles filters for data smoothing.
95  */
98  {
99  public:
102 
103  virtual void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override = 0;
104 
106  agx::Real getFilteredValue() const;
107 
109  agx::Real getRawValue() const;
110 
112  void setFilter(DataFilter * filter);
113 
115  DataFilter* getFilter();
116 
117  protected:
119  virtual ~MeasurementSensorOperation();
120 
122  virtual agx::Real getValue() const = 0;
123 
125  void updateFilter();
126 
128  // Variables
130  protected:
132  };
133 
134  /*
135  * This operations calculates the total mass of the bodies _inside_ the sensor geometry.
136  */
139  {
140  public:
142  CalculateTotalMass(const agx::Name& name = agx::Name());
143 
144  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
145 
147  agx::Real getTotalMass() const;
148 
149  protected:
151  virtual ~CalculateTotalMass() {}
152 
153  virtual agx::Real getValue() const override;
154 
156  // Variables
158  protected:
160  };
161 
162  /*
163  * This operations calculates the total volume of the bodies _inside_ the sensor geometry.
164  */
167  {
168  public:
170  VolumeCalculator(const agx::Name& name = agx::Name());
171 
172  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
173 
175  agx::Real getTotalVolume() const;
176 
178  agx::Real getPackingFractionInSensor() const;
179 
180  protected:
182  virtual ~VolumeCalculator() {}
183 
184  virtual agx::Real getValue() const override;
185 
187  // Variables
189  protected:
193  };
194 
195  /*
196  * Operation that calculates the average mass flow _inside_ the sensor volume
197  */
200  {
201  public:
203  CalculateTotalMassFlow(const agx::Name& name = agx::Name());
204 
205  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
206 
208  agx::Real getTotalMassFlow() const;
209 
210  protected:
213 
214  virtual agx::Real getValue() const override;
215 
217  // Variables
219  protected:
221  };
222 
223  /*
224  * This operations calculates the total mass of the bodies _inside_ the sensor geometry.
225  */
228  {
229  public:
232 
233  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
234 
236  agx::Real getTotalMass() const;
237 
238  protected:
241 
242  virtual agx::Real getValue() const override;
243 
245  // Variables
247  protected:
249  };
250 
251  /*
252  * Operation that calculates the average mass flow _inside_ the sensor volume
253  */
256  {
257  public:
260 
261  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
262 
264  agx::Real getTotalMassFlow() const;
265 
266  protected:
269 
270  virtual agx::Real getValue() const override;
271 
273  // Variables
275  protected:
277  };
278 
279 
280  /*
281  * This operations calculates the total volume of the bodies _inside_ the sensor geometry.
282  */
285  {
286  public:
289 
290  void postContactHandling(agxSDK::Simulation *simulation, EventSensor * sensor) override;
291 
293  agx::Real getTotalVolume() const;
294 
296  agx::Real getPackingFractionInSensor() const;
297 
298  protected:
301 
302  virtual agx::Real getValue() const override;
303 
305  // Variables
307  protected:
311  };
312 }
313 
314 #endif
agx::Real getFilteredValue() const
Returns the current filtered value.
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:59
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:119
virtual ~VolumeCalculator()
Default destructor.
virtual ~CalculateTotalRigidBodyDEMMassFlow()
Default destructor.
virtual ~CalculateTotalRigidBodyDEMMass()
Default destructor.
This namespace contains general operation and action classes which can be used to control a agxSDK::S...
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:126
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.