TrackedVehiclePlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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_TRACKEDVEHICLEPLUGIN_HH_
18 #define GAZEBO_PLUGINS_TRACKEDVEHICLEPLUGIN_HH_
19 
20 #include <string>
21 #include <unordered_map>
22 
23 #include <boost/algorithm/string.hpp>
24 #include <boost/optional.hpp>
25 
28 
29 #include "gazebo/common/Plugin.hh"
30 #include "gazebo/physics/physics.hh"
32 #include "gazebo/msgs/pose.pb.h"
33 #include "gazebo/msgs/twist.pb.h"
35 
36 namespace gazebo
37 {
40  enum class Tracks : bool { LEFT, RIGHT };
41 }
42 
43 namespace std
44 {
45  template <> struct hash<gazebo::Tracks>
46  {
47  size_t operator() (const gazebo::Tracks &_t) const
48  {
49  return size_t(_t);
50  }
51  };
52 }
53 
54 namespace gazebo
55 {
56  class TrackedVehiclePluginPrivate;
57 
80  {
82  public: TrackedVehiclePlugin();
83 
85  public: virtual ~TrackedVehiclePlugin();
86 
90  public: void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) override;
91 
93  public: void Init() override;
94 
96  public: void Reset() override;
97 
99  protected: virtual std::string GetRobotNamespace();
100 
102  protected: virtual double GetSteeringEfficiency();
103 
106  protected: virtual void SetSteeringEfficiency(double _steeringEfficiency);
107 
109  protected: virtual boost::optional<double> GetTrackMu();
110 
113  protected: virtual void SetTrackMu(double _mu);
114 
116  protected: virtual boost::optional<double> GetTrackMu2();
117 
120  protected: virtual void SetTrackMu2(double _mu2);
121 
124  protected: virtual void UpdateTrackSurface() = 0;
125 
130  protected: void SetLinkMu(const physics::LinkPtr &_link);
131 
133  protected: virtual double GetTracksSeparation();
134 
136  protected: std::unordered_map<Tracks, std::string> trackNames;
137 
146  protected: virtual void SetTrackVelocityImpl(double _left,
147  double _right) = 0;
148 
155  protected: virtual void SetTrackVelocity(double _left, double _right);
156 
158  // body motion.
162  protected: void SetBodyVelocity(
163  double _linear, double _angular); // TODO peci1: make virtual
164 
171  protected: virtual void OnVelMsg(ConstPosePtr &_msg) GAZEBO_DEPRECATED(9.0);
172 
179  protected: void OnVelMsg(ConstTwistPtr &_msg); // TODO peci1: make virtual
180 
182  protected: std::mutex mutex;
183 
185  private: std::unique_ptr<TrackedVehiclePluginPrivate> dataPtr;
186  };
187 }
188 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:110
Forward declarations for the common classes.
Definition: Animation.hh:26
std::mutex mutex
Mutex to protect updates.
Definition: TrackedVehiclePlugin.hh:182
Forward declarations for transport.
STL namespace.
std::unordered_map< Tracks, std::string > trackNames
Textual lowercase names of the tracks.
Definition: TrackedVehiclePlugin.hh:136
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:94
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
An abstract gazebo model plugin for tracked vehicles.
Definition: TrackedVehiclePlugin.hh:79
Tracks
Enum for distinguishing between left and right tracks.
Definition: TrackedVehiclePlugin.hh:40
A plugin with access to physics::Model.
Definition: Plugin.hh:303