5 #include <gazebo/physics/World.hh> 6 #include <gazebo/physics/HingeJoint.hh> 7 #include <gazebo/sensors/Sensor.hh> 8 #include <gazebo/common/Exception.hh> 9 #include <gazebo/sensors/RaySensor.hh> 10 #include <gazebo/sensors/SensorTypes.hh> 11 #include <gazebo/transport/transport.hh> 14 #include <sdf/Param.hh> 24 GZ_REGISTER_SENSOR_PLUGIN(GazeboRosIrSensor)
39 sdf::ElementPtr _sdf) {
41 RayPlugin::Load(_parent, this->
sdf_);
44 # if GAZEBO_MAJOR_VERSION >= 7 45 std::string worldName = _parent->WorldName();
47 std::string worldName = _parent->GetWorldName();
50 this->
world_ = physics::get_world(worldName);
57 dynamic_pointer_cast<sensors::RaySensor>(_parent);
60 gzthrow(
"GazeboRosIrSensor controller requires a Ray Sensor as its parent");
64 if (!this->
sdf_->HasElement(
"frameName")) {
67 "IR Sensor plugin missing <frameName>, defaults to world");
75 if (!this->
sdf_->HasElement(
"topicName")) {
78 "IR Sensor plugin missing <topicName>, defaults to /world");
90 ROS_FATAL_STREAM_NAMED(
"ir_sensor",
"A ROS node for Gazebo has not been initialized, unable to load plugin. " <<
"Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)");
96 "Starting IR Sensor Plugin (ns = %s)",
107 new gazebo::transport::Node());
117 boost::trim_right_if(this->
tf_prefix_, boost::is_any_of(
"/"));
123 "IR Sensor Plugin (ns = %s) <tf_prefix>, set to \"%s\"",
132 ros::AdvertiseOptions::create<std_msgs::Float32>(
154 # if GAZEBO_MAJOR_VERSION >= 7 194 std_msgs::Float32 ir_sensor_msg;
197 ir_sensor_msg.data = (float)_msg->scan().ranges(0) * 100.0;
void push(T &msg, ros::Publisher &pub)
gazebo::transport::SubscriberPtr ir_sensor_scan_sub_
#define ROS_INFO_NAMED(name,...)
std::string getPrefixParam(ros::NodeHandle &nh)
ros::NodeHandle * rosnode_
PubQueue< std_msgs::Float32 >::Ptr pub_queue_
ROSCPP_DECL bool isInitialized()
std::string resolve(const std::string &prefix, const std::string &frame_name)
#define ROS_FATAL_STREAM_NAMED(name, args)
void IrSensorDisconnect()
std::string robot_namespace_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf)
boost::shared_ptr< PubQueue< T > > addPub()
gazebo::transport::NodePtr gazebo_node_
int ir_sensor_connect_count_
boost::thread deferred_load_thread_
void startServiceThread()
std::string GetRobotNamespace(const sensors::SensorPtr &parent, const sdf::ElementPtr &sdf, const char *pInfo=NULL)
#define GAZEBO_SENSORS_USING_DYNAMIC_POINTER_CAST
boost::shared_ptr< void > VoidPtr
sensors::RaySensorPtr parent_ray_sensor_
void OnScan(ConstLaserScanStampedPtr &_msg)