AGXDynamics  2.31.1.0
Actuator1DOF.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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  virtual agx::Real calculateRelativeValue( ) const override;
47 
48  virtual agxPowerLine::DimensionAndSide getConnectableDimension(
50  agxPowerLine::Side side) override;
51 
52  virtual bool preUpdate(agx::Real timeStamp) override;
53 
54  void synchronizeDirections();
55 
59  virtual bool store(agxStream::StorageStream& str) const override;
60 
62 
66  virtual bool restore(agxStream::StorageStream& str) override;
67 
69 
70 
72  void store(agxStream::OutputArchive& out) const override;
73  void restore(agxStream::InputArchive& in) override;
74 
75  protected:
76  Actuator1DOF();
77 
78  virtual ~Actuator1DOF();
79 
80  void synchronizeUnits( agx::Constraint1DOF* constraint );
81  void replaceActuatorUnit( Unit* oldUnit, Unit* newUnit );
82 
83  void detachActuatorUnitsFromEachOther();
84 
85  virtual agx::Vec3 getDir1() const override;
86  virtual agx::Vec3 getDir2() const override;
87  virtual agx::Vec3 getCmToAnchorPos1() const override;
88  virtual agx::Vec3 getCmToAnchorPos2() const override;
89  virtual agx::Vec3 getSeparation() const override;
90 
91 
92  protected:
97  class ConstraintObserver : public agx::observer_ptr<agx::Constraint1DOF>
98  {
99  public:
100  ConstraintObserver(agx::Constraint1DOF* actuatedConstraint, Actuator1DOF* owningActuator);
101  virtual void objectDeleted(void*) override;
102 
104  private:
105  Actuator1DOF* m_owningActuator;
106  };
107 
108  friend class ConstraintObserver;
109 
110  protected:
112  agx::ref_ptr<agxPowerLine::ActuatorBodyUnit> m_dummyActuatorBodyUnits[2];
113  };
114 
115 
116 
118  {
119  public:
120  RotationalActuator( agx::Hinge* hinge );
121 
125  agx::Bool getUseHighSpeedMode( ) const;
126 
137  void setUseHighSpeedMode( agx::Bool highSpeedMode );
138 
144  agxPowerLine::RotationalUnit* getInputShaft();
145 
146 
147  virtual void setEnable(bool enabled);
148  virtual bool getEnable() const;
149 
150  // Called by the rest of the power line framework.
151  public:
152  virtual bool preUpdate(agx::Real timeStamp) override;
153 
154  virtual void getConnectableDimensionTypes(
156  agxPowerLine::Side side) const override;
157 
158  virtual agx::Real calculateRelativeGradient() const override;
159 
160  virtual agx::Vec3 calculateWorldDirection(
161  Side side,
162  agxPowerLine::PhysicalDimension::Type dimensionType) const override;
163 
164  virtual agx::Vec3 calculateLocalDirection(
165  Side side,
166  int dimensionType) const override;
167 
171  virtual bool store(agxStream::StorageStream& out) const override;
172 
176  virtual bool restore(agxStream::StorageStream& in) override;
177 
179 
181  public:
182  virtual agxPowerLine::DimensionAndSide getConnectableDimension(
184  agxPowerLine::Side side) override;
185 
186 
187  protected:
189 
190  /*
191  There are subclasses of RotationalActuator that want to create their own
192  versions of the input shaft and the internal connector. For example, the
193  hydraulics package contains the ImpellerActuator, which uses a FlowUnit
194  for input.
195 
196  Any subclass that uses the dont_create_input tag when constructing the
197  RotationalActuator base class must implement get- and setEnable.
198 
199  This part of the inheritence tree could use some redesign. There should
200  be one base class, inheriting from Actuator1DOF, that knows about hinges
201  and how to get Jacobians from them, and a collection of subclasses
202  derived of off that that knows about the type of the input and the custom
203  constraint that binds the input PhysicalDimension to the
204  ActuatorBodyUnits.
205 
206  Perhaps we should even move the concept of input unit and internal
207  constraint up a bit more and put it inside Actuator1DOF. In that case we
208  don't have to deal with the oddities of the current setEnable
209  implementation, which is just bad. A base class implementation does the
210  wrong thing for the derived classes.
211 
212  Not sure if the name RotationalActuator should be used for the base class
213  or the subclass that has a RotationalUnit input. The latter is more
214  consistent with the current implementation and a better user-level name
215  (the base class is not user-level), but what should the base class be
216  named?
217  */
218  struct AGXMODEL_EXPORT dont_create_input_t {};
219  static dont_create_input_t dont_create_input;
220  RotationalActuator(agx::Hinge* hinge, dont_create_input_t);
221 
222  virtual ~RotationalActuator();
223 
224  void connectActuatorConnector();
225  void disconnectActuatorConnector();
226  void reconnectActuatorConnector();
228 
229  protected:
230  agxPowerLine::RotationalUnitRef m_inputShaft;
231  agxPowerLine::detail::RotationalActuatorConnectorRef m_actuatorConnector;
232 
233  agx::Bool m_useHighSpeedMode;
234  };
235 
237 
238 
239 
241  {
242  public:
244 
246 
247  agxPowerLine::TranslationalUnit* getInputRod();
248 
249 
250  // Called by the rest of the power line framework.
251  public:
252  virtual void getConnectableDimensionTypes(
254  agxPowerLine::Side side) const override;
255 
259  virtual agxPowerLine::DimensionAndSide getConnectableDimension(
261  agxPowerLine::Side side) override;
262 
266  virtual agx::Real calculateRelativeGradient() const override;
267 
268  virtual agx::Vec3 calculateWorldDirection(
269  Side side,
270  agxPowerLine::PhysicalDimension::Type dimensionType) const override;
271 
272  virtual agx::Vec3 calculateLocalDirection(Side side, int dimensionType) const override;
273 
277  virtual bool store(agxStream::StorageStream& str) const override;
278 
282  virtual bool restore(agxStream::StorageStream& str) override;
283 
285 
286  protected:
288 
290  static dont_create_input_t dont_create_input;
291 
292  TranslationalActuator(agx::DistanceJoint* distance, dont_create_input_t);
293  TranslationalActuator(agx::Prismatic* prismatic, dont_create_input_t);
294 
295  virtual ~TranslationalActuator();
296 
297  void initialize();
298 
299  void connectActuatorConnector();
300 
301  private:
303  agxPowerLine::detail::TranslationalActuatorConnectorRef m_actuatorConnector;
304  };
305 
307 
308 
309 }
310 
311 #endif
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
ConstraintObserver m_constraint1DOF
Definition: Actuator1DOF.h:111
static dont_create_input_t dont_create_input
Definition: Actuator1DOF.h:290
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...
A rotational unit has one degree of freedom.
bool Bool
Definition: Integer.h:48
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Definition: observer_ptr.h:60
Observer that not only sets the Constraint1DOF pointer to nullptr on object deletion, but also informs the owning Actuator so the body units can be updated.
Definition: Actuator1DOF.h:97
Pure virtual class.
Definition: Unit.h:72
This joint will preserve the initial distance between a body and a point in world coordinate or betwe...
Definition: DistanceJoint.h:27
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
Specialization for constraints that have only one degree of freedom such as Hinge and Prismatic...
Definition: Constraint.h:674
agx::ref_ptr< TranslationalActuator > TranslationalActuatorRef
Definition: Actuator1DOF.h:306
Templated vector class.
Definition: Vector.h:52
Namespace agx contains the dynamics/math part of the AGX Dynamics API.
The hinge constraint between two rigid bodies or one rigid body and the world.
Definition: Hinge.h:103
A prismatic joint keeps a fixed relative orientation between the attached bodies but allows them to s...
Definition: Prismatic.h:67
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
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:206
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
#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:220
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > DimensionAndSide
#define AGXMODEL_EXPORT
double Real
Definition: Real.h:42
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:102
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:101
agx::observer_ptr< Constraint > ConstraintObserver
Definition: Constraint.h:53
GLenum type
Definition: gl.h:5539