Momentum Scripting v1
Loading...
Searching...
No Matches
Joint.h
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 without having a written signed agreement with Algoryx Simulation AB.
9
10Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
11from using this software, unless otherwise stated in written agreements with
12Algoryx Simulation AB.
13*/
14
15#ifndef MOMENTUM_JOINT_H
16#define MOMENTUM_JOINT_H
17
18#include "momentum_export.h"
19#include "momentum_namespace.h"
20
21#include "macros.h"
22#include "RigidBody.h"
23#include "AffineMatrix4x4.h"
24#include "Vec3.h"
25
26#include <memory>
27
28#ifndef SWIG
30namespace agx
31{
32 class Constraint;
33}
35#endif
36
37namespace MOMENTUM_NAMESPACE
38{
39
40 class HingeJoint;
41 class PrismaticJoint;
42 class CylindricalJoint;
43 class BallJoint;
44 class LockJoint;
45 class SpringJoint;
46
50 class MOMENTUM_EXPORT Joint
51 {
52 public:
54 {
57 Z
58 };
59#ifndef SWIG
61
65 Joint(agx::Constraint* constraint);
66
70 Joint();
72#endif
73
78 bool getEnabled() const;
79
80#ifndef AGX_MOMENTUM_ANALYSIS_API
87 void setEnabled(bool enabled);
88#endif
89
96 std::shared_ptr<RigidBody> getBody(int body) const;
97
104
105#ifndef AGX_MOMENTUM_ANALYSIS_API
113 void setTransformation(int body, const AffineMatrix4x4& transform);
114#endif
115
122 Vec3 getBodyForce(int body) const;
123
130 Vec3 getBodyTorque(int body) const;
131
139
140#ifndef AGX_MOMENTUM_ANALYSIS_API
148 void setTranslationalElasticity(DegreeOfFreedom dof, double elasticity);
149#endif
150
157
158#ifndef AGX_MOMENTUM_ANALYSIS_API
166 void setRotationalElasticity(DegreeOfFreedom dof, double elasticity);
167#endif
168
175
176#ifndef AGX_MOMENTUM_ANALYSIS_API
184 void setTranslationalDamping(DegreeOfFreedom dof, double damping);
185#endif
186
193
194#ifndef AGX_MOMENTUM_ANALYSIS_API
202 void setRotationalDamping(DegreeOfFreedom dof, double damping);
203#endif
204
206 std::shared_ptr<HingeJoint> asHingeJoint();
207
209 std::shared_ptr<PrismaticJoint> asPrismaticJoint();
210
212 std::shared_ptr<CylindricalJoint> asCylindricalJoint();
213
215 std::shared_ptr<BallJoint> asBallJoint();
216
218 std::shared_ptr<LockJoint> asLockJoint();
219
221 std::shared_ptr<SpringJoint> asSpringJoint();
222
227 std::string getName() const;
228
230 virtual std::string __str__() const;
232
233 bool operator==(const Joint& other) const;
234
237 virtual ~Joint();
239
240 protected:
241 // Because each constraint have different DOF setup we need to make this function in each specific joint
242 virtual int getAgxTranslationalDOF(DegreeOfFreedom ) const { return -1; }
243 virtual int getAgxRotationalDOF(DegreeOfFreedom ) const { return -1; }
244
245 agx::Real getDampingInternal(int agxDOF) const;
246 void setDampingInternal(int agxDOF, double damping);
247
248#ifndef SWIG
250 agx::Constraint* m_constraint;
252#endif
253 };
254
255 V1_DECLARE_CONTAINER_TYPE(Joint);
256} // namespace momentum
257
258
259#endif
Matrix class for rigid transformations (translation, rotation).
Definition: AffineMatrix4x4.h:51
Base class for all joints.
Definition: Joint.h:51
std::shared_ptr< HingeJoint > asHingeJoint()
double getRotationalDamping(DegreeOfFreedom dof) const
Get the rotational damping along the axis of the joint, in newton-meter-seconds per radian.
void setTranslationalElasticity(DegreeOfFreedom dof, double elasticity)
Set the translational elasticity along the axis of the joint, in newton per meter.
double getTranslationalDamping(DegreeOfFreedom dof) const
Get the translational damping along the axis of the joint, in newton-seconds per meter.
void setTranslationalDamping(DegreeOfFreedom dof, double damping)
Set the translational damping along the axis of the joint, in newton-seconds per meter.
bool operator==(const Joint &other) const
virtual int getAgxRotationalDOF(DegreeOfFreedom) const
Definition: Joint.h:243
void setTransformation(int body, const AffineMatrix4x4 &transform)
Set the attachment transformation in the world frame of the specified body.
DegreeOfFreedom
Definition: Joint.h:54
@ X
Definition: Joint.h:55
@ Y
Definition: Joint.h:56
void setRotationalElasticity(DegreeOfFreedom dof, double elasticity)
Set the rotational elasticity along the axis of the joint, in newton per radian.
std::shared_ptr< BallJoint > asBallJoint()
std::shared_ptr< RigidBody > getBody(int body) const
Return the body at position 0 or 1, 1 can be nullptr, if that is the case, it is attached to world.
void setDampingInternal(int agxDOF, double damping)
std::shared_ptr< PrismaticJoint > asPrismaticJoint()
bool getEnabled() const
Is the joint is enabled?
std::string getName() const
Get the name of the Joint.
virtual int getAgxTranslationalDOF(DegreeOfFreedom) const
Definition: Joint.h:242
void setRotationalDamping(DegreeOfFreedom dof, double damping)
Set the rotational damping along the axis of the joint, in newton-meter-seconds per radian.
std::shared_ptr< CylindricalJoint > asCylindricalJoint()
std::shared_ptr< SpringJoint > asSpringJoint()
void setEnabled(bool enabled)
Set to true if the joint should be enabled and should interact with the simulation.
agx::Real getDampingInternal(int agxDOF) const
AffineMatrix4x4 getTransformation(int body) const
Get the transformation in the world frame of the attachment of specified body.
double getTranslationalElasticity(DegreeOfFreedom dof) const
Get the translational elasticity along the axis of the joint.
Vec3 getBodyTorque(int body) const
Get the torque that the joint exerts on the specified body in the frame of the body,...
std::shared_ptr< LockJoint > asLockJoint()
double getRotationalElasticity(DegreeOfFreedom dof) const
Get the rotational elasticity along the axis of the joint, in newton per radian.
Vec3 getBodyForce(int body) const
Get the force that the joint exerts on the specified body in the frame of the body,...
A 3 dimensional vector which can be used to define a point or a vector and contains basic arithmetic.
Definition: Vec3.h:40
Namespace for Momentum Scripting API.
Definition: AffineMatrix4x4.h:29