cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsPID.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5  Author(s): Zihan Chen
6  Created on: 2013-02-22
7 
8  (C) Copyright 2013-2015 Johns Hopkins University (JHU), All Rights Reserved.
9 
10 --- begin cisst license - do not edit ---
11 
12 This software is provided "as is" under an open source license, with
13 no warranty. The complete license can be found in license.txt and
14 http://www.cisst.org/cisst/license.txt.
15 
16 --- end cisst license ---
17 */
18 
19 
29 #ifndef _mtsPID_h
30 #define _mtsPID_h
31 
39 
40 #include <sawControllers/sawControllersRevision.h>
41 
44 
46 {
48 
49 protected:
50  // Required interface
62  } Robot;
63 
65  int Counter;
66 
82 
83 
84  // TODO: change to prmPositionJointGet
99 
115 
119 
124 
129 
134 
137 
140 
143 
145  bool Enabled;
146 
149 
152  vctBoolVec mPreviousTrackingErrorFlag, mTrackingErrorFlag;
153 
156 
157  struct {
160  // !Joint limit event
162  } Events;
163 
164  struct {
168  } MessageEvents;
169 
174  void ResetController(void);
175 
181  void SetDesiredPositions(const prmPositionJointSet & prmPos);
182  void SetDesiredTorques(const prmForceTorqueJointSet& prmTrq);
183 
184  void SetupInterfaces(void);
185 
186  void Enable(const bool & enable);
187 
188  void EnableTorqueMode(const vctBoolVec & enable);
189 
190  void SetTrackingErrorTolerances(const vctDoubleVec & tolerances);
191 
192  void ErrorEventHandler(const std::string & message);
193 
194 public:
195 
202  mtsPID(const std::string & taskname,
203  const double period);
206 
212  void Configure(const std::string& filename);
213  void Startup(void);
214  void Run(void);
215  void Cleanup(void);
216 
217 
218 protected:
224  void SetPGain(const vctDoubleVec & pgain);
225 
231  void SetDGain(const vctDoubleVec & dgain);
232 
238  void SetIGain(const vctDoubleVec & igain);
239 
245  void SetJointLowerLimit(const vctDoubleVec & lowerLimit);
246 
252  void SetJointUpperLimit(const vctDoubleVec & upperLimit);
253 
254 
260  void SetMinIErrorLimit(const vctDoubleVec & iminlim);
261 
262 
268  void SetMaxIErrorLimit(const vctDoubleVec & imaxlim);
269 
275  void SetForgetIError(const double & forget);
276 
277 };
278 
280 
281 #endif // _mtsPID_h
Definition: prmPositionJointGet.h:35
vctBoolVec mTrackingErrorFlag
Definition: mtsPID.h:152
vctDoubleVec maxIErrorLimit
Max iError.
Definition: mtsPID.h:133
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
vctBoolVec TorqueMode
Enable mtsPID controller.
Definition: mtsPID.h:148
Definition: prmVelocityJointGet.h:39
prmStateJoint mStateJointDesired
Definition: mtsPID.h:114
bool mEnableTrackingError
Definition: mtsPID.h:150
Definition: mtsFunctionRead.h:37
mtsFunctionRead GetFeedbackPosition
Read joint position from robot.
Definition: mtsPID.h:55
vctDoubleVec DesiredPosition
Desired joint positions.
Definition: mtsPID.h:88
prmVelocityJointGet FeedbackVelocityParam
prm type feedback velocity
Definition: mtsPID.h:110
Definition: mtsTaskPeriodic.h:38
mtsFunctionWrite Warning
Definition: mtsPID.h:166
mtsFunctionWrite Status
Definition: mtsPID.h:165
mtsFunctionWrite Enabled
Enable event.
Definition: mtsPID.h:159
Definition: prmForceTorqueJointSet.h:37
const int CMN_DYNAMIC_CREATION_ONEARG
Definition: cmnClassRegisterMacros.h:333
virtual void Startup(void)
Definition: mtsComponent.h:262
Always include last.
Definition: mtsPID.h:45
bool Enabled
Enable mtsPID controller.
Definition: mtsPID.h:145
Definition: prmStateJoint.h:35
vctDoubleVec dError
Error derivative.
Definition: mtsPID.h:121
vctDoubleVec DesiredVelocity
Desired joint velocities.
Definition: mtsPID.h:96
vctDoubleVec DesiredTorque
Desired joint positions.
Definition: mtsPID.h:92
vctDoubleVec ErrorAbsolute
Definition: mtsPID.h:118
vctDoubleVec JointLowerLimit
Joint lower limit.
Definition: mtsPID.h:76
vctDoubleVec iError
Error integral.
Definition: mtsPID.h:123
mtsFunctionRead GetFeedbackVelocity
Read joint velocity from robot.
Definition: mtsPID.h:57
vctDoubleVec JointUpperLimit
Joint upper limit.
Definition: mtsPID.h:78
Definition: mtsPID.h:51
vctDoubleVec nonlinear
If 0, use regular PID, else use as nonlinear factor.
Definition: mtsPID.h:139
vctDoubleVec Error
Error.
Definition: mtsPID.h:117
vctDoubleVec Ki
Integral gains.
Definition: mtsPID.h:72
vctDoubleVec FeedbackPosition
Feedback joint positions.
Definition: mtsPID.h:86
vctDoubleVec mTrackingErrorTolerances
Definition: mtsPID.h:151
mtsFunctionWrite Error
Definition: mtsPID.h:167
vctDoubleVec DeadBand
Deadband (errors less than this are set to 0)
Definition: mtsPID.h:142
virtual void Configure(const std::string &CMN_UNUSED(filename)="")
Definition: mtsTask.h:218
vctDoubleVec forgetIError
iError forgetting factor
Definition: mtsPID.h:136
vctBoolVec mPreviousJointLimitFlag
Definition: mtsPID.h:81
Definition: mtsStateTable.h:67
mtsFunctionWrite SetTorque
Write the joint torques.
Definition: mtsPID.h:61
mtsFunctionWrite JointLimit
Definition: mtsPID.h:161
Joint position move parameters.
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
mtsFunctionRead GetFeedbackTorque
Read joint torque from robot.
Definition: mtsPID.h:59
Joint velocity query parameters.
prmPositionJointGet FeedbackPositionParam
prm type feedback positoin
Definition: mtsPID.h:103
prmForceTorqueJointSet prmDesiredTrq
prm type desired torque
Definition: mtsPID.h:108
vctDoubleVec Offset
Offset.
Definition: mtsPID.h:74
Defines a periodic task.
vctDoubleVec oldError
Previous error.
Definition: mtsPID.h:126
vctDoubleVec Kp
Proportional gains.
Definition: mtsPID.h:68
mtsFunctionRead GetJointType
Read joint type form robot.
Definition: mtsPID.h:53
prmPositionJointSet DesiredPositionParam
prm type desired position
Definition: mtsPID.h:106
virtual void Run(void)=0
vctDoubleVec FeedbackVelocity
Feedback joint velocities.
Definition: mtsPID.h:94
prmPositionJointGet FeedbackPositionPreviousParam
Definition: mtsPID.h:104
~mtsPID()
Definition: mtsPID.h:205
Joint position move parameters.
bool CheckJointLimit
Flag whether check joint limit.
Definition: mtsPID.h:80
vctDoubleVec oldDesiredPos
Previous desiredPos.
Definition: mtsPID.h:128
Definition: mtsFunctionWrite.h:37
Definition: mtsTaskPeriodic.h:80
vctDoubleVec Torque
Torque set to robot.
Definition: mtsPID.h:98
prmForceTorqueJointSet TorqueParam
prm type set torque
Definition: mtsPID.h:112
vctDoubleVec FeedbackTorque
Feedback joint positions.
Definition: mtsPID.h:90
CMN_DECLARE_SERVICES_INSTANTIATION(mtsPID)
virtual void Cleanup(void)
Definition: mtsComponent.h:267
int Counter
Counter for internal use.
Definition: mtsPID.h:65
vctDoubleVec Kd
Derivative gains.
Definition: mtsPID.h:70
mtsStateTable ConfigurationStateTable
Configuration state table.
Definition: mtsPID.h:155
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
vctDoubleVec minIErrorLimit
Min iError.
Definition: mtsPID.h:131
Definition: prmPositionJointSet.h:37
prmJointTypeVec JointType
prm type joint type
Definition: mtsPID.h:101