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 #include <ignition/transport/Node.hh>
23 
25 #include "gazebo/common/PID.hh"
26 #include "gazebo/common/Plugin.hh"
27 
28 namespace gazebo
29 {
53  {
55  public: HarnessPlugin();
56 
58  public: virtual ~HarnessPlugin();
59 
60  // Documentation Inherited.
61  public: virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
62 
63  // Documentation Inherited.
64  public: virtual void Init();
65 
68  public: void SetWinchVelocity(const float _value);
69 
72  public: double WinchVelocity() const;
73 
76  public: void Detach();
77 
80  private: void OnUpdate(const common::UpdateInfo &_info);
81 
84  private: void OnVelocity(ConstGzStringPtr &_msg);
85 
88  private: void OnDetach(ConstGzStringPtr &_msg);
89 
93  private: int JointIndex(const std::string &_name) const;
94 
96  private: std::vector<physics::JointPtr> joints;
97 
99  private: int winchIndex = 0;
100 
102  private: int detachIndex = 0;
103 
105  private: common::PID winchPosPID;
106 
108  private: common::PID winchVelPID;
109 
111  private: float winchTargetPos = 0.0;
112 
114  private: float winchTargetVel = 0.0;
115 
117  private: common::Time prevSimTime = common::Time::Zero;
118 
121  private: transport::NodePtr node;
122 
125  private: transport::SubscriberPtr velocitySub;
126 
129  private: transport::SubscriberPtr detachSub;
130 
132  private: event::ConnectionPtr updateConnection;
133 
134  // Place ignition::transport objects at the end of this file to
135  // guarantee they are destructed first.
136 
138  private: ignition::transport::Node nodeIgn;
139  };
140 }
141 #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:134
This plugin is designed to lower a model at a controlled rate.
Definition: HarnessPlugin.hh:52
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
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:260
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:58
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