Momentum Scripting v1
Deprecated API version. Use Momentum.v2 for new scripts.
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
51 class MOMENTUM_EXPORT Joint
52 {
53 public:
55 {
58 Z
59 };
60#ifndef SWIG
62
66 Joint(agx::Constraint* constraint);
67
71 Joint();
73#endif
74
79 bool getEnabled() const;
80
81#ifndef AGX_MOMENTUM_ANALYSIS_API
88 void setEnabled(bool enabled);
89#endif
90
97 std::shared_ptr<RigidBody> getBody(int body) const;
98
105
106#ifndef AGX_MOMENTUM_ANALYSIS_API
114 void setTransformation(int body, const AffineMatrix4x4& transform);
115#endif
116
123 Vec3 getBodyForce(int body) const;
124
131 Vec3 getBodyTorque(int body) const;
132
140
141#ifndef AGX_MOMENTUM_ANALYSIS_API
149 void setTranslationalElasticity(DegreeOfFreedom dof, double elasticity);
150#endif
151
158
159#ifndef AGX_MOMENTUM_ANALYSIS_API
167 void setRotationalElasticity(DegreeOfFreedom dof, double elasticity);
168#endif
169
176
177#ifndef AGX_MOMENTUM_ANALYSIS_API
185 void setTranslationalDamping(DegreeOfFreedom dof, double damping);
186#endif
187
194
195#ifndef AGX_MOMENTUM_ANALYSIS_API
203 void setRotationalDamping(DegreeOfFreedom dof, double damping);
204#endif
205
207 std::shared_ptr<HingeJoint> asHingeJoint();
208
210 std::shared_ptr<PrismaticJoint> asPrismaticJoint();
211
213 std::shared_ptr<CylindricalJoint> asCylindricalJoint();
214
216 std::shared_ptr<BallJoint> asBallJoint();
217
219 std::shared_ptr<LockJoint> asLockJoint();
220
222 std::shared_ptr<SpringJoint> asSpringJoint();
223
228 std::string getName() const;
229
231 virtual std::string __str__() const;
233
234 bool operator==(const Joint& other) const;
235
238 virtual ~Joint();
240
241 protected:
242 // Because each constraint have different DOF setup we need to make this function in each specific joint
243 virtual int getAgxTranslationalDOF(DegreeOfFreedom ) const { return -1; }
244 virtual int getAgxRotationalDOF(DegreeOfFreedom ) const { return -1; }
245
246 agx::Real getDampingInternal(int agxDOF) const;
247 void setDampingInternal(int agxDOF, double damping);
248
249#ifndef SWIG
251 agx::Constraint* m_constraint;
253#endif
254 };
255
256 V1_DECLARE_CONTAINER_TYPE(Joint);
257} // namespace momentum
258
259
260#endif
Matrix class for rigid transformations (translation, rotation).
Definition: AffineMatrix4x4.h:51
Base class for all joints.
Definition: Joint.h:52
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:244
void setTransformation(int body, const AffineMatrix4x4 &transform)
Set the attachment transformation in the world frame of the specified body.
DegreeOfFreedom
Definition: Joint.h:55
@ X
Definition: Joint.h:56
@ Y
Definition: Joint.h:57
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:243
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