HarnessPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 GAZEBO_PLUGINS_HARNESSPLUGIN_HH_
18 #define GAZEBO_PLUGINS_HARNESSPLUGIN_HH_
19 
20 #include <string>
21 #include <vector>
22 
24 #include "gazebo/common/PID.hh"
25 #include "gazebo/common/Plugin.hh"
26 
27 namespace gazebo
28 {
52  {
54  public: HarnessPlugin();
55 
57  public: virtual ~HarnessPlugin();
58 
59  // Documentation Inherited.
60  public: virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
61 
62  // Documentation Inherited.
63  public: virtual void Init();
64 
67  public: void SetWinchVelocity(const float _value);
68 
71  public: double WinchVelocity() const;
72 
75  public: void Detach();
76 
79  private: void OnUpdate(const common::UpdateInfo &_info);
80 
83  private: void OnVelocity(ConstGzStringPtr &_msg);
84 
87  private: void OnDetach(ConstGzStringPtr &_msg);
88 
92  private: int JointIndex(const std::string &_name) const;
93 
95  private: std::vector<physics::JointPtr> joints;
96 
98  private: int winchIndex = 0;
99 
101  private: int detachIndex = 0;
102 
104  private: common::PID winchPosPID;
105 
107  private: common::PID winchVelPID;
108 
110  private: float winchTargetPos = 0.0;
111 
113  private: float winchTargetVel = 0.0;
114 
116  private: common::Time prevSimTime = common::Time::Zero;
117 
120  private: transport::NodePtr node;
121 
124  private: transport::SubscriberPtr velocitySub;
125 
128  private: transport::SubscriberPtr detachSub;
129 
131  private: event::ConnectionPtr updateConnection;
132  };
133 }
134 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
Forward declarations for transport.
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
Information for use in an update event.
Definition: UpdateInfo.hh:30
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
This plugin is designed to lower a model at a controlled rate.
Definition: HarnessPlugin.hh:51
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:88
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
A plugin with access to physics::Model.
Definition: Plugin.hh:245
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:59
Generic PID controller class.
Definition: PID.hh:36
static const Time Zero
A static zero time variable set to common::Time(0, 0).
Definition: Time.hh:47
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44