AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
VelocityConstraint.h
Go to the documentation of this file.
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 unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17
18#pragma once
19
20#include <agx/Constraint.h>
23
24
25/*
26This file contains various constraint related classes used by the FixedVelocityEngine.
27*/
28
29
30namespace agxDriveTrain
31{
36 class AGXMODEL_EXPORT ElementaryVelocityConstraint : public agx::ElementaryConstraintN<1>
37 {
38 public:
39 ElementaryVelocityConstraint();
40
44 virtual agx::UInt getJacobian(
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:
130 virtual void render(agxRender::RenderManager* canvas, float scale) const override;
131
133
135 void setTargetVelocity(agx::Real targetVelocity);
136
138
139 protected:
140 void addNotification() override;
141
144 virtual int getNumDOF() const override;
145
146 private:
147 VelocityConstraintImplementation* m_velocityConstraint;
148 };
149
150
151}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#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
#define AGXMODEL_EXPORT
A constraint holding a single VelocityConstraintImplementation.
void addNotification() override
Called when added to a simulation.
VelocityConstraint(agxPowerLine::RotationalUnit *rotationalUnit)
Create a VelocityConstraint for the given rotational unit.
void setRotationalDimension(agxPowerLine::RotationalDimension *rotationalDim)
virtual void render(agxRender::RenderManager *canvas, float scale) const override
Inherited method of how to render this constraint into DebugRenderer.
void setTargetVelocity(agx::Real targetVelocity)
virtual int getNumDOF() const override
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:44
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
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:40
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:41
uint8_t UInt8
Definition: Integer.h:30