AGX Dynamics  2.35.0.1
Actuator1DOF.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 #ifndef AGXPOWERLINE_ACTUATOR_1DOF_H
19 #define AGXPOWERLINE_ACTUATOR_1DOF_H
20 
21 #include <agxPowerLine/Actuator.h>
26 #include <agx/Prismatic.h>
27 #include <agx/DistanceJoint.h>
28 #include <agx/Hinge.h>
30 
31 namespace agx
32 {
33  class RigidBody;
34 }
35 
36 namespace agxPowerLine
37 {
39 
41  {
42  public:
43 
45 
46  // Begin inhertied from agxPowerLine::Actuator.
47  virtual agx::Real calculateRelativeValue() const override;
48  // End inhertied from PowerLine::Actuator.
49 
50  // Begin inhertied from PowerLine::Unit.
53  agxPowerLine::Side side) override;
54  // End inherited from PowerLine::Unit.
55 
56 
57  // Begin inherited from PowerLine::SubGraph.
58  virtual bool preUpdate(agx::Real timeStamp) override;
59  // End inherited from PowerLine::SubGraph
60 
62 
66  virtual bool store(agxStream::StorageStream& str) const override;
67 
69 
73  virtual bool restore(agxStream::StorageStream& str) override;
74 
76 
78  void store(agxStream::OutputArchive& out) const override;
80 
81  protected:
83 
84  virtual ~Actuator1DOF();
85 
87  void replaceActuatorUnit( Unit* oldUnit, Unit* newUnit );
88 
90 
91  virtual agx::Vec3 getDir1() const override;
92  virtual agx::Vec3 getDir2() const override;
93  virtual agx::Vec3 getCmToAnchorPos1() const override;
94  virtual agx::Vec3 getCmToAnchorPos2() const override;
95  virtual agx::Vec3 getSeparation() const override;
96 
97 
98  protected:
103  class ConstraintObserver : public agx::observer_ptr<agx::Constraint1DOF>
104  {
105  public:
106  ConstraintObserver(agx::Constraint1DOF* actuatedConstraint, Actuator1DOF* owningActuator);
107  virtual void objectDeleted(void*) override;
108 
110  private:
111  Actuator1DOF* m_owningActuator;
112  };
113 
114  friend class ConstraintObserver;
115 
116  protected:
118  agx::ref_ptr<agxPowerLine::ActuatorBodyUnit> m_dummyActuatorBodyUnits[2];
119  };
120 
121 
122 
124  {
125  public:
127 
132 
143  void setUseHighSpeedMode( agx::Bool highSpeedMode );
144 
151 
152 
153  virtual void setEnable(bool enabled);
154  virtual bool getEnable() const;
155 
156  // Called by the rest of the power line framework.
157  public:
158  virtual bool preUpdate(agx::Real timeStamp) override;
159 
162  agxPowerLine::Side side) const override;
163 
164  virtual agx::Real calculateRelativeGradient() const override;
165 
167  Side side,
168  agxPowerLine::PhysicalDimension::Type dimensionType) const override;
169 
171  Side side,
172  int dimensionType) const override;
173 
177  virtual bool store(agxStream::StorageStream& out) const override;
178 
182  virtual bool restore(agxStream::StorageStream& in) override;
183 
185 
187  public:
188  virtual agxPowerLine::DimensionAndSide getConnectableDimension(
190  agxPowerLine::Side side) override;
191 
192 
193  protected:
195 
196  /*
197  There are subclasses of RotationalActuator that want to create their own
198  versions of the input shaft and the internal connector. For example, the
199  hydraulics package contains the ImpellerActuator, which uses a FlowUnit
200  for input.
201 
202  Any subclass that uses the dont_create_input tag when constructing the
203  RotationalActuator base class must implement get- and setEnable.
204 
205  This part of the inheritence tree could use some redesign. There should
206  be one base class, inheriting from Actuator1DOF, that knows about hinges
207  and how to get Jacobians from them, and a collection of subclasses
208  derived of off that that knows about the type of the input and the custom
209  constraint that binds the input PhysicalDimension to the
210  ActuatorBodyUnits.
211 
212  Perhaps we should even move the concept of input unit and internal
213  constraint up a bit more and put it inside Actuator1DOF. In that case we
214  don't have to deal with the oddities of the current setEnable
215  implementation, which is just bad. A base class implementation does the
216  wrong thing for the derived classes.
217 
218  Not sure if the name RotationalActuator should be used for the base class
219  or the subclass that has a RotationalUnit input. The latter is more
220  consistent with the current implementation and a better user-level name
221  (the base class is not user-level), but what should the base class be
222  named?
223  */
224  struct AGXMODEL_EXPORT dont_create_input_t {};
225  static dont_create_input_t dont_create_input;
226  RotationalActuator(agx::Hinge* hinge, dont_create_input_t);
227 
228  virtual ~RotationalActuator();
229 
230  void connectActuatorConnector();
231  void disconnectActuatorConnector();
232  void reconnectActuatorConnector();
234 
235  protected:
237  agxPowerLine::detail::RotationalActuatorConnectorRef m_actuatorConnector;
238 
239  agx::Bool m_useHighSpeedMode;
240  };
241 
243 
244 
245 
247  {
248  public:
250 
252 
253  agxPowerLine::TranslationalUnit* getInputRod();
254 
255 
256  // Called by the rest of the power line framework.
257  public:
260  agxPowerLine::Side side) const override;
261 
267  agxPowerLine::Side side) override;
268 
272  virtual agx::Real calculateRelativeGradient() const override;
273 
275  Side side,
276  agxPowerLine::PhysicalDimension::Type dimensionType) const override;
277 
278  virtual agx::Vec3 calculateLocalDirection(Side side, int dimensionType) const override;
279 
283  virtual bool store(agxStream::StorageStream& str) const override;
284 
288  virtual bool restore(agxStream::StorageStream& str) override;
289 
291 
292  protected:
294 
297 
300 
302 
303  void initialize();
304 
306 
307  private:
309  agxPowerLine::detail::TranslationalActuatorConnectorRef m_actuatorConnector;
310  };
311 
313 
314 
315 }
316 
317 #endif
#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
#define AGXMODEL_EXPORT
Observer that not only sets the Constraint1DOF pointer to nullptr on object deletion,...
Definition: Actuator1DOF.h:104
ConstraintObserver(agx::Constraint1DOF *actuatedConstraint, Actuator1DOF *owningActuator)
virtual void objectDeleted(void *) override
virtual agx::Vec3 getCmToAnchorPos2() const override
void store(agxStream::OutputArchive &out) const override
virtual agx::Vec3 getCmToAnchorPos1() const override
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
void synchronizeUnits(agx::Constraint1DOF *constraint)
virtual agx::Vec3 getDir2() const override
void replaceActuatorUnit(Unit *oldUnit, Unit *newUnit)
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxPowerLine::Actuator1DOF)
ConstraintObserver m_constraint1DOF
Definition: Actuator1DOF.h:117
virtual bool preUpdate(agx::Real timeStamp) override
virtual agx::Vec3 getSeparation() const override
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
virtual agxPowerLine::DimensionAndSide getConnectableDimension(agxPowerLine::PhysicalDimension::Type type, agxPowerLine::Side side) override
void restore(agxStream::InputArchive &in) override
virtual agx::Real calculateRelativeValue() const override
virtual agx::Vec3 getDir1() const override
Actuator1DOF(agx::Constraint1DOF *constraint1DOF)
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
virtual void setEnable(bool enabled)
virtual bool getEnable() const
virtual agx::Real calculateRelativeGradient() const override
agx::Bool getUseHighSpeedMode() const
virtual agx::Vec3 calculateLocalDirection(Side side, int dimensionType) const override
virtual bool preUpdate(agx::Real timeStamp) override
RotationalActuator(agx::Hinge *hinge)
virtual bool restore(agxStream::StorageStream &in) override
Restores internal data from stream.
void setUseHighSpeedMode(agx::Bool highSpeedMode)
Set the usage of high speed mode.
virtual void getConnectableDimensionTypes(agxPowerLine::PhysicalDimension::TypeVector &types, agxPowerLine::Side side) const override
virtual bool store(agxStream::StorageStream &out) const override
Stores internal data into stream.
agxPowerLine::RotationalUnit * getInputShaft()
virtual agx::Vec3 calculateWorldDirection(Side side, agxPowerLine::PhysicalDimension::Type dimensionType) const override
A rotational unit has one degree of freedom.
TranslationalActuator(agx::Prismatic *prismatic)
virtual agx::Vec3 calculateLocalDirection(Side side, int dimensionType) const override
static dont_create_input_t dont_create_input
Definition: Actuator1DOF.h:296
agxPowerLine::TranslationalUnit * getInputRod()
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
virtual void getConnectableDimensionTypes(agxPowerLine::PhysicalDimension::TypeVector &types, agxPowerLine::Side side) const override
TranslationalActuator(agx::Prismatic *prismatic, dont_create_input_t)
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
TranslationalActuator(agx::DistanceJoint *distance, dont_create_input_t)
virtual agx::Real calculateRelativeGradient() const override
Restores internal data from stream.
virtual agxPowerLine::DimensionAndSide getConnectableDimension(agxPowerLine::PhysicalDimension::Type type, agxPowerLine::Side side) override
Stores internal data into stream.
virtual agx::Vec3 calculateWorldDirection(Side side, agxPowerLine::PhysicalDimension::Type dimensionType) const override
TranslationalActuator(agx::DistanceJoint *distance)
Pure virtual class.
Definition: Unit.h:73
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
Specialization for constraints that have only one degree of freedom such as Hinge and Prismatic.
Definition: Constraint.h:677
This joint will preserve the initial distance between a body and a point in world coordinate or betwe...
Definition: DistanceJoint.h:28
The hinge constraint between two rigid bodies or one rigid body and the world.
Definition: Hinge.h:104
A prismatic joint keeps a fixed relative orientation between the attached bodies but allows them to s...
Definition: Prismatic.h:68
Templated vector class.
Definition: agx/Vector.h:53
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Definition: observer_ptr.h:61
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:24
agx::ref_ptr< TranslationalActuator > TranslationalActuatorRef
Definition: Actuator1DOF.h:312
std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > DimensionAndSide
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition: Integer.h:48
double Real
Definition: Real.h:42