##

TrackedVehiclePlugin.hh
Go to the documentation of this file.
/*
* Copyright (C) 2017 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_PLUGINS_TRACKEDVEHICLEPLUGIN_HH_
#define GAZEBO_PLUGINS_TRACKEDVEHICLEPLUGIN_HH_
#include <string>
#include <unordered_map>
#include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
#include <gazebo/physics/ode/ODELink.hh>
#include <gazebo/physics/ode/ODECollision.hh>
#include "gazebo/common/Plugin.hh"
#include "gazebo/physics/physics.hh"
#include "gazebo/transport/TransportTypes.hh"
#include "gazebo/msgs/pose.pb.h"
#include "gazebo/msgs/twist.pb.h"
#include "plugins/TrackedVehiclePlugin.hh"
namespace gazebo
{
enum class Tracks : bool { LEFT, RIGHT };
}
namespace std
{
template <> struct hash<gazebo::Tracks>
{
size_t operator() (const gazebo::Tracks &_t) const
{
return size_t(_t);
}
};
}
namespace gazebo
{
class TrackedVehiclePluginPrivate;
class TrackedVehiclePlugin : public ModelPlugin
{
public: TrackedVehiclePlugin();
public: virtual ~TrackedVehiclePlugin();
public: void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) override;
public: void Init() override;
public: void Reset() override;
protected: virtual std::string GetRobotNamespace();
protected: virtual double GetSteeringEfficiency();
protected: virtual void SetSteeringEfficiency(double _steeringEfficiency);
protected: virtual boost::optional<double> GetTrackMu();
protected: virtual void SetTrackMu(double _mu);
protected: virtual boost::optional<double> GetTrackMu2();
protected: virtual void SetTrackMu2(double _mu2);
protected: virtual void UpdateTrackSurface() = 0;
protected: void SetLinkMu(const physics::LinkPtr &_link);
protected: virtual double GetTracksSeparation();
protected: std::unordered_map<Tracks, std::string> trackNames;
protected: virtual void SetTrackVelocityImpl(double _left,
double _right) = 0;
protected: virtual void SetTrackVelocity(double _left, double _right);
// body motion.
protected: void SetBodyVelocity(
double _linear, double _angular); // TODO peci1: make virtual
protected: virtual void OnVelMsg(ConstPosePtr &_msg) GAZEBO_DEPRECATED(9.0);
protected: void OnVelMsg(ConstTwistPtr &_msg); // TODO peci1: make virtual
protected: std::mutex mutex;
private: std::unique_ptr<TrackedVehiclePluginPrivate> dataPtr;
};
}
#endif
gazebo::Tracks
Tracks
Enum for distinguishing between left and right tracks.
Definition: TrackedVehiclePlugin.hh:40
gazebo::TrackedVehiclePlugin::Load
void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) override
Called when the plugin is loaded.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::TrackedVehiclePlugin::trackNames
std::unordered_map< Tracks, std::string > trackNames
Textual lowercase names of the tracks.
Definition: TrackedVehiclePlugin.hh:136
gazebo::TrackedVehiclePlugin::SetTrackVelocityImpl
virtual void SetTrackVelocityImpl(double _left, double _right)=0
Set new target velocity for the tracks.
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::TrackedVehiclePlugin
An abstract gazebo model plugin for tracked vehicles.
Definition: TrackedVehiclePlugin.hh:79
gazebo::TrackedVehiclePlugin::SetTrackMu
virtual void SetTrackMu(double _mu)
Friction coefficient in the first friction direction.
gazebo::TrackedVehiclePlugin::Init
void Init() override
Initialize the plugin.
TransportTypes.hh
Forward declarations for transport.
gazebo::TrackedVehiclePlugin::~TrackedVehiclePlugin
virtual ~TrackedVehiclePlugin()
Destructor.
gazebo::TrackedVehiclePlugin::GetTrackMu
virtual boost::optional< double > GetTrackMu()
Friction coefficient in the first friction direction.
gazebo::Tracks::RIGHT
TrackedVehiclePlugin.hh
gazebo::TrackedVehiclePlugin::TrackedVehiclePlugin
TrackedVehiclePlugin()
Default Contstuctor.
gazebo::TrackedVehiclePlugin::mutex
std::mutex mutex
Mutex to protect updates.
Definition: TrackedVehiclePlugin.hh:182
gazebo::TrackedVehiclePlugin::GetTrackMu2
virtual boost::optional< double > GetTrackMu2()
Friction coefficient in the second friction direction.
gazebo::TrackedVehiclePlugin::Reset
void Reset() override
Reset the plugin.
ODECollision.hh
gazebo::TrackedVehiclePlugin::SetBodyVelocity
void SetBodyVelocity(double _linear, double _angular)
Set new target velocity for the tracks based on the desired.
gazebo::TrackedVehiclePlugin::SetTrackVelocity
virtual void SetTrackVelocity(double _left, double _right)
Set new target velocity for the tracks.
gazebo::TrackedVehiclePlugin::GetRobotNamespace
virtual std::string GetRobotNamespace()
Namespace used as a prefix for gazebo topic names.
ODELink.hh
gazebo::physics::LinkPtr
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
gazebo::TrackedVehiclePlugin::SetTrackMu2
virtual void SetTrackMu2(double _mu2)
Friction coefficient in the second friction direction.
gazebo::TrackedVehiclePlugin::GetSteeringEfficiency
virtual double GetSteeringEfficiency()
Steering efficiency coefficient (between 0.0 and 1.0).
GAZEBO_DEPRECATED
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
gazebo::Tracks::LEFT
gazebo::TrackedVehiclePlugin::SetSteeringEfficiency
virtual void SetSteeringEfficiency(double _steeringEfficiency)
Set steering efficiency coefficient (between 0.0 and 1.0).
gazebo::TrackedVehiclePlugin::SetLinkMu
void SetLinkMu(const physics::LinkPtr &_link)
Set mu and mu2 of all collisions of the given link to values given by GetTrackMu() and GetTrackMu2().
gazebo::ModelPlugin
A plugin with access to physics::Model.
Definition: Plugin.hh:303
Plugin.hh
gazebo::TrackedVehiclePlugin::OnVelMsg
virtual void OnVelMsg(ConstPosePtr &_msg) GAZEBO_DEPRECATED(9.0)
Callback for setting desired body velocity.
gazebo::TrackedVehiclePlugin::UpdateTrackSurface
virtual void UpdateTrackSurface()=0
Update surface parameters of the tracks to correspond to the values set in this plugin.
gazebo::TrackedVehiclePlugin::GetTracksSeparation
virtual double GetTracksSeparation()
Distance between the centers of the tracks.