AGX Dynamics  2.37.3.2
DynamicOperation.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 
20 
21 #ifndef AGXCONTROL_DYNAMIC_OPERATION_H
22 #define AGXCONTROL_DYNAMIC_OPERATION_H
23 
24 
25 #include <agx/config.h>
26 
27 #include <agxControl/Operation.h>
29 
30 #include <agx/Constraint.h>
31 
32 namespace agxControl
33 {
34 
35  AGX_DECLARE_POINTER_TYPES(EndOperationAction);
36 
40  class AGXPHYSICS_EXPORT EndOperationAction : public agxControl::Action
41  {
42  public:
43  EndOperationAction(agx::Real time);
44  AGXSTREAM_DECLARE_SERIALIZABLE(agxControl::EndOperationAction);
45  EndOperationAction(){};
46  protected:
47  virtual ~EndOperationAction() {}
48  };
49 
50 
51  class ConstraintAngleOperation;
52 
58 
64  class AGXPHYSICS_EXPORT DynamicOperation : public agxControl::Operation
65  {
66  protected:
67  virtual ~DynamicOperation() {}
68  };
69 
70 
75  class AGXPHYSICS_EXPORT ConstraintAngleOperation : public agxControl::Operation
76  {
77  public:
78  ConstraintAngleOperation(
79  agx::Real startTime, agx::Real endTime, agx::Constraint1DOF* constraint, agx::Real targetAngle, bool useHermite = true);
80 
81  void setWinding(agx::Real winding);
82  agx::Real getWinding() const;
83 
84  virtual void activate(agx::Real time) override;
85  virtual void update(agx::Real time) override;
86  virtual void deactivate(agx::Real time) override;
87 
88  AGXSTREAM_DECLARE_SERIALIZABLE( agxControl::ConstraintAngleOperation );
89  ConstraintAngleOperation() {}
90  protected:
91  virtual ~ConstraintAngleOperation() {}
92 
93  private:
94  agxControl::SecondaryConstraintAction* getWorkAction();
95  agxControl::Callback1ActionImplementation<agx::Real>* getWorkActionImplementation();
96  agx::Constraint1DOF* getConstraint();
97 
98  private:
99  bool m_useHermite;
100 
101  // Interpolation data.
102  agx::Real m_beginAngle; // Read during activate.
103  agx::Real m_endAngle; // Supplied by user through constructor.
104  agx::Real m_beginSpeed; // Read during activate.
105  agx::Real m_endSpeed; // May be set by user, initially zero.
106 
107  agx::Real m_winding; // Constraint winding interval. May be set by user, initially zero.
108 
109  agxControl::HermiteInterpolationControllerRef m_hermite;
110  };
111 
112 
113  class AGXPHYSICS_EXPORT BodyPositionOperation : public agxControl::Operation
114  {
115  public:
116  BodyPositionOperation(agx::Real startTime, agx::Real endTime, agx::RigidBody* body, agx::Vec3 targetPosition);
117 
118  virtual void activate(agx::Real time) override;
119  virtual void update(agx::Real time) override;
120  virtual void deactivate(agx::Real time) override;
121 
122  AGXSTREAM_DECLARE_SERIALIZABLE( agxControl::BodyPositionOperation );
123  BodyPositionOperation() {}
124  protected:
125  virtual ~BodyPositionOperation() {}
126 
127  private:
128  agxControl::BodyAction* getWorkAction();
129  agxControl::Callback1ActionImplementation<agx::Vec3>* getWorkImplementation();
130  agx::RigidBody* getBody();
131 
132  private:
133  agx::Vec3 m_targetPosition;
134  };
135 }
136 
137 // Include guard.
138 #endif
139 
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Specialization for constraints that have only one degree of freedom such as Hinge and Prismatic...
Definition: Constraint.h:673
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
This namespace contains general operation and action classes which can be used to control a agxSDK::S...
#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
double Real
Definition: Real.h:42