Go to the documentation of this file.00001 #ifndef ROBOTCONTROLLER_H
00002 #define ROBOTCONTROLLER_H
00003
00004 #include <gazebo/common/PID.hh>
00005 #include <gazebo/common/Time.hh>
00006 #include <r2_gazebo_interface/JointController.h>
00007 #include <r2_msgs/JointStatusArray.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 <ros/ros.h>
00017 #include <string>
00018 #include <vector>
00019
00020 namespace gazebo
00021 {
00022 class RobotController
00023 {
00024 public:
00025 struct JointState
00026 {
00027 double position;
00028 double velocity;
00029 double effort;
00030 };
00031
00032 RobotController(physics::ModelPtr _modelPtr);
00033 ~RobotController();
00034
00035
00036 void addJoint(physics::JointPtr _jointPtr, bool advancedMode = false);
00037
00038
00039 void addJointDependency(std::string _childName, std::string _parentName, double factor);
00040 void setPosPid(const std::string& name, double _p = 0.0, double _i = 0.0, double _d = 0.0,
00041 double _imax = 0.0, double _imin = 0.0,
00042 double _cmdMax = 0.0, double _cmdMin = 0.0);
00043 void setVelPid(const std::string& name, double _p = 0.0, double _i = 0.0, double _d = 0.0,
00044 double _imax = 0.0, double _imin = 0.0,
00045 double _cmdMax = 0.0, double _cmdMin = 0.0);
00046
00047
00048 void setJointPositions(std::map<std::string, double> posMap);
00049
00050
00051 void getJointStates(std::map<std::string, JointState>& posMap);
00052
00053
00054 void getJointTargets(std::map<std::string, JointState>& posMap);
00055
00056
00057
00058 void getJointLimits(std::map<std::string, std::pair<double, double> >& limitsMap);
00059
00060
00061 void setJointPosTarget(const std::string& name, double target);
00062 void setJointVelTarget(const std::string& name, double target);
00063 void setJointEffortTarget(const std::string& name, double target);
00064
00065
00066 void setJointControl(const r2_msgs::JointControl::ConstPtr& msg);
00067 const r2_msgs::JointStatus& getJointStatus(const std::string& name) const;
00068 void publishJointStatuses(ros::Publisher& rosPub) const;
00069
00070
00071 void update();
00072
00073 private:
00074 physics::ModelPtr modelPtr;
00075 std::map<std::string, JointControllerPtr> joints;
00076
00077 typedef std::multimap<std::string, std::pair<std::string, double> > dependenciesType;
00078 dependenciesType dependencies;
00079
00080 common::Time prevUpdateTime;
00081 };
00082 }
00083 #endif