20 #include <gazebo/physics/Base.hh> 21 #include <gazebo/physics/Link.hh> 22 #include <gazebo/physics/Model.hh> 23 #include <gazebo/physics/World.hh> 37 #if GAZEBO_MAJOR_VERSION >= 8 40 gazebo::event::Events::DisconnectWorldUpdateBegin(
48 const uuv_gazebo_ros_plugins_msgs::FloatStamped::ConstPtr &_msg)
50 if (std::isnan(_msg->data))
52 ROS_WARN(
"FinROSPlugin: Ignoring nan command");
90 FinPlugin::Load(_parent, _sdf);
91 }
catch(gazebo::common::Exception &_e)
93 gzerr <<
"Error loading plugin." 94 <<
"Please ensure that your model is correct." 101 gzerr <<
"Not loading plugin since ROS has not been " 102 <<
"properly initialized. Try starting gazebo with ros plugin:\n" 103 <<
" gazebo -s libgazebo_ros_api_plugin.so\n";
110 uuv_gazebo_ros_plugins_msgs::FloatStamped
115 uuv_gazebo_ros_plugins_msgs::FloatStamped
118 std::string wrenchTopic;
119 if (_sdf->HasElement(
"wrench_topic"))
120 wrenchTopic = _sdf->Get<std::string>(
"wrench_topic");
125 this->
rosNode->advertise<geometry_msgs::WrenchStamped>(wrenchTopic, 10);
127 std::stringstream stream;
128 stream << _parent->GetName() <<
"/fins/" << this->
finID <<
129 "/get_lift_drag_params";
130 this->
services[
"get_lift_drag_params"] = this->
rosNode->advertiseService(
133 gzmsg <<
"Fin #" << this->
finID <<
" initialized" << std::endl
134 <<
"\t- Link: " << this->
link->GetName() << std::endl
135 <<
"\t- Robot model: " << _parent->GetName() << std::endl
136 <<
"\t- Input command topic: " <<
138 <<
"\t- Output topic: " <<
155 uuv_gazebo_ros_plugins_msgs::FloatStamped state_msg;
157 state_msg.header.frame_id = this->
link->GetName();
158 state_msg.data = this->
angle;
162 geometry_msgs::WrenchStamped msg;
164 msg.header.frame_id = this->
link->GetName();
165 msg.wrench.force.x = this->
finForce.X();
166 msg.wrench.force.y = this->
finForce.Y();
167 msg.wrench.force.z = this->
finForce.Z();
175 uuv_gazebo_ros_plugins_msgs::GetListParam::Request& _req,
176 uuv_gazebo_ros_plugins_msgs::GetListParam::Response& _res)
178 _res.description = this->
liftdrag->GetType();
179 for (
auto& item : this->
liftdrag->GetListParams())
181 _res.tags.push_back(item.first);
182 _res.data.push_back(item.second);
void Load(gazebo::physics::ModelPtr _parent, sdf::ElementPtr _sdf)
Load module and read parameters from SDF.
ignition::math::Vector3d finForce
std::map< std::string, ros::ServiceServer > services
Map of services.
void publish(const boost::shared_ptr< M > &message) const
ros::Publisher pubFinForce
Publisher for current actual thrust.
ROSCPP_DECL bool isInitialized()
GZ_REGISTER_MODEL_PLUGIN(UmbilicalPlugin)
virtual void Reset()
Reset Module.
~FinROSPlugin()
Destructor.
FinROSPlugin()
Constrcutor.
gazebo::event::ConnectionPtr rosPublishConnection
Connection for callbacks on update world.
void RosPublishStates()
Publish state via ROS.
void SetRosPublishRate(double _hz)
Set the ROS publish frequency (Hz).
bool GetLiftDragParams(uuv_gazebo_ros_plugins_msgs::GetListParam::Request &_req, uuv_gazebo_ros_plugins_msgs::GetListParam::Response &_res)
Return the list of paramaters of the lift and drag model.
gazebo::common::Time rosPublishPeriod
Period after which we should publish a message via ROS.
void SetReference(const uuv_gazebo_ros_plugins_msgs::FloatStamped::ConstPtr &_msg)
Set new set point.
virtual void Init()
Initialize Module.
boost::scoped_ptr< ros::NodeHandle > rosNode
Pointer to this ROS node's handle.
gazebo::common::Time lastRosPublishTime
Last time we published a message via ROS.
transport::SubscriberPtr commandSubscriber
ros::Publisher pubState
Publisher for current state.
transport::PublisherPtr anglePublisher
ros::Subscriber subReference
Subscriber reacting to new reference set points.
std::shared_ptr< LiftDrag > liftdrag
gazebo::common::Time GetRosPublishPeriod()
Return the ROS publish period.