AGXDynamics  2.35.0.2
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 
44  Actuator1DOF(agx::Constraint1DOF* constraint1DOF);
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.
51  virtual agxPowerLine::DimensionAndSide getConnectableDimension(
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 
61  void synchronizeDirections();
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;
79  void restore(agxStream::InputArchive& in) override;
80 
81  protected:
82  Actuator1DOF();
83 
84  virtual ~Actuator1DOF();
85 
86  void synchronizeUnits( agx::Constraint1DOF* constraint );
87  void replaceActuatorUnit( Unit* oldUnit, Unit* newUnit );
88 
89  void detachActuatorUnitsFromEachOther();
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:
126  RotationalActuator( agx::Hinge* hinge );
127 
131  agx::Bool getUseHighSpeedMode( ) const;
132 
143  void setUseHighSpeedMode( agx::Bool highSpeedMode );
144 
150  agxPowerLine::RotationalUnit* getInputShaft();
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 
160  virtual void getConnectableDimensionTypes(
162  agxPowerLine::Side side) const override;
163 
164  virtual agx::Real calculateRelativeGradient() const override;
165 
166  virtual agx::Vec3 calculateWorldDirection(
167  Side side,
168  agxPowerLine::PhysicalDimension::Type dimensionType) const override;
169 
170  virtual agx::Vec3 calculateLocalDirection(
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:
236  agxPowerLine::RotationalUnitRef m_inputShaft;
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:
258  virtual void getConnectableDimensionTypes(
260  agxPowerLine::Side side) const override;
261 
265  virtual agxPowerLine::DimensionAndSide getConnectableDimension(
267  agxPowerLine::Side side) override;
268 
272  virtual agx::Real calculateRelativeGradient() const override;
273 
274  virtual agx::Vec3 calculateWorldDirection(
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 
301  virtual ~TranslationalActuator();
302 
303  void initialize();
304 
305  void connectActuatorConnector();
306 
307  private:
309  agxPowerLine::detail::TranslationalActuatorConnectorRef m_actuatorConnector;
310  };
311 
313 
314 
315 }
316 
317 #endif
agxPowerLine::Actuator
Definition: Actuator.h:49
RotationalUnit.h
agx::Real
double Real
Definition: Real.h:42
agxPowerLine::Side
Side
Definition: Sides.h:30
Hinge.h
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxStream::out
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.
Definition: OutputArchive.h:412
agx::Constraint1DOF
Specialization for constraints that have only one degree of freedom such as Hinge and Prismatic.
Definition: Constraint.h:676
agx::ConstraintObserver
agx::observer_ptr< Constraint > ConstraintObserver
Definition: Constraint.h:53
DOXYGEN_END_INTERNAL_BLOCK
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
agx::Prismatic
A prismatic joint keeps a fixed relative orientation between the attached bodies but allows them to s...
Definition: Prismatic.h:67
TranslationalDimension.h
DOXYGEN_START_INTERNAL_BLOCK
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
agxPowerLine::Actuator::store
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
agxPowerLine::Actuator::restore
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:221
agxPowerLine::PhysicalDimension
Pure virtual class.
Definition: PhysicalDimension.h:93
AGXSTREAM_DECLARE_SERIALIZABLE
#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
agxPowerLine::PhysicalDimension::Type
int Type
Definition: PhysicalDimension.h:96
agx::observer_ptr
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Definition: observer_ptr.h:60
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
Prismatic.h
agxStream::in
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
agxPowerLine::Unit
Pure virtual class.
Definition: Unit.h:72
agx::ref_ptr< agxPowerLine::ActuatorBodyUnit >
TranslationalActuatorConnector.h
agxPowerLine::TranslationalActuatorRef
agx::ref_ptr< TranslationalActuator > TranslationalActuatorRef
Definition: Actuator1DOF.h:312
agxPowerLine::RotationalActuator
Definition: Actuator1DOF.h:123
agxPowerLine::TranslationalActuator::dont_create_input
static dont_create_input_t dont_create_input
Definition: Actuator1DOF.h:296
agxPowerLine::Actuator1DOF::ConstraintObserver
Observer that not only sets the Constraint1DOF pointer to nullptr on object deletion,...
Definition: Actuator1DOF.h:103
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agxPowerLine::Actuator1DOF
Definition: Actuator1DOF.h:40
agxPowerLine::Actuator1DOF::m_constraint1DOF
ConstraintObserver m_constraint1DOF
Definition: Actuator1DOF.h:117
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxPowerLine
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:23
Actuator.h
agx::Bool
bool Bool
Definition: Integer.h:48
agxPowerLine::TranslationalActuator
Definition: Actuator1DOF.h:246
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agx::Hinge
The hinge constraint between two rigid bodies or one rigid body and the world.
Definition: Hinge.h:103
agxPowerLine::RotationalUnit
A rotational unit has one degree of freedom.
Definition: RotationalUnit.h:29
agx::DistanceJoint
This joint will preserve the initial distance between a body and a point in world coordinate or betwe...
Definition: DistanceJoint.h:27
DistanceJoint.h
agx::Vec3T< Real >
TranslationalUnit.h
RotationalActuatorConnector.h
agxStream::ElementTypes::Type
Type
Definition: Types.h:37
agxPowerLine::TranslationalActuator::dont_create_input_t
Definition: Actuator1DOF.h:295
agxPowerLine::DimensionAndSide
std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > DimensionAndSide
Definition: PhysicalDimension.h:78