Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
gazebo::UsvThrust Class Reference

A plugin to simulate a propulsion system under water. This plugin accepts the following SDF parameters. See https://github.com/bsb808/robotx_docs/blob/master/theoryofoperation/theory_of_operation.pdf for more information. More...

#include <usv_gazebo_thrust_plugin.hh>

Inheritance diagram for gazebo::UsvThrust:
Inheritance graph
[legend]

Public Member Functions

virtual void Load (physics::ModelPtr _parent, sdf::ElementPtr _sdf)
 
 UsvThrust ()=default
 Constructor. More...
 
virtual ~UsvThrust ()=default
 Destructor. More...
 

Public Attributes

std::mutex mutex
 A mutex to protect member variables accessed during OnThustCmd() and Update(). More...
 
physics::WorldPtr world
 Pointer to the Gazebo world, retrieved when the model is loaded. More...
 

Protected Member Functions

virtual void Update ()
 Callback executed at every physics update. More...
 

Private Member Functions

double Glf (const double _x, const float _A, const float _K, const float _B, const float _v, const float _C, const float _M) const
 Generalized logistic function (GLF) used for non-linear thruster model. More...
 
double GlfThrustCmd (const double _cmd, const double _maxPos, const double _maxNeg) const
 Uses GLF function to map thrust command to thruster force in Newtons. More...
 
void RotateEngine (size_t _i, common::Time _stepTime)
 Rotate engine using engine joint PID. More...
 
double ScaleThrustCmd (const double _cmd, const double _max_cmd, const double _max_pos, const double _max_neg) const
 Takes ROS Drive commands and scales them by max thrust. More...
 
double SdfParamDouble (sdf::ElementPtr _sdfPtr, const std::string &_paramName, const double _defaultVal) const
 Convenience function for getting SDF parameters. More...
 
void SpinPropeller (size_t _i)
 Spin a propeller based on its current command. More...
 

Private Attributes

double cmdTimeout
 Timeout for receiving Drive commands [s]. More...
 
sensor_msgs::JointState jointStateMsg
 The propeller message state. More...
 
ros::Publisher jointStatePub
 For publishing to /joint_state with propeller state. More...
 
physics::ModelPtr model
 Pointer to Gazebo parent model, retrieved when the model is loaded. More...
 
std::unique_ptr< ros::NodeHandlerosnode
 The ROS node handler used for communications. More...
 
std::vector< Thrusterthrusters
 Vector of thruster instances. More...
 
event::ConnectionPtr updateConnection
 Pointer to the update event connection. More...
 

Detailed Description

A plugin to simulate a propulsion system under water. This plugin accepts the following SDF parameters. See https://github.com/bsb808/robotx_docs/blob/master/theoryofoperation/theory_of_operation.pdf for more information.

<robotNamespace>: Namespace prefix for USV. <cmdTimeout>: Timeout, after which thrust is set to zero [s].

Multiple thrusters are declared by including <thruster> SDF elements, where each thruster includes the following SDF parameters specific to the individual thruster Required elements: <linkName>: Name of the link on which to apply thrust forces. <propJointName>: The name of the propeller joint. <engineJointName>: The name of the engine joint. <cmdTopic>: The ROS topic to control this thruster, typically within [-1.0 , 1.0] <angleTopic>: The ROS topic to control the angle of this thruster, will be clipped to stay within [-maxAngle, maxAngle] <enableAngle>: If true, thruster will have adjustable angle. If false, thruster will have constant angle. Optional elements: <mappingType>: Thruster mapping (0=linear; 1=GLF, nonlinear), default is 0 <maxCmd>:Maximum (abs val) of thrust commands, defualt is 1.0 <maxForceFwd>: Maximum forward force [N]. default is 250.0 N <maxForceRev>: Maximum reverse force [N]. default is -100.0 N <maxAngle>: Absolute value of maximum thruster angle [radians]. default is pi/2

Here is an example:

<plugin name="example" filename="libusv_gazebo_thrust_plugin.so">

<cmdTimeout>1.0</cmdTimeout>

 <thruster>
   <linkName>left_propeller_link</linkName>
   <propJointName>left_engine_propeller_joint</propJointName>
   <engineJointName>left_chasis_engine_joint</engineJointName>
   <cmdTopic>left_thrust_cmd</cmdTopic>
   <angleTopic>left_thrust_angle</angleTopic>
   <enableAngle>false</enableAngle>
   <mappingType>1</mappingType>
   <maxCmd>1.0</maxCmd>
   <maxForceFwd>250.0</maxForceFwd>
   <maxForceRev>-100.0</maxForceRev>
   <maxAngle>1.57</maxAngle>
 </thruster>
 <thruster>
   <linkName>right_propeller_link</linkName>
   <propJointName>right_engine_propeller_joint</propJointName>
   <engineJointName>right_chasis_engine_joint</engineJointName>
   <cmdTopic>right_thrust_cmd</cmdTopic>
   <angleTopic>right_thrust_angle</angleTopic>
   <enableAngle>false</enableAngle>
   <mappingType>1</mappingType>
   <maxCmd>1.0</maxCmd>
   <maxForceFwd>250.0</maxForceFwd>
   <maxForceRev>-100.0</maxForceRev>
   <maxAngle>1.57</maxAngle>
 </thruster>

