AnimatLab  2
Test
MotorizedJoint.h
1 #pragma once
2 
3 #include "PidControl.h"
4 
5 namespace AnimatSim
6 {
7  namespace Environment
8  {
9 
12  {
13  VelocityControl,
14  PositionControl,
15  PositionVelocityControl
16  };
17 
18  class ANIMAT_PORT MotorizedJoint : public Joint
19  {
20  protected:
23 
27 
33 
36 
40 
44 
49 
52 
58 
61 
65 
69 
72 
76 
80 
83 
86 
89 
94 
97  CStdFPoint m_vMotorForceToA;
98 
101 
104 
107 
110  CStdFPoint m_vMotorForceToB;
111 
114 
117 
120 
123  CStdFPoint m_vMotorTorqueToA;
124 
127 
130 
133 
136  CStdFPoint m_vMotorTorqueToB;
137 
140 
143 
146 
149 
152 
155 
156  //This is the temperature for the motor. This is not really that useful in the simulation at the moment, but
157  //it is data that is available for robotic motors, so I am adding a hook here for setting and displaying it.
158  float m_fltTemperature;
159 
160  //This is the voltage for the motor. This is not really that useful in the simulation at the moment, but
161  //it is data that is available for robotic motors, so I am adding a hook here for setting and displaying it.
162  float m_fltVoltage;
163 
165  RobotPartInterface *m_lpRobotMotorControl;
166 
169 
170  virtual void AddRobotPartInterface(RobotPartInterface *lpPart);
171  virtual void RemoveRobotPartInterface(RobotPartInterface *lpPart);
172 
173  virtual void ClearAssistForces();
174  virtual void ApplyMotorAssist();
175  virtual void EnableFeedback();
176 
177  public:
178  MotorizedJoint(void);
179  virtual ~MotorizedJoint(void);
180 
181  static MotorizedJoint *CastToDerived(AnimatBase *lpBase) {return static_cast<MotorizedJoint*>(lpBase);}
182 
183  virtual IMotorizedJoint *PhysicsMotorJoint();
184  virtual void PhysicsMotorJoint(IMotorizedJoint *lpJoint);
185 
186  virtual bool EnableMotor();
187  virtual void EnableMotor(bool bVal);
188 
189  virtual void MotorType(eJointMotorType eServo);
190  virtual eJointMotorType MotorType();
191 
192  virtual void ServoGain(float fltVal);
193  virtual float ServoGain();
194 
195  virtual void MaxForce(float fltVal, bool bUseScaling = true);
196  virtual float MaxForce();
197  virtual float MaxForceNotScaled();
198 
199  virtual float MaxVelocity();
200  virtual void MaxVelocity(float fltVal, bool bUseScaling = true);
201 
202  virtual float DesiredPosition();
203  virtual void DesiredPosition(float fltPosition);
204 
205  virtual float SetPosition();
206  virtual void SetPosition(float fltVal);
207 
208  virtual float PrevSetPosition();
209  virtual void PrevSetPosition(float fltVal);
210 
211  virtual bool ReachedSetPosition();
212  virtual void ReachedSetPosition(bool bVal);
213 
214  virtual float DesiredVelocity();
215  virtual void DesiredVelocity(float fltVelocity);
216 
217  virtual float SetVelocity();
218  virtual void SetVelocity(float fltVal);
219 
220  virtual float PrevSetVelocity();
221  virtual void PrevSetVelocity(float fltVal);
222 
223  virtual float PrevVelocity();
224  virtual void PrevVelocity(float fltVal);
225 
226  virtual int AssistCountdown();
227  virtual void AssistCountdown(int iVal);
228 
229  virtual CStdFPoint MotorForceToA();
230  virtual void MotorForceToA(CStdFPoint &vVal);
231 
232  virtual float MotorForceToAMagnitude();
233  virtual void MotorForceToAMagnitude(float fltVal);
234 
235  virtual CStdFPoint MotorAssistForceToA();
236  virtual void MotorAssistForceToA(CStdFPoint &vVal);
237 
238  virtual CStdFPoint MotorAssistForceToAReport();
239  virtual void MotorAssistForceToAReport(CStdFPoint &vVal);
240 
241  virtual CStdFPoint MotorForceToB();
242  virtual void MotorForceToB(CStdFPoint &vVal);
243 
244  virtual float MotorForceToBMagnitude();
245  virtual void MotorForceToBMagnitude(float fltVal);
246 
247  virtual CStdFPoint MotorAssistForceToB();
248  virtual void MotorAssistForceToB(CStdFPoint &vVal);
249 
250  virtual CStdFPoint MotorAssistForceToBReport();
251  virtual void MotorAssistForceToBReport(CStdFPoint &vVal);
252 
253  virtual CStdFPoint MotorTorqueToA();
254  virtual void MotorTorqueToA(CStdFPoint &vVal);
255 
256  virtual float MotorTorqueToAMagnitude();
257  virtual void MotorTorqueToAMagnitude(float fltVal);
258 
259  virtual CStdFPoint MotorAssistTorqueToA();
260  virtual void MotorAssistTorqueToA(CStdFPoint &vVal);
261 
262  virtual CStdFPoint MotorAssistTorqueToAReport();
263  virtual void MotorAssistTorqueToAReport(CStdFPoint &vVal);
264 
265  virtual CStdFPoint MotorTorqueToB();
266  virtual void MotorTorqueToB(CStdFPoint &vVal);
267 
268  virtual float MotorTorqueToBMagnitude();
269  virtual void MotorTorqueToBMagnitude(float fltVal);
270 
271  virtual CStdFPoint MotorAssistTorqueToB();
272  virtual void MotorAssistTorqueToB(CStdFPoint &vVal);
273 
274  virtual CStdFPoint MotorAssistTorqueToBReport();
275  virtual void MotorAssistTorqueToBReport(CStdFPoint &vVal);
276 
277  virtual CStdPID *AssistPid();
278 
279  virtual float Temperature();
280  virtual void Temperature(float fltVal);
281 
282  virtual float Voltage();
283  virtual void Voltage(float fltVal);
284 
285  virtual void MotorInput(float fltInput);
286 
287  virtual void RobotMotorControl(RobotPartInterface *lpPart);
288  virtual RobotPartInterface *RobotMotorControl();
289 
290  virtual void SetVelocityToDesired();
291  virtual void EnableLock(bool bOn, float fltPosition, float fltMaxLockForce);
292 
293  virtual void Initialize();
294  virtual void ResetSimulation();
295 
296  virtual float *GetDataPointer(const std::string &strDataType);
297  virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError = true);
298  virtual void QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
299 
300  virtual void Load(CStdXml &oXml);
301  };
302 
303  }
304 }
The base class for all of the joint type of objects.
Definition: Joint.h:40
Animatlab PID control system. This implements the CStdPid with extra AnimatBase functionality.
Definition: PidControl.h:11
float m_fltMaxForceNotScaled
The un=scaled maximum force.
Root namespace for the base simulation library for AnimatLab.
float m_fltMotorTorqueAMagnitude
The magnitude of the motor torque being applied to body A. (scaled units)
CStdFPoint m_vMotorAssistForceToAReport
Force vector that the motor assist is applying to body A. (un-scaled units).
PidControl * m_lpAssistPid
The PID controller for the motor assist system.
CStdFPoint m_vMotorAssistTorqueToB
Torque vector that the motor assist is applying to body B. (scaled units).
CStdFPoint m_vMotorAssistForceToA
Force vector that the motor assist is applying to body A. (scaled units).
float m_fltMotorForceBMagnitude
The magnitude of the motor Force being applied to body B. (scaled units)
float m_fltMotorForceAMagnitude
The magnitude of the motor Force being applied to body A. (scaled units)
RobotPartInterface * m_lpRobotMotorControl
The RobotPartInterface responsible for motor control for this motorized joint.
CStdFPoint m_vMotorAssistForceToBReport
Force vector that the motor assist is applying to body B. (un-scaled units).
CStdFPoint m_vMotorAssistTorqueToA
Torque vector that the motor assist is applying to body A. (scaled units).
float m_fltPrevSetVelocity
The previous velocity set for the motorized joint in the last time step.
CStdFPoint m_vMotorAssistForceToB
Force vector that the motor assist is applying to body B. (scaled units).
CStdFPoint m_vMotorAssistTorqueToAReport
Torque vector that the motor assist is applying to body A. (un-scaled units).
Animat base class.
Definition: AnimatBase.h:36
float m_fltReportSetPosition
This is the variable that is reported to AnimatLab on what the set position was.
float m_fltMotorAssistMagnitudeReport
The reportable motor assist Force magnitude.
float m_fltReportSetVelocity
This is the variable that is reported to AnimatLab on what the set veloicty was.
bool m_bEnableMotor
If true then the motor for this joint is enabled.
float m_fltSetPositionDeltaCheck
Used to check whether the set position has changed.
float m_fltMotorTorqueBMagnitude
The magnitude of the motor torque being applied to body B. (scaled units)
float m_ftlServoGain
The gain of the servo motor.
eJointMotorType
The motor control type for this joint.
eJointMotorType m_eMotorType
Determines the type of motor control this joint uses. The default is velocity controlled, but it can be position controlled, or both position and velocity controlled.
IMotorizedJoint * m_lpPhysicsMotorJoint
The pointer to the physics joint instance.
CStdFPoint m_vMotorAssistTorqueToBReport
Torque vector that the motor assist is applying to body B. (un-scaled units).
float m_fltMotorAssistMagnitude
The motor assist Force magnitude.