ContactWorldPlugin.hh
Go to the documentation of this file.
1 
8 #ifndef _CONTACT_WORLD_PLUGIN_HH_
9 #define _CONTACT_WORLD_PLUGIN_HH_
10 
11 // Gazebo
12 #include "gazebo/msgs/MessageTypes.hh"
13 #include "gazebo/common/Plugin.hh"
14 #include <gazebo/msgs/msgs.hh>
15 #include <gazebo/physics/physics.hh>
16 #include <gazebo/transport/transport.hh>
17 
18 // Custom messages
19 #include "contact_request.pb.h"
20 #include "contact_response.pb.h"
21 
22 namespace ContactWorldPlugin {
23 
24  // Plugin messages
25 
27  #define REQUEST_TOPIC "~/grasp/contact"
28  #define RESPONSE_TOPIC "~/grasp/contact/response"
30 }
31 
32 namespace gazebo {
33 
37  typedef const boost::shared_ptr<const grasp::msgs::ContactRequest>
42  typedef const boost::shared_ptr<const grasp::msgs::ContactResponse>
44 
45  // Forward declaration of private data class
47 
49  class ContactWorldPlugin : public WorldPlugin
50  {
51  // Private attributes
52 
54  private: std::unique_ptr<ContactWorldPluginPrivate> data_ptr;
55 
57  private: physics::WorldPtr world;
59  private: event::ConnectionPtr update_connection;
60 
62  private: bool recv_msg {false};
64  private: bool enabled {false};
66  private: boost::shared_ptr<ContactRequest const> msg_req;
67 
68  // Public methods
69 
71  public: ContactWorldPlugin();
72 
74  public: virtual ~ContactWorldPlugin();
75 
79  public: virtual void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf);
80 
83  public: void onUpdate();
84 
88  public: void onContact(ConstContactsPtr & _msg);
89 
94  public: void onRequest(ContactRequestPtr & _msg);
95 
98  public: void onResponse(ContactResponsePtr & _msg);
99 
102  public: void checkCollision(ContactResponse & _msg);
103 
107  public: void changeSurface(ContactResponse & _msg);
108  };
109 }
110 
111 #endif
Definition: ContactSensorPlugin.cc:12
grasp::msgs::ContactResponse ContactResponse
Declaration for response message type.
Definition: run_trials.hh:132
std::unique_ptr< ContactWorldPluginPrivate > data_ptr
Class with private attributes.
Definition: ContactWorldPlugin.hh:54
const boost::shared_ptr< const grasp::msgs::ContactRequest > ContactRequestPtr
Shared pointer declaration for request message type.
Definition: ContactWorldPlugin.hh:38
boost::shared_ptr< ContactRequest const > msg_req
Last received request message.
Definition: ContactWorldPlugin.hh:66
grasp::msgs::ContactRequest ContactRequest
Declaration for request message type.
Definition: ContactWorldPlugin.hh:35
void changeSurface(gazebo::transport::PublisherPtr pub, const std::string &model, const std::string &link, const std::string &collision)
Change surface properties.
Definition: contacts_example.cc:67
Definition: ContactWorldPlugin.hh:22
event::ConnectionPtr update_connection
Connection to world update event.
Definition: ContactWorldPlugin.hh:59
const boost::shared_ptr< const grasp::msgs::ContactRequest > ContactRequestPtr
Shared pointer declaration for request message type.
Definition: run_trials.hh:130
const boost::shared_ptr< const grasp::msgs::ContactResponse > ContactResponsePtr
Shared pointer declaration for response message type.
Definition: ContactWorldPlugin.hh:43
physics::WorldPtr world
World pointer.
Definition: ContactWorldPlugin.hh:57
Class for private Target plugin data.
Definition: ContactWorldPlugin.cc:14