AGX Dynamics  2.35.0.1
VelocityConstraint.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 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 
83  ElementaryVelocityConstraint* asElementaryVelocityConstraint(agx::Constraint* constraint);
84 
85 
86 
90  class VelocityConstraintImplementation : public agx::ConstraintImplementation, public agxStream::Serializable
91  {
92  public:
93  VelocityConstraintImplementation(agxPowerLine::RotationalUnit* rotationalUnit);
94  void setRotationalDimension(agxPowerLine::RotationalDimension* rotationalDim);
95 
96  agx::Real getCurrentTorque();
97 
98  agx::Real getTargetVelocity();
99  void setTargetVelocity(agx::Real targetVelocity);
100 
101  virtual bool updateValid() override;
102 
103  virtual void storeLightData(agxStream::StorageStream& str) const override;
104  virtual void restoreLightData(agxStream::StorageStream& str) override;
105 
106  AGXSTREAM_DECLARE_SERIALIZABLE(agxDriveTrain::VelocityConstraintImplementation);
107 
108  protected:
109  virtual ~VelocityConstraintImplementation() {}
110  VelocityConstraintImplementation();
111 
112  private:
113  agxPowerLine::RotationalDimension* m_rotationalDimension;
114  ElementaryVelocityConstraint* m_elementaryConstraint;
115  };
116 
117 
118 
119  AGX_DECLARE_POINTER_TYPES(VelocityConstraint);
120 
126  class VelocityConstraint : public agx::Constraint
127  {
128  public:
132  VelocityConstraint(agxPowerLine::RotationalUnit* rotationalUnit);
133  void setRotationalDimension(agxPowerLine::RotationalDimension* rotationalDim);
134  virtual void render(agxRender::RenderManager* canvas, float scale) const override;
135 
136  agx::Real getCurrentTorque();
137 
138  agx::Real getTargetVelocity();
139  void setTargetVelocity(agx::Real targetVelocity);
140 
141  AGXSTREAM_DECLARE_SERIALIZABLE(agxDriveTrain::VelocityConstraint);
142 
143  protected:
144  VelocityConstraint();
145  virtual ~VelocityConstraint();
146  virtual int getNumDOF() const override;
147 
148  private:
149  VelocityConstraintImplementation* m_velocityConstraint;
150  };
152 
153 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#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
The rotational has one rotational degree of freedom.
A rotational unit has one degree of freedom.
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
The base class for a constraint.
Definition: Constraint.h:89
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
A library of agxPowerLine components designed to model the various parts of a vehicle drive train.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition: Integer.h:48
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
uint8_t UInt8
Definition: Integer.h:38