30 #if GAZEBO_MAJOR_VERSION >= 8 33 gazebo::event::Events::DisconnectWorldUpdateBegin(
45 UnderwaterCurrentPlugin::Load(_world, _sdf);
46 }
catch(gazebo::common::Exception &_e)
48 gzerr <<
"Error loading plugin." 49 <<
"Please ensure that your model is correct." 56 gzerr <<
"Not loading plugin since ROS has not been " 57 <<
"properly initialized. Try starting gazebo with ros plugin:\n" 58 <<
" gazebo -s libgazebo_ros_api_plugin.so\n";
63 if (_sdf->HasElement(
"namespace"))
64 this->
ns = _sdf->Get<std::string>(
"namespace");
66 gzmsg <<
"UnderwaterCurrentROSPlugin::namespace=" << this->
ns << std::endl;
76 this->
rosNode->advertiseService(
77 "set_current_velocity_model",
81 this->worldServices[
"get_current_velocity_model"] =
82 this->
rosNode->advertiseService(
83 "get_current_velocity_model",
87 this->worldServices[
"set_current_horz_angle_model"] =
88 this->
rosNode->advertiseService(
89 "set_current_horz_angle_model",
93 this->worldServices[
"get_current_horz_angle_model"] =
94 this->
rosNode->advertiseService(
95 "get_current_horz_angle_model",
99 this->worldServices[
"set_current_vert_angle_model"] =
100 this->
rosNode->advertiseService(
101 "set_current_vert_angle_model",
105 this->worldServices[
"get_current_vert_angle_model"] =
106 this->
rosNode->advertiseService(
107 "get_current_vert_angle_model",
111 this->worldServices[
"set_current_velocity"] =
112 this->
rosNode->advertiseService(
113 "set_current_velocity",
117 this->worldServices[
"set_current_horz_angle"] =
118 this->
rosNode->advertiseService(
119 "set_current_horz_angle",
123 this->worldServices[
"set_current_vert_angle"] =
124 this->
rosNode->advertiseService(
125 "set_current_vert_angle",
138 geometry_msgs::TwistStamped flowVelMsg;
140 flowVelMsg.header.frame_id =
"/world";
152 uuv_world_ros_plugins_msgs::SetCurrentDirection::Request& _req,
153 uuv_world_ros_plugins_msgs::SetCurrentDirection::Response& _res)
162 uuv_world_ros_plugins_msgs::SetCurrentDirection::Request& _req,
163 uuv_world_ros_plugins_msgs::SetCurrentDirection::Response& _res)
171 uuv_world_ros_plugins_msgs::SetCurrentVelocity::Request& _req,
172 uuv_world_ros_plugins_msgs::SetCurrentVelocity::Response& _res)
178 gzmsg <<
"Current velocity [m/s] = " << _req.velocity << std::endl
179 <<
"Current horizontal angle [rad] = " << _req.horizontal_angle
181 <<
"Current vertical angle [rad] = " << _req.vertical_angle
183 <<
"\tWARNING: Current velocity calculated in the ENU frame" 189 gzmsg <<
"Error while updating the current velocity" << std::endl;
190 _res.success =
false;
197 uuv_world_ros_plugins_msgs::GetCurrentModel::Request& _req,
198 uuv_world_ros_plugins_msgs::GetCurrentModel::Response& _res)
210 uuv_world_ros_plugins_msgs::GetCurrentModel::Request& _req,
211 uuv_world_ros_plugins_msgs::GetCurrentModel::Response& _res)
223 uuv_world_ros_plugins_msgs::GetCurrentModel::Request& _req,
224 uuv_world_ros_plugins_msgs::GetCurrentModel::Response& _res)
237 uuv_world_ros_plugins_msgs::SetCurrentModel::Request& _req,
238 uuv_world_ros_plugins_msgs::SetCurrentModel::Response& _res)
241 std::max(0.0, _req.mean),
242 std::max(0.0, _req.min),
243 std::max(0.0, _req.max),
246 gzmsg <<
"Current velocity model updated" << std::endl
247 <<
"\tWARNING: Current velocity calculated in the ENU frame" 255 uuv_world_ros_plugins_msgs::SetCurrentModel::Request& _req,
256 uuv_world_ros_plugins_msgs::SetCurrentModel::Response& _res)
259 _req.max, _req.mu, _req.noise);
260 gzmsg <<
"Horizontal angle model updated" << std::endl
261 <<
"\tWARNING: Current velocity calculated in the ENU frame" 269 uuv_world_ros_plugins_msgs::SetCurrentModel::Request& _req,
270 uuv_world_ros_plugins_msgs::SetCurrentModel::Response& _res)
273 _req.max, _req.mu, _req.noise);
274 gzmsg <<
"Vertical angle model updated" << std::endl
275 <<
"\tWARNING: Current velocity calculated in the ENU frame" GaussMarkovProcess currentVelModel
ros::Publisher flowVelocityPub
Publisher for the flow velocity in the world frame.
void publish(const boost::shared_ptr< M > &message) const
gazebo::common::Time rosPublishPeriod
Period after which we should publish a message via ROS.
bool UpdateCurrentVertAngleModel(uuv_world_ros_plugins_msgs::SetCurrentModel::Request &_req, uuv_world_ros_plugins_msgs::SetCurrentModel::Response &_res)
Service call to update the parameters for the vertical angle Gauss-Markov process model...
bool UpdateCurrentVelocity(uuv_world_ros_plugins_msgs::SetCurrentVelocity::Request &_req, uuv_world_ros_plugins_msgs::SetCurrentVelocity::Response &_res)
Service call to update the mean value of the flow velocity.
ROSCPP_DECL bool isInitialized()
bool GetCurrentVelocityModel(uuv_world_ros_plugins_msgs::GetCurrentModel::Request &_req, uuv_world_ros_plugins_msgs::GetCurrentModel::Response &_res)
Service call to read the parameters for the velocity Gauss-Markov process model.
std::string currentVelocityTopic
virtual ~UnderwaterCurrentROSPlugin()
Class destructor.
void OnUpdateCurrentVel()
Publishes ROS topics.
bool UpdateHorzAngle(uuv_world_ros_plugins_msgs::SetCurrentDirection::Request &_req, uuv_world_ros_plugins_msgs::SetCurrentDirection::Response &_res)
Service call to update the mean value of the horizontal angle.
bool UpdateCurrentHorzAngleModel(uuv_world_ros_plugins_msgs::SetCurrentModel::Request &_req, uuv_world_ros_plugins_msgs::SetCurrentModel::Response &_res)
Service call to update the parameters for the horizontal angle Gauss-Markov process model...
gazebo::common::Time lastRosPublishTime
Last time we published a message via ROS.
bool SetMean(double _mean)
GaussMarkovProcess currentHorzAngleModel
boost::scoped_ptr< ros::NodeHandle > rosNode
Pointer to this ROS node's handle.
bool UpdateVertAngle(uuv_world_ros_plugins_msgs::SetCurrentDirection::Request &_req, uuv_world_ros_plugins_msgs::SetCurrentDirection::Response &_res)
Service call to update the mean value of the vertical angle.
bool UpdateCurrentVelocityModel(uuv_world_ros_plugins_msgs::SetCurrentModel::Request &_req, uuv_world_ros_plugins_msgs::SetCurrentModel::Response &_res)
Service call to update the parameters for the velocity Gauss-Markov process model.
bool SetModel(double _mean, double _min, double _max, double _mu=0, double _noise=0)
UnderwaterCurrentROSPlugin()
Class constructor.
GaussMarkovProcess currentVertAngleModel
ignition::math::Vector3d currentVelocity
bool GetCurrentHorzAngleModel(uuv_world_ros_plugins_msgs::GetCurrentModel::Request &_req, uuv_world_ros_plugins_msgs::GetCurrentModel::Response &_res)
Service call to read the parameters for the horizontal angle Gauss-Markov process model...
std::map< std::string, ros::ServiceServer > worldServices
All underwater world services.
void Load(gazebo::physics::WorldPtr _world, sdf::ElementPtr _sdf)
Load module and read parameters from SDF.
Publishes the constant flow velocity in ROS messages and creates a service to alter the flow model in...
gazebo::event::ConnectionPtr rosPublishConnection
Connection for callbacks on update world.
bool GetCurrentVertAngleModel(uuv_world_ros_plugins_msgs::GetCurrentModel::Request &_req, uuv_world_ros_plugins_msgs::GetCurrentModel::Response &_res)
Service call to read the parameters for the vertical angle Gauss-Markov process model.