34 GetSDFParam<double>(_sdf,
"saturation", this->
saturation, 3000);
35 GetSDFParam<bool>(_sdf,
"estimate_depth_on", this->
estimateDepth,
false);
38 GetSDFParam<double>(_sdf,
"kPa_per_meter", this->
kPaPerM, 9.80638);
41 this->
rosNode->advertise<sensor_msgs::FluidPressure>(
47 this->
gazeboNode->Advertise<sensor_msgs::msgs::Pressure>(
62 ignition::math::Vector3d pos;
63 #if GAZEBO_MAJOR_VERSION >= 8 64 pos = this->
link->WorldPose().Pos();
66 pos = this->
link->GetWorldPose().Ign().Pos();
69 double depth = std::abs(pos.Z());
74 pressure += depth * this->
kPaPerM;
79 double inferredDepth = 0.0;
89 sensor_msgs::msgs::Pressure gazeboMsg;
91 gazeboMsg.set_pressure(pressure);
95 gazeboMsg.set_depth(inferredDepth);
100 sensor_msgs::FluidPressure rosMsg;
102 rosMsg.header.stamp.sec = _info.simTime.sec;
103 rosMsg.header.stamp.nsec = _info.simTime.nsec;
104 rosMsg.header.frame_id = this->
link->GetName();
106 rosMsg.fluid_pressure = pressure;
112 #if GAZEBO_MAJOR_VERSION >= 8 double kPaPerM
Factor of kPa per meter.
double GetGaussianNoise(double _amp)
Returns noise value for a function with zero mean from the default Gaussian noise model...
void publish(const boost::shared_ptr< M > &message) const
bool EnableMeasurement(const common::UpdateInfo &_info) const
Enables generation of simulated measurement if the timeout since the last update has been reached...
~SubseaPressureROSPlugin()
Class destructor.
physics::WorldPtr world
Pointer to the world.
common::Time lastMeasurementTime
(Simulation) time when the last sensor measurement was generated.
virtual bool OnUpdate(const common::UpdateInfo &_info)
Update sensor measurement.
SubseaPressureROSPlugin()
Class constructor.
double noiseAmp
Noise amplitude.
virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
Load the plugin.
double saturation
Sensor saturation (max. value for output pressure in Pa)
virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
Load plugin and its configuration from sdf,.
transport::NodePtr gazeboNode
Gazebo's node handle for transporting measurement messages.
double noiseSigma
Noise standard deviation.
transport::PublisherPtr gazeboSensorOutputPub
Gazebo's publisher for transporting measurement messages.
physics::LinkPtr link
Pointer to the link.
std::string sensorOutputTopic
Name of the sensor's output topic.
ros::Publisher rosSensorOutputPub
Gazebo's publisher for transporting measurement messages.
boost::shared_ptr< ros::NodeHandle > rosNode
ROS node handle for communication with ROS.
GZ_REGISTER_MODEL_PLUGIN(GazeboRosP3D)
bool estimateDepth
If flag is set to true, estimate depth according to pressure measurement.
std::string robotNamespace
Robot namespace.
double standardPressure
Standard pressure.
bool gazeboMsgEnabled
Flag set to true if the Gazebo sensors messages are supposed to be published as well (it can avoid un...
void PublishState()
Publish the current state of the plugin.