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
00030 void update();
00031
00032 private:
00033
00034 void commandJoints(const sensor_msgs::JointState::ConstPtr& msg);
00035
00036
00037 void controlJoints(const r2_msgs::JointControl::ConstPtr& msg);
00038
00039
00040
00041
00042
00043
00044
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
00049
00050 bool getDoubleVal(XmlRpc::XmlRpcValue& val, double& doubleVal);
00051
00052
00053 physics::ModelPtr modelPtr;
00054
00055
00056 event::ConnectionPtr updateConnectionPtr;
00057
00058 std::unique_ptr<RobotController> robotControllerPtr;
00059
00060
00061 std::unique_ptr<ros::NodeHandle> rosNodePtr;
00062 std::unique_ptr<ros::NodeHandle> paramsNodePtr;
00063
00064
00065 std::string jointCommandsTopic;
00066 ros::Subscriber jointCommandsSub;
00067
00068
00069 std::string jointCapabilitiesTopic;
00070 ros::Publisher jointCapabilitiesPub;
00071 std::map<std::string, std::pair<double, double> > jointLimits;
00072
00073
00074 std::string jointStatesTopic;
00075 ros::Publisher jointStatePub;
00076 double jointStatesStepTime;
00077 std::map<std::string, RobotController::JointState> jointStates;
00078
00079
00080 std::string jointCommandRefsTopic;
00081 ros::Publisher jointCommandRefsPub;
00082 std::map<std::string, RobotController::JointState> jointCommandRefs;
00083
00084
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