35 const stdr_msgs::SonarSensorMsg& msg,
36 const std::string& name,
39 Sensor(map, name, n, msg.pose, msg.frame_id, msg.frequency)
65 sensor_msgs::Range sonarRangeMsg;
69 sonarRangeMsg.radiation_type = 0;
72 if (
_map.info.height == 0 ||
_map.info.width == 0 )
80 float angleStep = 3.14159 / 180.0;
87 for (
float sonarIter = angleMin; sonarIter < angleMax;
88 sonarIter += angleStep )
102 if (yMap *
_map.info.width + xMap >
_map.info.height*
_map.info.width ||
103 yMap *
_map.info.width + xMap < 0)
110 if (
_map.data[ yMap *
_map.info.width + xMap ] > 70 )
117 if ( distance *
_map.info.resolution < sonarRangeMsg.range )
119 sonarRangeMsg.range = distance *
_map.info.resolution;
125 sonarRangeMsg.range = -std::numeric_limits<float>::infinity();
127 else if ( sonarRangeMsg.range >=
_description.maxRange )
129 sonarRangeMsg.range = std::numeric_limits<float>::infinity();
const std::string & _namespace
< The base for the sensor frame_id
void publish(const boost::shared_ptr< M > &message) const
The main namespace for STDR Robot.
static double getYaw(const Quaternion &bt_q)
A class that provides sensor abstraction.
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
stdr_msgs::SonarSensorMsg _description
< Sonar sensor description
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
TFSIMD_FORCE_INLINE const tfScalar & x() const
virtual void updateSensorCallback()
Updates the sensor measurements.
Sonar(const nav_msgs::OccupancyGrid &map, const stdr_msgs::SonarSensorMsg &msg, const std::string &name, ros::NodeHandle &n)
Default constructor.
tf::StampedTransform _sensorTransform
True if sensor got the _sensorTransform.
TFSIMD_FORCE_INLINE const tfScalar & y() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
const nav_msgs::OccupancyGrid & _map
Sensor pose relative to robot.
~Sonar(void)
Default destructor.
ros::Publisher _publisher
ROS tf listener.