</plugin>

Definition at line 181 of file usv_gazebo_thrust_plugin.hh.

Constructor & Destructor Documentation

gazebo::UsvThrust::UsvThrust ( )
default

Constructor.

virtual gazebo::UsvThrust::~UsvThrust ( )
virtualdefault

Destructor.

Member Function Documentation

double UsvThrust::Glf ( const double  _x,
const float  _A,
const float  _K,
const float  _B,
const float  _v,
const float  _C,
const float  _M 
) const
private

Generalized logistic function (GLF) used for non-linear thruster model.

Parameters
[in]_xIndependent variable (input) of GLF.
[in]_ALower asymptote.
[in]_KUpper asymptote.
[in]_BGrowth rate
[in]_vAffects near which asymptote max. growth occurs.
[in]_CTypically near 1.0.
[in]_MOffset to input.
Returns

Definition at line 309 of file usv_gazebo_thrust_plugin.cc.

double UsvThrust::GlfThrustCmd ( const double  _cmd,
const double  _maxPos,
const double  _maxNeg 
) const
private

Uses GLF function to map thrust command to thruster force in Newtons.

Parameters
[in]_cmdThrust command {-1.0,1.0}.
Returns
Thrust force [N].

Definition at line 316 of file usv_gazebo_thrust_plugin.cc.

void UsvThrust::Load ( physics::ModelPtr  _parent,
sdf::ElementPtr  _sdf 
)
virtual

Definition at line 86 of file usv_gazebo_thrust_plugin.cc.

void UsvThrust::RotateEngine ( size_t  _i,
common::Time  _stepTime 
)
private

Rotate engine using engine joint PID.

Parameters
[in]_iIndex of thruster whose engine will be rotated
[in]_stepTimecommon::Time since last rotation

Definition at line 395 of file usv_gazebo_thrust_plugin.cc.

double UsvThrust::ScaleThrustCmd ( const double  _cmd,
const double  _max_cmd,
const double  _max_pos,
const double  _max_neg 
) const
private

Takes ROS Drive commands and scales them by max thrust.

Parameters
[in]_cmdROS drive command.
Returns
Value scaled and saturated.

Definition at line 290 of file usv_gazebo_thrust_plugin.cc.

double UsvThrust::SdfParamDouble ( sdf::ElementPtr  _sdfPtr,
const std::string &  _paramName,
const double  _defaultVal 
) const
private

Convenience function for getting SDF parameters.

Parameters
[in]_sdfPtrPointer to an SDF element to parse.
[in]_paramNameThe name of the element to parse.
[in]_defaultValThe default value returned if the element does not exist.
Returns
The value parsed.

Definition at line 69 of file usv_gazebo_thrust_plugin.cc.

void UsvThrust::SpinPropeller ( size_t  _i)
private

Spin a propeller based on its current command.

Parameters
[in]_iIndex of thruster whose propeller will be spun

Definition at line 428 of file usv_gazebo_thrust_plugin.cc.

void UsvThrust::Update ( )
protectedvirtual

Callback executed at every physics update.

Definition at line 335 of file usv_gazebo_thrust_plugin.cc.

Member Data Documentation

double gazebo::UsvThrust::cmdTimeout
private

Timeout for receiving Drive commands [s].

Definition at line 265 of file usv_gazebo_thrust_plugin.hh.

sensor_msgs::JointState gazebo::UsvThrust::jointStateMsg
private

The propeller message state.

Definition at line 277 of file usv_gazebo_thrust_plugin.hh.

ros::Publisher gazebo::UsvThrust::jointStatePub
private

For publishing to /joint_state with propeller state.

Definition at line 274 of file usv_gazebo_thrust_plugin.hh.

physics::ModelPtr gazebo::UsvThrust::model
private

Pointer to Gazebo parent model, retrieved when the model is loaded.

Definition at line 262 of file usv_gazebo_thrust_plugin.hh.

std::mutex gazebo::UsvThrust::mutex

A mutex to protect member variables accessed during OnThustCmd() and Update().

Definition at line 252 of file usv_gazebo_thrust_plugin.hh.

std::unique_ptr<ros::NodeHandle> gazebo::UsvThrust::rosnode
private

The ROS node handler used for communications.

Definition at line 255 of file usv_gazebo_thrust_plugin.hh.

std::vector<Thruster> gazebo::UsvThrust::thrusters
private

Vector of thruster instances.

Definition at line 268 of file usv_gazebo_thrust_plugin.hh.

event::ConnectionPtr gazebo::UsvThrust::updateConnection
private

Pointer to the update event connection.

Definition at line 271 of file usv_gazebo_thrust_plugin.hh.

physics::WorldPtr gazebo::UsvThrust::world

Pointer to the Gazebo world, retrieved when the model is loaded.

Definition at line 258 of file usv_gazebo_thrust_plugin.hh.


The documentation for this class was generated from the following files:


usv_gazebo_plugins
Author(s): Brian Bingham , Carlos Aguero
autogenerated on Thu May 7 2020 03:54:47