Gripper.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GRIPPER_HH_
18 #define _GRIPPER_HH_
19 
20 #include <map>
21 #include <vector>
22 #include <string>
23 
24 #include "gazebo/msgs/msgs.hh"
26 #include "gazebo/math/Pose.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace physics
33  {
36 
44  class GZ_PHYSICS_VISIBLE Gripper
45  {
48  public: explicit Gripper(ModelPtr _model);
49 
51  public: virtual ~Gripper();
52 
56  public: virtual void Load(sdf::ElementPtr _sdf);
57 
59  public: virtual void Init();
60 
62  public: std::string GetName() const;
63 
67  public: bool IsAttached() const;
68 
70  private: void OnUpdate();
71 
74  private: void OnContacts(ConstContactsPtr &_msg);
75 
77  private: void HandleAttach();
78 
80  private: void HandleDetach();
81 
83  private: void ResetDiffs();
84 
86  private: physics::ModelPtr model;
87 
89  // NOTE: Variable not used, left here for ABI compatibility. Remove when
90  // merging forward.
91  private: physics::PhysicsEnginePtr physics;
92 
94  private: physics::WorldPtr world;
95 
97  private: physics::JointPtr fixedJoint;
98 
100  private: physics::LinkPtr palmLink;
101 
103  private: std::vector<event::ConnectionPtr> connections;
104 
106  private: std::map<std::string, physics::CollisionPtr> collisions;
107 
109  private: std::vector<msgs::Contact> contacts;
110 
112  private: boost::mutex mutexContacts;
113 
115  private: bool attached;
116 
119  private: math::Pose prevDiff;
120 
122  private: std::vector<double> diffs;
123 
125  private: int diffIndex;
126 
128  private: common::Time updateRate;
129 
131  private: common::Time prevUpdateTime;
132 
135  private: int posCount;
136 
139  private: int zeroCount;
140 
142  private: unsigned int minContactCount;
143 
145  private: int attachSteps;
146 
148  private: int detachSteps;
149 
151  private: std::string name;
152 
155 
157  private: transport::SubscriberPtr contactSub;
158  };
160  }
161 }
162 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:100
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:84
Forward declarations for the common classes.
Definition: Animation.hh:33
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
Forward declarations for transport.
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:108
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
default namespace for gazebo
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:116
A gripper abstraction.
Definition: Gripper.hh:44
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:88
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
transport::NodePtr node
Node for communication.
Definition: Gripper.hh:154
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44