AGX Dynamics
2.37.2.0
RigidBodyAttributeAccessors.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 AGXFMI2_RIGIDBODYATTRIBUTEACCESSORS_H
18
#define AGXFMI2_RIGIDBODYATTRIBUTEACCESSORS_H
19
20
#include <
agxFMI2/export/Variable.h
>
21
#include <
agx/Physics/RigidBodyEntity.h
>
22
#include <
agx/Solver.h
>
23
#include <
agxData/Attribute.h
>
24
25
extern
"C"
26
{
27
#include <FMI2/fmi2Functions.h>
28
}
29
30
namespace
agx
{
31
class
RigidBody;
32
}
33
34
namespace
agxFMI2
35
{
36
namespace
Export
37
{
39
// INPUT VARIABLES
41
AGX_DECLARE_POINTER_TYPES
(
RigidBodyAttributeInputVariableReal
);
42
43
class
AGXFMI_EXPORT
RigidBodyAttributeInputVariableReal
:
public
InputVariable_Real
44
{
45
public
:
46
RigidBodyAttributeInputVariableReal
(
agx::RigidBody
*body,
const
agx::String
& name);
47
48
agx::Physics::RigidBodyRef
getBody();
49
void
setBody(
agx::Physics::RigidBodyRef
body);
50
protected
:
51
virtual
~
RigidBodyAttributeInputVariableReal
();
52
53
protected
:
54
agx::Physics::RigidBodyRef
m_body
;
55
};
56
57
AGX_DECLARE_POINTER_TYPES
(
RigidBodyVec3AttributeInputVariable
);
58
59
// Generic agx::Vec3 attribute
60
class
AGXFMI_EXPORT
RigidBodyVec3AttributeInputVariable
:
public
RigidBodyAttributeInputVariableReal
61
{
62
public
:
63
typedef
agxData::ScalarAttributeT<agx::Vec3>
AttributeT
;
64
65
public
:
66
RigidBodyVec3AttributeInputVariable
(
agx::RigidBody
*body, AttributeT *attribute,
agx::UInt
component,
bool
causalityName =
false
);
67
RigidBodyVec3AttributeInputVariable
(
agx::RigidBody
*body, AttributeT *attribute,
agx::UInt
component,
const
agx::String
& name);
68
virtual
fmi2Status
set
(
agx::Real
value)
override
;
69
virtual
fmi2Status
get
(
agx::Real
& value)
override
;
70
71
void
setDirectionalDerivativeInput(agx::MobilitySolver *solver,
agx::Real
value);
72
73
protected
:
74
virtual
~
RigidBodyVec3AttributeInputVariable
();
75
76
private
:
77
using
InputVariable_Real::get;
78
agx::Real
get
();
79
80
protected
:
81
agx::ref_ptr<AttributeT>
m_attribute
;
82
agx::UInt
m_component
;
83
84
};
85
86
#define RB_VEC3_INPUT_VARIABLE(NAME, ATTRIBUTE_NAME) \
87
class AGXFMI_EXPORT RigidBody ## NAME ## InputVariable : public RigidBodyVec3AttributeInputVariable \
88
{ \
89
public: \
90
RigidBody ## NAME ## InputVariable(agx::RigidBody *body, agx::UInt component, bool causalityName = false) : RigidBodyVec3AttributeInputVariable(body, agx::Physics::RigidBodyModel::ATTRIBUTE_NAME ## Attribute, component, causalityName) {} \
91
\
92
protected: \
93
virtual ~RigidBody ## NAME ## InputVariable() {} \
94
}
95
96
RB_VEC3_INPUT_VARIABLE
(Force, force);
97
RB_VEC3_INPUT_VARIABLE
(Torque, torque);
98
RB_VEC3_INPUT_VARIABLE
(Velocity, velocity);
99
RB_VEC3_INPUT_VARIABLE
(AngularVelocity, angularVelocity);
100
101
AGX_DECLARE_POINTER_TYPES
(
RigidBodyForceAccumulatorInputVariable
);
102
103
class
AGXFMI_EXPORT
RigidBodyForceAccumulatorInputVariable
:
public
RigidBodyVec3AttributeInputVariable
104
{
105
public
:
106
RigidBodyForceAccumulatorInputVariable
(
agx::RigidBody
*body,
agx::UInt
component,
bool
causalityName =
false
);
107
virtual
fmi2Status
set
(
agx::Real
value)
override
;
108
void
apply();
109
110
protected
:
111
virtual
~
RigidBodyForceAccumulatorInputVariable
();
112
113
private
:
114
agx::Real
m_storedValue;
115
};
116
117
AGX_DECLARE_POINTER_TYPES
(
RigidBodyTorqueAccumulatorInputVariable
);
118
119
class
AGXFMI_EXPORT
RigidBodyTorqueAccumulatorInputVariable
:
public
RigidBodyVec3AttributeInputVariable
120
{
121
public
:
122
RigidBodyTorqueAccumulatorInputVariable
(
agx::RigidBody
*body,
agx::UInt
component,
bool
causalityName =
false
);
123
virtual
fmi2Status
set
(
agx::Real
value)
override
;
124
void
apply();
125
126
protected
:
127
virtual
~
RigidBodyTorqueAccumulatorInputVariable
();
128
129
private
:
130
agx::Real
m_storedValue;
131
};
132
133
134
class
AGXFMI_EXPORT
RigidBodyPositionInputVariable
:
public
RigidBodyAttributeInputVariableReal
135
{
136
public
:
137
RigidBodyPositionInputVariable
(
agx::RigidBody
*body,
agx::UInt
component,
bool
causalityName =
false
);
138
virtual
fmi2Status
set
(
agx::Real
value)
override
;
139
virtual
fmi2Status
get
(
agx::Real
& value)
override
;
140
141
protected
:
142
virtual
~
RigidBodyPositionInputVariable
();
143
144
private
:
145
agx::UInt
m_component;
146
};
147
148
class
AGXFMI_EXPORT
RigidBodyRotationQuatInputVariable
:
public
RigidBodyAttributeInputVariableReal
149
{
150
public
:
151
RigidBodyRotationQuatInputVariable
(
agx::RigidBody
*body,
agx::UInt
component,
bool
causalityName =
false
);
152
virtual
fmi2Status
set
(
agx::Real
value)
override
;
153
virtual
fmi2Status
get
(
agx::Real
& value)
override
;
154
155
protected
:
156
virtual
~
RigidBodyRotationQuatInputVariable
();
157
158
private
:
159
agx::UInt
m_component;
160
};
161
162
class
AGXFMI_EXPORT
RigidBodyRotationEulerInputVariable
:
public
RigidBodyAttributeInputVariableReal
163
{
164
public
:
165
RigidBodyRotationEulerInputVariable
(
agx::RigidBody
*body,
agx::UInt
component,
bool
causalityName =
false
);
166
virtual
fmi2Status
set
(
agx::Real
value)
override
;
167
virtual
fmi2Status
get
(
agx::Real
& value)
override
;
168
169
protected
:
170
virtual
~
RigidBodyRotationEulerInputVariable
();
171
172
private
:
173
agx::UInt
m_component;
174
};
175
176
178
// OUTPUT VARIABLES
180
181
// Generic agx::Vec3 attribute
182
183
class
AGXFMI_EXPORT
RigidBodyVec3AttributeOutputVariable
:
public
OutputVariable_Real
184
{
185
public
:
186
typedef
agxData::ScalarAttributeT<agx::Vec3>
AttributeT
;
187
188
public
:
189
RigidBodyVec3AttributeOutputVariable
(
agx::RigidBody
*body, AttributeT *attribute,
agx::UInt
component,
bool
causalityName =
false
);
190
virtual
fmi2Status
get
(
agx::Real
& value)
override
;
191
agx::Real
getDirectionalDerivativeOutput(agx::MobilitySolver *solver, agx::MobilitySolver *referenceSolver);
192
agx::Real
get
(agx::MobilitySolver *solver);
193
194
protected
:
195
virtual
~
RigidBodyVec3AttributeOutputVariable
();
196
197
private
:
198
agx::Physics::RigidBodyRef
m_body;
199
agx::ref_ptr<AttributeT>
m_attribute;
200
agx::UInt
m_component;
201
};
202
203
#define RB_VEC3_OUTPUT_VARIABLE(NAME, ATTRIBUTE_NAME) \
204
class AGXFMI_EXPORT RigidBody ## NAME ## OutputVariable : public RigidBodyVec3AttributeOutputVariable \
205
{ \
206
public: \
207
RigidBody ## NAME ## OutputVariable(agx::RigidBody *body, agx::UInt component, bool causalityName = false) : RigidBodyVec3AttributeOutputVariable(body, agx::Physics::RigidBodyModel::ATTRIBUTE_NAME ## Attribute, component, causalityName) {} \
208
\
209
protected: \
210
virtual ~RigidBody ## NAME ## OutputVariable() {} \
211
}
212
213
RB_VEC3_OUTPUT_VARIABLE
(Force, force);
214
RB_VEC3_OUTPUT_VARIABLE
(Torque, torque);
215
RB_VEC3_OUTPUT_VARIABLE
(AppliedForce, lastForce);
216
RB_VEC3_OUTPUT_VARIABLE
(AppliedTorque, lastTorque);
217
RB_VEC3_OUTPUT_VARIABLE
(Acceleration, linearAcceleration);
218
RB_VEC3_OUTPUT_VARIABLE
(AngularAcceleration, angularAcceleration);
219
RB_VEC3_OUTPUT_VARIABLE
(Velocity, velocity);
220
RB_VEC3_OUTPUT_VARIABLE
(AngularVelocity, angularVelocity);
221
222
223
class
AGXFMI_EXPORT
RigidBodyPositionOutputVariable
:
public
OutputVariable_Real
224
{
225
public
:
226
RigidBodyPositionOutputVariable
(
agx::RigidBody
*body,
agx::UInt
component,
bool
causalityName =
false
);
227
virtual
fmi2Status
get
(
agx::Real
& value)
override
;
228
229
protected
:
230
virtual
~
RigidBodyPositionOutputVariable
();
231
232
private
:
233
agx::Physics::RigidBodyRef
m_body;
234
agx::UInt
m_component;
235
};
236
237
class
AGXFMI_EXPORT
RigidBodyRotationQuatOutputVariable
:
public
OutputVariable_Real
238
{
239
public
:
240
RigidBodyRotationQuatOutputVariable
(
agx::RigidBody
*body,
agx::UInt
component,
bool
causalityName =
false
);
241
virtual
fmi2Status
get
(
agx::Real
& value)
override
;
242
243
protected
:
244
virtual
~
RigidBodyRotationQuatOutputVariable
();
245
246
private
:
247
agx::Physics::RigidBodyRef
m_body;
248
agx::UInt
m_component;
249
};
250
251
class
AGXFMI_EXPORT
RigidBodyRotationEulerOutputVariable
:
public
OutputVariable_Real
252
{
253
public
:
254
RigidBodyRotationEulerOutputVariable
(
agx::RigidBody
*body,
agx::UInt
component,
bool
causalityName =
false
);
255
virtual
fmi2Status
get
(
agx::Real
& value)
override
;
256
257
protected
:
258
virtual
~
RigidBodyRotationEulerOutputVariable
();
259
260
private
:
261
agx::Physics::RigidBodyRef
m_body;
262
agx::UInt
m_component;
263
};
264
}
265
}
266
267
#endif
/* AGXFMI2_RIGIDBODYATTRIBUTEACCESSORS_H */
agxFMI2::Export::RigidBodyAttributeInputVariableReal
Definition:
RigidBodyAttributeAccessors.h:43
agxData::EntityRef< RigidBodyPtr >
agxData::ScalarAttributeT
Definition:
Attribute.h:279
agxFMI2::Export::RigidBodyVec3AttributeInputVariable::m_component
agx::UInt m_component
Definition:
RigidBodyAttributeAccessors.h:82
AGXFMI_EXPORT
#define AGXFMI_EXPORT
agxFMI2::Export::RigidBodyVec3AttributeOutputVariable
Definition:
RigidBodyAttributeAccessors.h:183
agx::AgXString< std::string >
RigidBodyEntity.h
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition:
Referenced.h:254
agxFMI2::Export::RigidBodyForceAccumulatorInputVariable
Definition:
RigidBodyAttributeAccessors.h:103
RB_VEC3_INPUT_VARIABLE
#define RB_VEC3_INPUT_VARIABLE(NAME, ATTRIBUTE_NAME)
Definition:
RigidBodyAttributeAccessors.h:86
agxFMI2::Export::RigidBodyRotationEulerOutputVariable
Definition:
RigidBodyAttributeAccessors.h:251
agxFMI2::Export::RigidBodyVec3AttributeInputVariable
Definition:
RigidBodyAttributeAccessors.h:60
agxFMI2::Export::RigidBodyTorqueAccumulatorInputVariable
Definition:
RigidBodyAttributeAccessors.h:119
agx::UInt
uint32_t UInt
Definition:
Integer.h:34
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition:
AddedMassInteraction.h:22
agxFMI2::Export::RigidBodyVec3AttributeInputVariable::m_attribute
agx::ref_ptr< AttributeT > m_attribute
Definition:
RigidBodyAttributeAccessors.h:81
agxFMI2::Export::RigidBodyRotationQuatInputVariable
Definition:
RigidBodyAttributeAccessors.h:148
Variable.h
Solver.h
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition:
ref_ptr.h:29
agxFMI2::Export::RigidBodyRotationEulerInputVariable
Definition:
RigidBodyAttributeAccessors.h:162
RB_VEC3_OUTPUT_VARIABLE
#define RB_VEC3_OUTPUT_VARIABLE(NAME, ATTRIBUTE_NAME)
Definition:
RigidBodyAttributeAccessors.h:203
agxFMI2::Export::RigidBodyVec3AttributeInputVariable::AttributeT
agxData::ScalarAttributeT< agx::Vec3 > AttributeT
Definition:
RigidBodyAttributeAccessors.h:63
agxFMI2::Export::RigidBodyRotationQuatOutputVariable
Definition:
RigidBodyAttributeAccessors.h:237
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition:
RigidBody.h:54
agxFMI2::Export::RigidBodyVec3AttributeOutputVariable::AttributeT
agxData::ScalarAttributeT< agx::Vec3 > AttributeT
Definition:
RigidBodyAttributeAccessors.h:186
agxFMI2
This namespace contains functionality for using AGX together with version 2 of the Functional Mockup ...
agxFMI2::Export::RigidBodyPositionInputVariable
Definition:
RigidBodyAttributeAccessors.h:134
Attribute.h
agx::Real
double Real
Definition:
Real.h:42
agxFMI2::Export::RigidBodyPositionOutputVariable
Definition:
RigidBodyAttributeAccessors.h:223
agxFMI2::Export::RigidBodyAttributeInputVariableReal::m_body
agx::Physics::RigidBodyRef m_body
Definition:
RigidBodyAttributeAccessors.h:54
include
agxFMI2
export
RigidBodyAttributeAccessors.h
Generated on Sun Jan 28 2024 11:19:33 for AGX Dynamics by
1.8.13