AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
IMUOutput.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#pragma once
19
20#include <agx/Referenced.h>
21
22#include <limits>
23
24namespace agxSensor
25{
27
51 {
52 public:
53 enum Field : int32_t
54 {
110 SENSOR_MAX_X_F64 = ( ( ( 1 << 30 ) - 3 ) / 3) * 3,
112 SENSOR_MAX_Y_F64 = SENSOR_MAX_X_F64 + 1,
114 SENSOR_MAX_Z_F64 = SENSOR_MAX_X_F64 + 2,
116 NUM_FIELDS
117 };
118
119 using FieldVector = std::vector<Field>;
120
121 public:
126 static size_t sizeOf( Field field );
127
132 static const char* getFieldName( Field field );
133
137 IMUOutput() = default;
138
142 template<Field... field>
143 void build();
144
150 IMUOutput& add( Field field );
151
156 void setPaddingValue( const agx::Real& value );
157
162 virtual size_t getElementSize() const override;
163
167 virtual const BinaryOutputBuffer& getData() override;
168
176 virtual bool hasUnreadData( bool markAsRead = true ) override;
177
179
180 public:
181 virtual ~IMUOutput() = default;
182
183 virtual void result( const CallbackData& data ) override;
184 virtual void cleanup() override;
185
187
189
190 private:
191 FieldVector m_fields{};
192 size_t m_elementSize{ 0u };
193 agx::Real m_paddingValue{ std::numeric_limits<agx::Real>::signaling_NaN() };
194 bool m_hasUnreadData{ false };
195 BinaryOutputBuffer m_output{};
196 };
197
198 template<IMUOutput::Field... field>
200 {
201 m_fields.clear();
202 m_elementSize = 0u;
203 ( this->add( field ), ... );
204 }
205
207
208 #pragma pack(push, 1)
209 struct SixDoFValue
210 {
211 agx::Real x0, y0, z0;
212 agx::Real x1, y1, z1;
213
214 inline SixDoFValue() {}
215 inline SixDoFValue( const agx::Vec3& a, const agx::Vec3& b )
216 : x0( a.x() )
217 , y0( a.y() )
218 , z0( a.z() )
219 , x1( b.x() )
220 , y1( b.y() )
221 , z1( b.z() )
222 {
223 }
224 inline SixDoFValue( const SixDoFValue& ) = default;
225 inline SixDoFValue& operator=( const SixDoFValue& ) = default;
226
227 inline agx::Vec3 getTriplet( const size_t i ) const noexcept
228 {
229 if ( i == 0 )
230 return agx::Vec3( x0, y0, z0 );
231 else if ( i == 1 )
232 return agx::Vec3( x1, y1, z1 );
233 else
234 return agx::Vec3();
235 }
236 };
237
238 struct NineDoFValue
239 {
240 agx::Real x0, y0, z0;
241 agx::Real x1, y1, z1;
242 agx::Real x2, y2, z2;
243
244 inline NineDoFValue() {}
245 inline NineDoFValue( const agx::Vec3& a, const agx::Vec3& b, const agx::Vec3& c )
246 : x0( a.x() )
247 , y0( a.y() )
248 , z0( a.z() )
249 , x1( b.x() )
250 , y1( b.y() )
251 , z1( b.z() )
252 , x2( c.x() )
253 , y2( c.y() )
254 , z2( c.z() )
255 {
256 }
257 inline NineDoFValue( const NineDoFValue& ) = default;
258 inline NineDoFValue& operator=( const NineDoFValue& ) = default;
259
260 inline agx::Vec3 getTriplet( const size_t i ) const noexcept
261 {
262 if ( i == 0 )
263 return agx::Vec3( x0, y0, z0 );
264 else if ( i == 1 )
265 return agx::Vec3( x1, y1, z1 );
266 else if ( i == 2 )
267 return agx::Vec3( x2, y2, z2 );
268 else
269 return agx::Vec3();
270 }
271 };
272 #pragma pack(pop)
273
274 class AGXSENSOR_EXPORT IMUOutputSixDoF : public IMUOutput
275 {
276 public:
277 IMUOutputSixDoF();
278 };
279
280 class AGXSENSOR_EXPORT IMUOutputNineDoF : public IMUOutput
281 {
282 public:
283 IMUOutputNineDoF();
284 };
285
287}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXSENSOR_EXPORT
Buffer used for sensor output of a wide range of output element types.
IMU sensor output data where IMUOutput::Field is used to define the data available.
Definition: IMUOutput.h:51
virtual size_t getElementSize() const override
"Element size" is the summed data size of the currently added fields.
virtual bool hasUnreadData(bool markAsRead=true) override
std::vector< Field > FieldVector
Definition: IMUOutput.h:119
virtual const BinaryOutputBuffer & getData() override
static size_t sizeOf(Field field)
static const char * getFieldName(Field field)
void build()
Add one or more fields, build a matching data structure.
Definition: IMUOutput.h:199
IMUOutput()=default
Default constructor.
IMUOutput & add(Field field)
Add new field.
@ SENSOR_1_X_F64
1x 64-bit floating point x-axis output from the second sensor in the IMU.
Definition: IMUOutput.h:80
@ SENSOR_1_Y_F64
1x 64-bit floating point y-axis output from the second sensor in the IMU.
Definition: IMUOutput.h:82
@ ACCELEROMETER_Z_F64
1x 64-bit floating point accelerometer z-axis output.
Definition: IMUOutput.h:60
@ SENSOR_0_Z_F64
1x 64-bit floating point z-axis output from the first sensor in the IMU.
Definition: IMUOutput.h:78
@ GYROSCOPE_Y_F64
1x 64-bit floating point gyroscope y-axis output.
Definition: IMUOutput.h:64
@ MAGNETOMETER_Y_F64
1x 64-bit floating point magnetometer y-axis output.
Definition: IMUOutput.h:70
@ ACCELEROMETER_X_F64
1x 64-bit floating point accelerometer x-axis output.
Definition: IMUOutput.h:56
@ ACCELEROMETER_Y_F64
1x 64-bit floating point accelerometer y-axis output.
Definition: IMUOutput.h:58
@ SENSOR_0_Y_F64
1x 64-bit floating point y-axis output from the first sensor in the IMU.
Definition: IMUOutput.h:76
@ MAGNETOMETER_Z_F64
1x 64-bit floating point magnetometer z-axis output.
Definition: IMUOutput.h:72
@ SENSOR_1_Z_F64
1x 64-bit floating point z-axis output from the second sensor in the IMU.
Definition: IMUOutput.h:84
@ SENSOR_0_X_F64
1x 64-bit floating point x-axis output from the first sensor in the IMU.
Definition: IMUOutput.h:74
@ GYROSCOPE_X_F64
1x 64-bit floating point gyroscope x-axis output.
Definition: IMUOutput.h:62
@ MAGNETOMETER_X_F64
1x 64-bit floating point magnetometer x-axis output.
Definition: IMUOutput.h:68
@ GYROSCOPE_Z_F64
1x 64-bit floating point gyroscope z-axis output.
Definition: IMUOutput.h:66
void setPaddingValue(const agx::Real &value)
Set value to use for padding when no underlying signal data can be found.
Common interface for sensor output data.
Definition: SensorOutput.h:27
System node is a separate step/operation in an execution tree representing a sensor (or such) in a se...
Definition: SystemNode.h:44
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
The agxSensor namespace contains components to model real-time sensors connected to the physics of AG...
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: agx/Vec3.h:36
double Real
Definition: Real.h:41