AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
Actuator1DOF.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>
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
374 {
375 public:
376 // \todo Not sure what the best type to take here is. Constraint1DOF is
377 // too lenient but Hinge may be too restrictive. How do I spell
378 // "Constraints with a rotational part."? Does that even make sense?
379 // What other types of Constraints would match, more than Hinge and
380 // Cylindrical? Don't forget SlackCylindrical. And SplineJoint while we're
381 // at it.
383
384
394
399
410 void setUseHighSpeedMode( agx::Bool highSpeedMode );
411
418
419
420 virtual void setEnable(bool enabled);
421 virtual bool getEnable() const;
422
423 // Called by the rest of the power line framework.
424 public:
425 virtual bool preUpdate(agx::Real timeStamp) override;
426
429 agxPowerLine::Side side) const override;
430
431 virtual agx::Real calculateRelativeGradient() const override;
432
434 Side side,
435 agxPowerLine::PhysicalDimension::Type dimensionType) const override;
436
438 Side side,
439 int dimensionType) const override;
440
444 virtual bool store(agxStream::StorageStream& out) const override;
445
449 virtual bool restore(agxStream::StorageStream& in) override;
450
452
454 public:
455 virtual agxPowerLine::DimensionAndSide getConnectableDimension(
457 agxPowerLine::Side side) override;
458
459
460 protected:
462
463 /*
464 There are subclasses of RotationalActuator that want to create their own
465 versions of the input shaft and the internal connector. For example, the
466 hydraulics package contains the ImpellerActuator, which uses a FlowUnit
467 for input.
468
469 Any subclass that uses the dont_create_input tag when constructing the
470 RotationalActuator base class must implement get- and setEnable.
471
472 This part of the inheritence tree could use some redesign. There should
473 be one base class, inheriting from Actuator1DOF, that knows about hinges
474 and how to get Jacobians from them, and a collection of subclasses
475 derived of off that that knows about the type of the input and the custom
476 constraint that binds the input PhysicalDimension to the
477 ActuatorBodyUnits.
478
479 Perhaps we should even move the concept of input unit and internal
480 constraint up a bit more and put it inside Actuator1DOF. In that case we
481 don't have to deal with the oddities of the current setEnable
482 implementation, which is just bad. A base class implementation does the
483 wrong thing for the derived classes.
484
485 Not sure if the name RotationalActuator should be used for the base class
486 or the subclass that has a RotationalUnit input. The latter is more
487 consistent with the current implementation and a better user-level name
488 (the base class is not user-level), but what should the base class be
489 named?
490 */
491 struct AGXMODEL_EXPORT dont_create_input_t {};
492 static dont_create_input_t dont_create_input;
493 RotationalActuator(agx::Constraint1DOF* constraint, dont_create_input_t);
494 RotationalActuator(agx::Constraint* constraint, ConstraintGeometry* constraintGeometry, dont_create_input_t);
495
496 virtual ~RotationalActuator();
497
498 void connectActuatorConnector();
499 void disconnectActuatorConnector();
500 void reconnectActuatorConnector();
502
503 protected:
505 agxPowerLine::detail::RotationalActuatorConnectorRef m_actuatorConnector;
506
507 agx::Bool m_useHighSpeedMode;
508 };
509
511
512
513
518 {
519 public:
520
521 TranslationalActuator(agx::Constraint1DOF* constraint); // \todo How only allow translational constraints? Should we?
523
525
526
527 // Called by the rest of the power line framework.
528 public:
531 agxPowerLine::Side side) const override;
532
535 agxPowerLine::Side side) override;
536
537 virtual agx::Real calculateRelativeGradient() const override;
538
540 Side side,
541 agxPowerLine::PhysicalDimension::Type dimensionType) const override;
542
543 virtual agx::Vec3 calculateLocalDirection(Side side, int dimensionType) const override;
544
548 virtual bool store(agxStream::StorageStream& str) const override;
549
553 virtual bool restore(agxStream::StorageStream& str) override;
554
556
557 protected:
559
562
566
568
570
572
573 private:
575 agxPowerLine::detail::TranslationalActuatorConnectorRef m_actuatorConnector;
576 };
577
579
580
581}
#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...
Definition: Serializable.h:221
#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 Constraint pointer to nullptr on object deletion, but also informs th...
Definition: Actuator1DOF.h:347
ConstraintObserver(agx::Constraint *actuatedConstraint, Actuator1DOF *owningActuator)
virtual void objectDeleted(void *) override
An Actuator that operates on Constraint1DOF constraints.
Definition: Actuator1DOF.h:276
virtual agx::Vec3 getCmToAnchorPos2() const override
ConstraintGeometryRef m_constraintGeometry
Definition: Actuator1DOF.h:361
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
Definition: Actuator1DOF.h:360
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)
Abstract base class for connecting a agxPowerLine::Unit to an ordinary constraint such as a Hinge or ...
Definition: Actuator.h:47
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.
Definition: Actuator1DOF.h:241
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 ...
Definition: Actuator1DOF.h:47
virtual agx::Vec3 getCmToPosition(agx::UInt index) const =0
virtual agx::Constraint * getConstraint()=0
agx::Vec3 getWorldDirection2() const
Definition: Actuator1DOF.h:102
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
Definition: Actuator1DOF.h:93
virtual agx::RangeReal getAngleRange() const
Get the range of allowed angles.
Definition: Actuator1DOF.h:149
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
Definition: Actuator1DOF.h:78
agx::Vec3 getCmToPosition2() const
Definition: Actuator1DOF.h:126
agx::Vec3 getCmToPosition1() const
Definition: Actuator1DOF.h:117
agx::Vec3 getWorldPosition1() const
Definition: Actuator1DOF.h:69
ConstraintGeometry for any type of constraint that has a BasicControllerConstraint along the axis tha...
Definition: Actuator1DOF.h:188
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
Class that will connect a agxPowerLine::Unit to a rotational ordinary constraint such as a agx::Hinge...
Definition: Actuator1DOF.h:374
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.
Class that will connect a agxPowerLine::Unit to a translational ordinary constraint such as a agx::Pr...
Definition: Actuator1DOF.h:518
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
Definition: Actuator1DOF.h:561
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.
Definition: InputArchive.h:51
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
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
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:710
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...
Definition: observer_ptr.h:61
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
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:41