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
30#include "gazebo/physics/physics.hh"
32#include "gazebo/msgs/pose.pb.h"
33#include "gazebo/msgs/twist.pb.h"
35
36namespace gazebo
37{
40 enum class Tracks : bool { LEFT, RIGHT };
41}
42
43namespace 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
54namespace gazebo
55{
56 class TrackedVehiclePluginPrivate;
57
80 {
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
Forward declarations for transport.
A plugin with access to physics::Model.
Definition Plugin.hh:304
An abstract gazebo model plugin for tracked vehicles.
Definition TrackedVehiclePlugin.hh:80
virtual double GetSteeringEfficiency()
Steering efficiency coefficient (between 0.0 and 1.0).
virtual void UpdateTrackSurface()=0
Update surface parameters of the tracks to correspond to the values set in this plugin.
virtual std::string GetRobotNamespace()
Namespace used as a prefix for gazebo topic names.
std::mutex mutex
Mutex to protect updates.
Definition TrackedVehiclePlugin.hh:182
virtual void SetTrackVelocity(double _left, double _right)
Set new target velocity for the tracks.
void SetLinkMu(const physics::LinkPtr &_link)
Set mu and mu2 of all collisions of the given link to values given by GetTrackMu() and GetTrackMu2().
virtual void SetTrackMu(double _mu)
Friction coefficient in the first friction direction.
void Init() override
Initialize the plugin.
virtual ~TrackedVehiclePlugin()
Destructor.
virtual void SetSteeringEfficiency(double _steeringEfficiency)
Set steering efficiency coefficient (between 0.0 and 1.0).
void OnVelMsg(ConstTwistPtr &_msg)
Callback for setting desired body velocity.
virtual void SetTrackMu2(double _mu2)
Friction coefficient in the second friction direction.
virtual boost::optional< double > GetTrackMu2()
Friction coefficient in the second friction direction.
void SetBodyVelocity(double _linear, double _angular)
Set new target velocity for the tracks based on the desired.
virtual void OnVelMsg(ConstPosePtr &_msg) GAZEBO_DEPRECATED(9.0)
Callback for setting desired body velocity.
void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) override
Called when the plugin is loaded.
virtual void SetTrackVelocityImpl(double _left, double _right)=0
Set new target velocity for the tracks.
virtual double GetTracksSeparation()
Distance between the centers of the tracks.
virtual boost::optional< double > GetTrackMu()
Friction coefficient in the first friction direction.
std::unordered_map< Tracks, std::string > trackNames
Textual lowercase names of the tracks.
Definition TrackedVehiclePlugin.hh:136
void Reset() override
Reset the plugin.
TrackedVehiclePlugin()
Default Contstuctor.
boost::shared_ptr< Link > LinkPtr
Definition PhysicsTypes.hh:109
boost::shared_ptr< Model > ModelPtr
Definition PhysicsTypes.hh:93
Forward declarations for the common classes.
Definition Animation.hh:27
Tracks
Enum for distinguishing between left and right tracks.
Definition TrackedVehiclePlugin.hh:40
STL namespace.
#define GAZEBO_DEPRECATED(version)
Definition system.hh:328