31 gzmsg <<
"GPSROSPlugin - Loading base sensor plugin" << std::endl;
34 gzmsg <<
"GPSROSPlugin - Converting GPS sensor pointer" << std::endl;
36 std::dynamic_pointer_cast<sensors::GpsSensor>(_parent);
38 gzmsg <<
"GPSROSPlugin - Initialize sensor topic publisher" << std::endl;
46 sensor_msgs::NavSatFix::COVARIANCE_TYPE_KNOWN;
48 double horizontalPosStdDev = 0.0;
49 GetSDFParam(_sdf,
"horizontal_pos_std_dev", horizontalPosStdDev, 0.0);
51 double verticalPosStdDev = 0.0;
52 GetSDFParam(_sdf,
"vertical_pos_std_dev", verticalPosStdDev, 0.0);
54 this->
gpsMessage.position_covariance[0] = horizontalPosStdDev * horizontalPosStdDev;
55 this->
gpsMessage.position_covariance[4] = horizontalPosStdDev * horizontalPosStdDev;
56 this->
gpsMessage.position_covariance[8] = verticalPosStdDev * verticalPosStdDev;
59 this->
gpsMessage.status.status = sensor_msgs::NavSatStatus::STATUS_FIX;
60 this->
gpsMessage.status.service = sensor_msgs::NavSatStatus::SERVICE_GPS;
72 common::Time currentTime = this->
gazeboGPSSensor->LastMeasurementTime();
74 this->
gpsMessage.header.stamp.sec = currentTime.sec;
75 this->
gpsMessage.header.stamp.nsec = currentTime.nsec;
GPSROSPlugin()
Class constructor.
virtual void Load(sensors::SensorPtr _model, sdf::ElementPtr _sdf)
Load plugin and its configuration from sdf,.
void publish(const boost::shared_ptr< M > &message) const
bool GetSDFParam(sdf::ElementPtr sdf, const std::string &name, T ¶m, const T &default_value, const bool &verbose=false)
Obtains a parameter from sdf.
event::ConnectionPtr updateConnection
Pointer to the update event connection.
bool OnUpdateGPS()
Update GPS ROS message.
virtual ~GPSROSPlugin()
Class destructor.
std::string sensorOutputTopic
Name of the sensor's output topic.
ros::Publisher rosSensorOutputPub
Gazebo's publisher for transporting measurement messages.
sensors::GpsSensorPtr gazeboGPSSensor
Pointer to the parent sensor.
boost::shared_ptr< ros::NodeHandle > rosNode
ROS node handle for communication with ROS.
virtual void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf)
Load module and read parameters from SDF.
std::string robotNamespace
Robot namespace.
sensor_msgs::NavSatFix gpsMessage
Output GPS ROS message.
void PublishState()
Publish the current state of the plugin.