##

WheelTrackedVehiclePlugin.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_WHEELTRACKEDVEHICLEPLUGIN_HH
#define GAZEBO_WHEELTRACKEDVEHICLEPLUGIN_HH
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "gazebo/physics/Joint.hh"
#include "plugins/TrackedVehiclePlugin.hh"
namespace gazebo
{
class WheelTrackedVehiclePlugin :
public TrackedVehiclePlugin
{
public: WheelTrackedVehiclePlugin() = default;
public: virtual ~WheelTrackedVehiclePlugin() = default;
public: void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) override;
public: void Init() override;
public: void Reset() override;
protected: void SetTrackVelocityImpl(double _left, double _right) override;
protected: void UpdateTrackSurface() override;
protected: void LoadWheel(physics::ModelPtr &_model, Tracks &_track,
const std::string &_jointName);
protected: struct WheelInfo
{
physics::JointPtr joint;
std::string jointName;
// cppcheck-suppress unusedStructMember
double radius;
};
typedef std::shared_ptr<WheelInfo> WheelInfoPtr;
typedef std::vector<WheelInfoPtr> WheelInfo_V;
protected: std::unordered_map<Tracks, WheelInfo_V> wheels;
protected: std::unordered_map<Tracks, double> trackVelocity;
protected: double defaultWheelRadius;
protected: physics::WorldPtr world;
protected: std::mutex mutex;
private: event::ConnectionPtr updateConnection;
private: void OnUpdate();
};
}
#endif
gazebo::WheelTrackedVehiclePlugin::LoadWheel
void LoadWheel(physics::ModelPtr &_model, Tracks &_track, const std::string &_jointName)
Load a wheel connected to joint named jointName and append it to this->wheels[track].
gazebo::Tracks
Tracks
Enum for distinguishing between left and right tracks.
Definition: TrackedVehiclePlugin.hh:40
gazebo::WheelTrackedVehiclePlugin::Init
void Init() override
Initialize the plugin.
gazebo::WheelTrackedVehiclePlugin::wheels
std::unordered_map< Tracks, WheelInfo_V > wheels
The wheels on the LEFT/RIGHT track.
Definition: WheelTrackedVehiclePlugin.hh:105
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::WheelTrackedVehiclePlugin::mutex
std::mutex mutex
Mutex to protect updates.
Definition: WheelTrackedVehiclePlugin.hh:117
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::WheelTrackedVehiclePlugin::~WheelTrackedVehiclePlugin
virtual ~WheelTrackedVehiclePlugin()=default
TrackedVehiclePlugin.hh
gazebo::WheelTrackedVehiclePlugin::UpdateTrackSurface
void UpdateTrackSurface() override
Update surface parameters of the tracks to correspond to the values set in this plugin.
gazebo::WheelTrackedVehiclePlugin::WheelInfoPtr
std::shared_ptr< WheelInfo > WheelInfoPtr
Definition: WheelTrackedVehiclePlugin.hh:101
gazebo::WheelTrackedVehiclePlugin::WheelTrackedVehiclePlugin
WheelTrackedVehiclePlugin()=default
gazebo::WheelTrackedVehiclePlugin::Reset
void Reset() override
Reset the plugin.
gazebo::WheelTrackedVehiclePlugin::WheelInfo::joint
physics::JointPtr joint
The hinge joint connecting the wheel to the track/body.
Definition: WheelTrackedVehiclePlugin.hh:91
gazebo::WheelTrackedVehiclePlugin
An approximate model of non-deformable tracks emulated by wheels.
Definition: WheelTrackedVehiclePlugin.hh:49
gazebo::WheelTrackedVehiclePlugin::WheelInfo::radius
double radius
Radius of the wheel (used to convert linear to angular speed).
Definition: WheelTrackedVehiclePlugin.hh:98
gazebo::WheelTrackedVehiclePlugin::Load
void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) override
Called when the plugin is loaded.
gazebo::WheelTrackedVehiclePlugin::WheelInfo_V
std::vector< WheelInfoPtr > WheelInfo_V
Definition: WheelTrackedVehiclePlugin.hh:102
Joint.hh
gazebo::event::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
gazebo::WheelTrackedVehiclePlugin::WheelInfo
Holds information about each wheel.
Definition: WheelTrackedVehiclePlugin.hh:88
gazebo::WheelTrackedVehiclePlugin::WheelInfo::jointName
std::string jointName
Name of the hinge joint.
Definition: WheelTrackedVehiclePlugin.hh:94
gazebo::WheelTrackedVehiclePlugin::trackVelocity
std::unordered_map< Tracks, double > trackVelocity
Desired velocities of the tracks.
Definition: WheelTrackedVehiclePlugin.hh:108
gazebo::physics::JointPtr
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
gazebo::WheelTrackedVehiclePlugin::defaultWheelRadius
double defaultWheelRadius
The radius (in meters) used for wheels where autodetection fails.
Definition: WheelTrackedVehiclePlugin.hh:111
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
gazebo::WheelTrackedVehiclePlugin::world
physics::WorldPtr world
Pointer to the world the model lives in.
Definition: WheelTrackedVehiclePlugin.hh:114
gazebo::WheelTrackedVehiclePlugin::SetTrackVelocityImpl
void SetTrackVelocityImpl(double _left, double _right) override
Set new target velocity for the tracks.