All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Gripper.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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 
29 namespace gazebo
30 {
31  namespace physics
32  {
35 
43  class Gripper
44  {
47  public: explicit Gripper(ModelPtr _model);
48 
50  public: virtual ~Gripper();
51 
55  public: virtual void Load(sdf::ElementPtr _sdf);
56 
58  public: virtual void Init();
59 
61  public: std::string GetName() const;
62 
66  public: bool IsAttached() const;
67 
69  private: void OnUpdate();
70 
73  private: void OnContacts(ConstContactsPtr &_msg);
74 
76  private: void HandleAttach();
77 
79  private: void HandleDetach();
80 
82  private: void ResetDiffs();
83 
85  private: physics::ModelPtr model;
86 
88  private: physics::PhysicsEnginePtr physics;
89 
91  private: physics::WorldPtr world;
92 
94  private: physics::JointPtr fixedJoint;
95 
97  private: physics::LinkPtr palmLink;
98 
100  private: std::vector<event::ConnectionPtr> connections;
101 
103  private: std::map<std::string, physics::CollisionPtr> collisions;
104 
106  private: std::vector<msgs::Contact> contacts;
107 
109  private: bool attached;
110 
113  private: math::Pose prevDiff;
114 
116  private: std::vector<double> diffs;
117 
119  private: int diffIndex;
120 
122  private: common::Time updateRate;
123 
125  private: common::Time prevUpdateTime;
126 
129  private: int posCount;
130 
133  private: int zeroCount;
134 
136  private: unsigned int minContactCount;
137 
139  private: int attachSteps;
140 
142  private: int detachSteps;
143 
145  private: std::string name;
146 
149 
151  private: transport::SubscriberPtr contactSub;
152  };
154  }
155 }
156 #endif