30 #include <gazebo/physics/physics.hh> 67 world = _model->GetWorld();
70 if (!_sdf->HasElement(
"robotNamespace"))
73 namespace_ = _sdf->GetElement(
"robotNamespace")->GetValue()->GetAsString();
75 if (!_sdf->HasElement(
"bodyName"))
77 link = _model->GetLink();
81 link_name_ = _sdf->GetElement(
"bodyName")->GetValue()->GetAsString();
101 fix_.status.status = sensor_msgs::NavSatStatus::STATUS_FIX;
102 fix_.status.service = 0;
104 if (_sdf->HasElement(
"frameId"))
105 frame_id_ = _sdf->GetElement(
"frameId")->GetValue()->GetAsString();
107 if (_sdf->HasElement(
"topicName"))
108 fix_topic_ = _sdf->GetElement(
"topicName")->GetValue()->GetAsString();
110 if (_sdf->HasElement(
"velocityTopicName"))
111 velocity_topic_ = _sdf->GetElement(
"velocityTopicName")->GetValue()->GetAsString();
113 if (_sdf->HasElement(
"referenceLatitude"))
116 if (_sdf->HasElement(
"referenceLongitude"))
119 if (_sdf->HasElement(
"referenceHeading"))
123 if (_sdf->HasElement(
"referenceAltitude"))
126 if (_sdf->HasElement(
"status")) {
127 int status =
fix_.status.status;
128 if (_sdf->GetElement(
"status")->GetValue()->Get(status))
129 fix_.status.status = static_cast<sensor_msgs::NavSatStatus::_status_type>(status);
132 if (_sdf->HasElement(
"service")) {
133 unsigned int service =
fix_.status.service;
134 if (_sdf->GetElement(
"service")->GetValue()->Get(service))
135 fix_.status.service = static_cast<sensor_msgs::NavSatStatus::_service_type>(service);
153 ROS_FATAL_STREAM(
"A ROS node for Gazebo has not been initialized, unable to load plugin. " 154 <<
"Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)");
187 using sensor_msgs::NavSatStatus;
189 if (!config.STATUS_FIX) {
190 fix_.status.status = NavSatStatus::STATUS_NO_FIX;
192 fix_.status.status = (config.STATUS_SBAS_FIX ? NavSatStatus::STATUS_SBAS_FIX : 0) |
193 (config.STATUS_GBAS_FIX ? NavSatStatus::STATUS_GBAS_FIX : 0);
195 fix_.status.service = (config.SERVICE_GPS ? NavSatStatus::SERVICE_GPS : 0) |
196 (config.SERVICE_GLONASS ? NavSatStatus::SERVICE_GLONASS : 0) |
197 (config.SERVICE_COMPASS ? NavSatStatus::SERVICE_COMPASS : 0) |
198 (config.SERVICE_GALILEO ? NavSatStatus::SERVICE_GALILEO : 0);
200 config.STATUS_FIX = (
fix_.status.status != NavSatStatus::STATUS_NO_FIX);
201 config.STATUS_SBAS_FIX = (
fix_.status.status & NavSatStatus::STATUS_SBAS_FIX);
202 config.STATUS_GBAS_FIX = (
fix_.status.status & NavSatStatus::STATUS_GBAS_FIX);
203 config.SERVICE_GPS = (
fix_.status.service & NavSatStatus::SERVICE_GPS);
204 config.SERVICE_GLONASS = (
fix_.status.service & NavSatStatus::SERVICE_GLONASS);
205 config.SERVICE_COMPASS = (
fix_.status.service & NavSatStatus::SERVICE_COMPASS);
206 config.SERVICE_GALILEO = (
fix_.status.service & NavSatStatus::SERVICE_GALILEO);
214 #if (GAZEBO_MAJOR_VERSION >= 8) 215 common::Time sim_time =
world->SimTime();
218 ignition::math::Pose3d pose =
link->WorldPose();
223 common::Time sim_time =
world->GetSimTime();
226 math::Pose pose =
link->GetWorldPose();
239 #if (GAZEBO_MAJOR_VERSION >= 8) 247 fix_.position_covariance_type = sensor_msgs::NavSatFix::COVARIANCE_TYPE_DIAGONAL_KNOWN;
259 fix_.position_covariance_type = sensor_msgs::NavSatFix::COVARIANCE_TYPE_DIAGONAL_KNOWN;
static const double DEFAULT_REFERENCE_ALTITUDE
virtual const T & getCurrentDrift() const
static const double DEFAULT_REFERENCE_LONGITUDE
virtual void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf, const std::string &_prefix="update")
double reference_longitude_
virtual void setCurrentDrift(const T &new_drift)
void publish(const boost::shared_ptr< M > &message) const
static const double flattening
virtual void Load(sdf::ElementPtr _sdf, const std::string &prefix=std::string())
void dynamicReconfigureCallback(GNSSConfig &config, uint32_t level)
static const double equatorial_radius
sensor_msgs::NavSatFix fix_
ROSCPP_DECL bool isInitialized()
physics::WorldPtr world
The parent World.
virtual event::ConnectionPtr Connect(const boost::function< void()> &_subscriber, bool connectToWorldUpdateBegin=true)
boost::shared_ptr< dynamic_reconfigure::Server< SensorModelConfig > > dynamic_reconfigure_server_velocity_
double reference_heading_
ros::Publisher fix_publisher_
boost::shared_ptr< dynamic_reconfigure::Server< GNSSConfig > > dynamic_reconfigure_server_status_
double reference_altitude_
static const double DEFAULT_REFERENCE_HEADING
hector_gazebo_plugins::GNSSConfig GNSSConfig
#define ROS_FATAL_STREAM(args)
virtual void Disconnect(event::ConnectionPtr const &_c=event::ConnectionPtr())
std::string velocity_topic_
virtual void dynamicReconfigureCallback(SensorModelConfig &config, uint32_t level)
common::Time getTimeSinceLastUpdate() const
virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
SensorModel3 velocity_error_model_
geometry_msgs::Vector3Stamped velocity_
static const double excentrity2
event::ConnectionPtr updateConnection
physics::LinkPtr link
The link referred to by this plugin.
static const double DEFAULT_REFERENCE_LATITUDE
double reference_latitude_
ros::Publisher velocity_publisher_
void setUpdateRate(double rate)
ros::NodeHandle * node_handle_
boost::shared_ptr< dynamic_reconfigure::Server< SensorModelConfig > > dynamic_reconfigure_server_position_
SensorModel3 position_error_model_