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