AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
Actuator1DOF.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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>
21#include <agx/DistanceJoint.h>
22#include <agx/Hinge.h>
23#include <agx/Prismatic.h>
24#include <agx/Referenced.h>
31
32namespace agx
33{
34 class RigidBody;
35}
36
37namespace agxPowerLine
38{
39
41
47 {
48 public:
49 virtual bool isValid() const = 0;
50
58 virtual void transform() = 0;
59
64 virtual agx::Vec3 getWorldPosition(agx::UInt index) const = 0;
65
70 {
71 // First body is on index 0.
72 return getWorldPosition(0);
73 }
74
79 {
80 // Second body is on index 1.
81 return getWorldPosition(1);
82 }
83
88 virtual agx::Vec3 getWorldDirection(agx::UInt index) const = 0;
89
94 {
95 // First body is on index 0.
96 return getWorldDirection(0);
97 }
98
103 {
104 // Second body is on index 1.
105 return getWorldDirection(1);
106 }
107
112 virtual agx::Vec3 getCmToPosition(agx::UInt index) const = 0;
113
118 {
119 // First body is at index 1.
120 return getCmToPosition(0);
121 }
122
127 {
128 return getCmToPosition(1);
129 }
130
134 virtual agx::Vec3 getSeparation() const = 0;
135
142 virtual agx::Real getAngle() const = 0;
143
150 {
151 return {getMinAngle(), getMaxAngle()};
152 }
153
157 virtual agx::Real getMinAngle() const = 0;
158
162 virtual agx::Real getMaxAngle() const = 0;
163
172 virtual bool setConstraint(agx::Constraint* constraint) = 0;
173
174 virtual const agx::Constraint* getConstraint() const = 0;
176
177 AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxPoerLine::ConstraintGeometry)
178 };
179
180
181
188 {
189 public:
191
198
202 virtual bool isValid() const override;
203
204 virtual void transform() override;
205
206 virtual agx::Vec3 getWorldPosition(agx::UInt index) const override;
207 virtual agx::Vec3 getWorldDirection(agx::UInt index) const override;
208 virtual agx::Vec3 getCmToPosition(agx::UInt index) const override;
209
210 virtual agx::Vec3 getSeparation() const override;
211 virtual agx::Real getAngle() const override;
212 virtual agx::RangeReal getAngleRange() const override;
213 virtual agx::Real getMinAngle() const override;
214 virtual agx::Real getMaxAngle() const override;
215
216 virtual bool setConstraint(agx::Constraint* constraint) override;
218
219 virtual const agx::Constraint* getConstraint() const override;
220 virtual agx::Constraint* getConstraint() override;
221
224
226
227 const agx::ConstraintAngleBasedData& getAngleData() const;
228
229 private:
230 agx::Constraint* m_constraint;
231 agx::BasicControllerConstraint* m_controller;
232 };
233
234
235
241 {
242 public:
245
246 virtual bool isValid() const override;
247
255 virtual bool setConstraint(agx::Constraint* constraint) override;
256
258
259 private:
260 // Safe to keep a raw pointer because Actuator1DOF will clear this
261 // pointer from its objectDeleted observer_ptr callback.
262 agx::Constraint1DOF* m_constraint;
263 };
264
265
266
268
269
276 {
277 public:
278
280 Actuator1DOF(agx::Constraint* constraint1DOF, ConstraintGeometry* constraintGeometry);
281
282 // Begin agxPowerLine::Actuator interface.
283 virtual agx::Real calculateRelativeValue() const override;
284 // End PowerLine::Actuator interface.
285
286 // Begin PowerLine::Unit interface.
289 agxPowerLine::Side side) override;
290 // End PowerLine::Unit interface.
291
292
293 // Begin PowerLine::SubGraph interface.
294 virtual bool preUpdate(agx::Real timeStamp) override;
295 // End PowerLine::SubGraph interface.
296
299
305
309 virtual bool store(agxStream::StorageStream& str) const override;
310
312
316 virtual bool restore(agxStream::StorageStream& str) override;
317
319
321 void store(agxStream::OutputArchive& out) const override;
323
324 protected:
326
327 virtual ~Actuator1DOF();
328
330 void replaceActuatorUnit(Unit* oldUnit, Unit* newUnit);
331
333
334 virtual agx::Vec3 getDir1() const override;
335 virtual agx::Vec3 getDir2() const override;
336 virtual agx::Vec3 getCmToAnchorPos1() const override;
337 virtual agx::Vec3 getCmToAnchorPos2() const override;
338 virtual agx::Vec3 getSeparation() const override;
339
340
341 protected:
346 class ConstraintObserver : public agx::observer_ptr<agx::Constraint>
347 {
348 public:
349 ConstraintObserver(agx::Constraint* actuatedConstraint, Actuator1DOF* owningActuator);
350 virtual void objectDeleted(void*) override;
351
352 using agx::observer_ptr<agx::Constraint>::operator=;
353 private:
354 Actuator1DOF* m_owningActuator;
355 };
356
357 friend class ConstraintObserver;
358
359 protected:
362
367 };
368
369
370
372 {
373 public:
374 // \todo Not sure what the best type to take here is. Constraint1DOF is
375 // too lenient but Hinge may be too restrictive. How do I spell
376 // "Constraints with a rotational part."? Does that even make sense?
377 // What other types of Constraints would match, more than Hinge and
378 // Cylindrical? Don't forget SlackCylindrical. And SplineJoint while we're
379 // at it.
381
382
392
397
408 void setUseHighSpeedMode( agx::Bool highSpeedMode );
409
416
417
418 virtual void setEnable(bool enabled);
419 virtual bool getEnable() const;
420
421 // Called by the rest of the power line framework.
422 public:
423 virtual bool preUpdate(agx::Real timeStamp) override;
424
427 agxPowerLine::Side side) const override;
428
429 virtual agx::Real calculateRelativeGradient() const override;
430
432 Side side,
433 agxPowerLine::PhysicalDimension::Type dimensionType) const override;
434
436 Side side,
437 int dimensionType) const override;
438
442 virtual bool store(agxStream::StorageStream& out) const override;
443
447 virtual bool restore(agxStream::StorageStream& in) override;
448
450
452 public:
453 virtual agxPowerLine::DimensionAndSide getConnectableDimension(
455 agxPowerLine::Side side) override;
456
457
458 protected:
460
461 /*
462 There are subclasses of RotationalActuator that want to create their own
463 versions of the input shaft and the internal connector. For example, the
464 hydraulics package contains the ImpellerActuator, which uses a FlowUnit
465 for input.
466
467 Any subclass that uses the dont_create_input tag when constructing the
468 RotationalActuator base class must implement get- and setEnable.
469
470 This part of the inheritence tree could use some redesign. There should
471 be one base class, inheriting from Actuator1DOF, that knows about hinges
472 and how to get Jacobians from them, and a collection of subclasses
473 derived of off that that knows about the type of the input and the custom
474 constraint that binds the input PhysicalDimension to the
475 ActuatorBodyUnits.
476
477 Perhaps we should even move the concept of input unit and internal
478 constraint up a bit more and put it inside Actuator1DOF. In that case we
479 don't have to deal with the oddities of the current setEnable
480 implementation, which is just bad. A base class implementation does the
481 wrong thing for the derived classes.
482
483 Not sure if the name RotationalActuator should be used for the base class
484 or the subclass that has a RotationalUnit input. The latter is more
485 consistent with the current implementation and a better user-level name
486 (the base class is not user-level), but what should the base class be
487 named?
488 */
489 struct AGXMODEL_EXPORT dont_create_input_t {};
490 static dont_create_input_t dont_create_input;
491 RotationalActuator(agx::Constraint1DOF* constraint, dont_create_input_t);
492 RotationalActuator(agx::Constraint* constraint, ConstraintGeometry* constraintGeometry, dont_create_input_t);
493
494 virtual ~RotationalActuator();
495
496 void connectActuatorConnector();
497 void disconnectActuatorConnector();
498 void reconnectActuatorConnector();
500
501 protected:
503 agxPowerLine::detail::RotationalActuatorConnectorRef m_actuatorConnector;
504
505 agx::Bool m_useHighSpeedMode;
506 };
507
509
510
511
513 {
514 public:
515
516 TranslationalActuator(agx::Constraint1DOF* constraint); // \todo How only allow translational constraints? Should we?
518
520
521
522 // Called by the rest of the power line framework.
523 public:
526 agxPowerLine::Side side) const override;
527
530 agxPowerLine::Side side) override;
531
532 virtual agx::Real calculateRelativeGradient() const override;
533
535 Side side,
536 agxPowerLine::PhysicalDimension::Type dimensionType) const override;
537
538 virtual agx::Vec3 calculateLocalDirection(Side side, int dimensionType) const override;
539
543 virtual bool store(agxStream::StorageStream& str) const override;
544
548 virtual bool restore(agxStream::StorageStream& str) override;
549
551
552 protected:
554
557
561
563
565
567
568 private:
570 agxPowerLine::detail::TranslationalActuatorConnectorRef m_actuatorConnector;
571 };
572
574
575
576}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXMODEL_EXPORT
Observer that not only sets the Constraint pointer to nullptr on object deletion, but also informs th...
ConstraintObserver(agx::Constraint *actuatedConstraint, Actuator1DOF *owningActuator)
virtual void objectDeleted(void *) override
An Actuator that operates on Constraint1DOF constraints.
virtual agx::Vec3 getCmToAnchorPos2() const override
ConstraintGeometryRef m_constraintGeometry
void store(agxStream::OutputArchive &out) const override
Actuator1DOF(agx::Constraint *constraint1DOF, ConstraintGeometry *constraintGeometry)
void synchronizeDirections()
Synchronize the power-line dimension state directions with the constraint frame directions using the ...
virtual agx::Vec3 getCmToAnchorPos1() const override
virtual bool store(agxStream::StorageStream &str) const override
Stores internal data into stream.
virtual agx::Vec3 getDir2() const override
void replaceActuatorUnit(Unit *oldUnit, Unit *newUnit)
const ConstraintGeometry * getConstraintGeometry() const
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxPowerLine::Actuator1DOF)
ConstraintObserver m_constraintObserver
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 synchronizeUnits(agx::Constraint *constraint)
ConstraintGeometry * getConstraintGeometry()
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.
ConstraintGeometry for 1-DOF constraints.
Constraint1DOFGeometry(agx::Constraint1DOF *constraint)
virtual bool setConstraint(agx::Constraint *constraint) override
Set a new constraint, which must be of type Constraint1DOF.
virtual bool isValid() const override
Description of how an Actuator is allowed to apply forces and torques on the body or bodies attached ...
virtual agx::Vec3 getCmToPosition(agx::UInt index) const =0
virtual agx::Constraint * getConstraint()=0
agx::Vec3 getWorldDirection2() const
virtual const agx::Constraint * getConstraint() const =0
virtual bool isValid() const =0
virtual void transform()=0
Transform constraint attachment frames and updates data.
virtual agx::Vec3 getWorldDirection(agx::UInt index) const =0
agx::Vec3 getWorldDirection1() const
virtual agx::RangeReal getAngleRange() const
Get the range of allowed angles.
virtual bool setConstraint(agx::Constraint *constraint)=0
Replace the constraint being queried for geometry information.
virtual agx::Vec3 getWorldPosition(agx::UInt index) const =0
virtual agx::Real getMinAngle() const =0
virtual agx::Real getAngle() const =0
This method returns the current angle for the constraint.
virtual agx::Real getMaxAngle() const =0
virtual agx::Vec3 getSeparation() const =0
agx::Vec3 getWorldPosition2() const
agx::Vec3 getWorldPosition1() const
ConstraintGeometry for any type of constraint that has a BasicControllerConstraint along the axis tha...
virtual const agx::Constraint * getConstraint() const override
virtual agx::Vec3 getWorldPosition(agx::UInt index) const override
bool setConstraint(agx::Constraint *constraint, agx::BasicControllerConstraint *controller)
agx::BasicControllerConstraint * getController()
virtual agx::Real getMaxAngle() const override
virtual agx::Vec3 getWorldDirection(agx::UInt index) const override
virtual bool isValid() const override
virtual agx::Constraint * getConstraint() override
virtual agx::Real getAngle() const override
This method returns the current angle for the constraint.
ControllerConstraintGeometry(agx::Constraint *constraint, agx::BasicControllerConstraint *controller)
Create a ConstraintGeometry aligned with the direction of the given BasicControllerConstraint.
const agx::BasicControllerConstraint * getController() const
virtual agx::RangeReal getAngleRange() const override
Get the range of allowed angles.
virtual agx::Vec3 getCmToPosition(agx::UInt index) const override
virtual bool setConstraint(agx::Constraint *constraint) override
Replace the constraint being queried for geometry information.
virtual agx::Vec3 getSeparation() const override
virtual void transform() override
Transform constraint attachment frames and updates data.
virtual agx::Real getMinAngle() const override
virtual void setEnable(bool enabled)
virtual bool getEnable() const
virtual agx::Real calculateRelativeGradient() const override
RotationalActuator(agx::Constraint *constraint, agxPowerLine::ConstraintGeometry *constraintGeometry)
Constructor for constraints that have a more complicated geometry than a simple Hinge.
agx::Bool getUseHighSpeedMode() const
virtual agx::Vec3 calculateLocalDirection(Side side, int dimensionType) const override
virtual bool preUpdate(agx::Real timeStamp) override
RotationalActuator(agx::Constraint1DOF *constraint)
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.
agxPowerLine::TranslationalUnit * getInputRod()
TranslationalActuator(agx::Constraint *constraint, agxPowerLine::ConstraintGeometry *constraintGeometry, dont_create_input_t)
virtual agx::Vec3 calculateLocalDirection(Side side, int dimensionType) const override
static dont_create_input_t dont_create_input
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
virtual bool restore(agxStream::StorageStream &str) override
Restores internal data from stream.
TranslationalActuator(agx::Constraint1DOF *constraint)
TranslationalActuator(agx::Constraint1DOF *constraint, dont_create_input_t)
virtual agx::Real calculateRelativeGradient() const override
virtual agxPowerLine::DimensionAndSide getConnectableDimension(agxPowerLine::PhysicalDimension::Type type, agxPowerLine::Side side) override
virtual agx::Vec3 calculateWorldDirection(Side side, agxPowerLine::PhysicalDimension::Type dimensionType) const override
TranslationalActuator(agx::Constraint *constraint, ConstraintGeometry *constraintGeometry)
Pure virtual class.
Definition Unit.h:72
Class for reading a binary stream of serialized data.
Class for writing serialized data in binary format to a stream.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Abstract base class for storing/restoring a line/drums with version control.
Base class for constraint angle based elementary constraints (secondary constraints).
Specialization for constraints that have only one degree of freedom such as Hinge and Prismatic.
Definition Constraint.h:674
The base class for a constraint.
Definition Constraint.h:89
Base class providing referencing counted objects.
Definition Referenced.h:120
Templated vector class.
Definition agx/Vector.h:53
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
#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
std::pair< agxPowerLine::PhysicalDimension *, agxPowerLine::Side > DimensionAndSide
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:42