AGX Dynamics  2.37.3.2
VelocityConstraint.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 
18 #pragma once
19 
20 #include <agx/Constraint.h>
23 
24 
25 /*
26 This file contains various constraint related classes used by the FixedVelocityEngine.
27 */
28 
29 
30 namespace agxDriveTrain
31 {
36  class AGXMODEL_EXPORT ElementaryVelocityConstraint : public agx::ElementaryConstraintN<1>
37  {
38  public:
39  ElementaryVelocityConstraint();
40 
44  virtual agx::UInt getJacobian(
45  agx::Jacobian6DOFElement* G, agx::UInt numBlocks,
46  agx::UInt row, agx::GWriteState::Enum writeState) override;
47 
51  virtual agx::UInt getVelocity(agx::Real* v, agx::UInt row) const override;
52 
56  virtual agx::UInt getViolation(agx::Real* b, agx::UInt row) override;
57 
58  agx::Real getTargetVelocity();
59  void setTargetVelocity(agx::Real targetVelocity);
60 
61  void setSlot(agx::UInt8 slot);
62 
63  virtual agx::Bool isImpacting() const override;
64 
65  virtual void storeLightData(agxStream::StorageStream& str) const override;
66  virtual void restoreLightData(agxStream::StorageStream& str) override;
67 
68  AGXSTREAM_DECLARE_SERIALIZABLE(agxDriveTrain::ElementaryVelocityConstraint);
69 
70  protected:
71  virtual ~ElementaryVelocityConstraint() {}
72 
73  private:
74  // To avoid warning C4512. And these really should not be copyable.
75  void operator=(const ElementaryVelocityConstraint&) {}
76 
77  private:
78  agx::Real m_targetVelocity;
79  agx::UInt8 m_slot;
80  };
81 
82 
86  class AGXMODEL_EXPORT VelocityConstraintImplementation : public agx::ConstraintImplementation, public agxStream::Serializable
87  {
88  public:
89  VelocityConstraintImplementation(agxPowerLine::RotationalUnit* rotationalUnit);
90  void setRotationalDimension(agxPowerLine::RotationalDimension* rotationalDim);
91 
92  agx::Real getCurrentTorque();
93 
94  agx::Real getTargetVelocity();
95  void setTargetVelocity(agx::Real targetVelocity);
96 
97  virtual bool updateValid() override;
98 
99  virtual void storeLightData(agxStream::StorageStream& str) const override;
100  virtual void restoreLightData(agxStream::StorageStream& str) override;
101 
102  AGXSTREAM_DECLARE_SERIALIZABLE(agxDriveTrain::VelocityConstraintImplementation);
103 
104  protected:
105  virtual ~VelocityConstraintImplementation() {}
106  VelocityConstraintImplementation();
107 
108  private:
109  agxPowerLine::RotationalDimension* m_rotationalDimension;
110  ElementaryVelocityConstraint* m_elementaryConstraint;
111  };
112 
114 
116 
122  class AGXMODEL_EXPORT VelocityConstraint : public agx::Constraint
123  {
124  public:
128  VelocityConstraint(agxPowerLine::RotationalUnit* rotationalUnit);
129  void setRotationalDimension(agxPowerLine::RotationalDimension* rotationalDim);
130  virtual void render(agxRender::RenderManager* canvas, float scale) const override;
131 
132  agx::Real getCurrentTorque();
133 
134  agx::Real getTargetVelocity();
135  void setTargetVelocity(agx::Real targetVelocity);
136 
138 
139  protected:
140  VelocityConstraint();
141  virtual ~VelocityConstraint();
142  virtual int getNumDOF() const override;
143 
144  private:
145  VelocityConstraintImplementation* m_velocityConstraint;
146  };
147 
148 
149 }
A rotational unit has one degree of freedom.
bool Bool
Definition: Integer.h:48
uint8_t UInt8
Definition: Integer.h:38
A constraint holding a single VelocityConstraintImplementation.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
A library of agxPowerLine components designed to model the various parts of a vehicle drive train...
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc...
uint32_t UInt
Definition: Integer.h:34
The rotational has one rotational degree of freedom.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
#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
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
#define AGXMODEL_EXPORT
double Real
Definition: Real.h:42
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:98
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:97