GazeboInterface.h
Go to the documentation of this file.
00001 #ifndef GAZEBOINTERFACE_H
00002 #define GAZEBOINTERFACE_H
00003 
00004 #include <gazebo/common/Events.hh>
00005 #include <gazebo/common/Plugin.hh>
00006 #include <r2_gazebo_interface/RobotController.h>
00007 #include <r2_msgs/JointCapability.h>
00008 #include <r2_msgs/JointCommand.h>
00009 #include <r2_msgs/JointControl.h>
00010 #include <r2_msgs/JointStatus.h>
00011 #include <r2_msgs/JointStatusArray.h>
00012 #include <gazebo/physics/Joint.hh>
00013 #include <gazebo/physics/Model.hh>
00014 #include <gazebo/physics/World.hh>
00015 #include <ros/ros.h>
00016 #include <sensor_msgs/JointState.h>
00017 
00018 namespace gazebo
00019 {
00020     class GazeboInterface : public ModelPlugin
00021     {
00022     public:
00023         GazeboInterface();
00024         ~GazeboInterface();
00025 
00026         virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
00027         virtual void Init();
00028 
00029         // Called by the world update start event
00030         void update();
00031 
00032     private:
00033         // handle joint commands
00034         void commandJoints(const sensor_msgs::JointState::ConstPtr& msg);
00035 
00036         // handle joint control messages
00037         void controlJoints(const r2_msgs::JointControl::ConstPtr& msg);
00038 
00039         // traverse through yaml structure looking for the mapped values
00040         // param: structure to traverseB
00041         // valMap: returned map
00042         // searchKey: named value to find
00043         // ns: namespace to prepend
00044         // name: name of param
00045         void traverseParams(XmlRpc::XmlRpcValue param, std::map<std::string, XmlRpc::XmlRpcValue>& valMap, std::string searchKey = "",
00046                             std::string ns = "", std::string name = "");
00047 
00048         // get a double from double or int XmlRpcValue
00049         // returns false if type is neither double or int
00050         bool getDoubleVal(XmlRpc::XmlRpcValue& val, double& doubleVal);
00051 
00052         // Pointer to the model
00053         physics::ModelPtr modelPtr;
00054 
00055         // Pointer to the update event connection
00056         event::ConnectionPtr updateConnectionPtr;
00057 
00058         std::unique_ptr<RobotController> robotControllerPtr;
00059 
00060         // ros stuff
00061         std::unique_ptr<ros::NodeHandle> rosNodePtr;
00062         std::unique_ptr<ros::NodeHandle> paramsNodePtr;
00063 
00064         // joint commands
00065         std::string jointCommandsTopic;
00066         ros::Subscriber jointCommandsSub;
00067 
00068         // joint capabilities
00069         std::string jointCapabilitiesTopic;
00070         ros::Publisher jointCapabilitiesPub;
00071         std::map<std::string, std::pair<double, double> > jointLimits;
00072 
00073         // joint states
00074         std::string jointStatesTopic;
00075         ros::Publisher jointStatePub;
00076         double jointStatesStepTime;
00077         std::map<std::string, RobotController::JointState> jointStates;
00078 
00079         // joint commandRefs
00080         std::string jointCommandRefsTopic;
00081         ros::Publisher jointCommandRefsPub;
00082         std::map<std::string, RobotController::JointState> jointCommandRefs;
00083 
00084         // joint status
00085         bool advancedMode;
00086         std::string jointControlTopic;
00087         ros::Subscriber jointControlSub;
00088         std::string jointStatusTopic;
00089         ros::Publisher jointStatusPub;
00090         double jointStatusStepTime;
00091 
00092         common::Time prevStatesUpdateTime;
00093         common::Time prevStatusUpdateTime;
00094     };
00095 }
00096 
00097 #endif


r2_gazebo_interface
Author(s):
autogenerated on Fri Jun 21 2019 20:03:41