Go to the documentation of this file.00001 #ifndef JOINTCONTROLLER_H
00002 #define JOINTCONTROLLER_H
00003
00004 #include <map>
00005 #include <string>
00006 #include <vector>
00007
00008 #include "common/PID.hh"
00009 #include "common/Time.hh"
00010 #include "physics/PhysicsTypes.hh"
00011
00012 #include <boost/thread.hpp>
00013
00014 #include "nasa_r2_common_msgs/JointStatus.h"
00015 #include "nasa_r2_common_msgs/JointControl.h"
00016
00017 namespace gazebo
00018 {
00019 class JointController
00020 {
00021 public:
00022 JointController(physics::JointPtr _jointPtr, bool _advancedMode = false);
00023 ~JointController();
00024
00025 void setPosPid(double _p = 0.0, double _i = 0.0, double _d = 0.0,
00026 double _imax = 0.0, double _imin = 0.0,
00027 double _cmdMax = 0.0, double _cmdMin = 0.0);
00028 void setVelPid(double _p = 0.0, double _i = 0.0, double _d = 0.0,
00029 double _imax = 0.0, double _imin = 0.0,
00030 double _cmdMax = 0.0, double _cmdMin = 0.0);
00031
00032
00033 void setPosTarget(double target);
00034 void setVelTarget(double target);
00035 void setEffortTarget(double target);
00036
00037 inline double getPosTarget() {return position;}
00038 inline double getVelTarget() {return velocity;}
00039 inline double getEffortTarget() {return effort;}
00040
00041 inline void getJointLimits(double& lowLimit, double& highLimit) {lowLimit = jointLowLimit; highLimit = jointHighLimit;}
00042
00043
00044
00045 void update(common::Time& stepTime);
00046
00047
00048 void setJointControl(const nasa_r2_common_msgs::JointControl::ConstPtr& msg);
00049 const nasa_r2_common_msgs::JointStatus& getJointStatus() const;
00050
00051 void releaseBrake(bool release = true);
00052 void clearFaults();
00053
00054 private:
00055 physics::JointPtr jointPtr;
00056
00057 common::PID posPid;
00058 common::PID velPid;
00059
00060 double position;
00061 double velocity;
00062 double effort;
00063
00064 boost::mutex controllerMutex;
00065
00066 bool advancedMode;
00067
00068
00069 enum JointControlMode {POS_COM = 0, TORQ_COM = 1, IMP_COM = 2, VEL_COM = 3};
00070 enum JointFault {OK = 0};
00071
00072 nasa_r2_common_msgs::JointStatusPtr currStatusPtr;
00073 JointControlMode controlMode;
00074 JointFault fault;
00075
00076 double jointLowLimit;
00077 double jointHighLimit;
00078 };
00079
00080 typedef boost::shared_ptr<JointController> JointControllerPtr;
00081 }
00082 #endif