3 import roslib; roslib.load_manifest(
'map_laser')
6 from sensor_msgs.msg
import LaserScan
7 from nav_msgs.msg
import OccupancyGrid
8 from tf.transformations
import euler_from_quaternion
9 from std_msgs.msg
import ColorRGBA
15 rospy.init_node(
'map_laser_filter')
16 self.
pub = rospy.Publisher(
'/base_scan_filter',
22 self.
sub = rospy.Subscriber(
'/scan_filtered',
26 self.
sub2 = rospy.Subscriber(
'/map', OccupancyGrid, self.
map_cb)
33 now = msg.header.stamp
34 f2 = msg.header.frame_id
36 self.listener.waitForTransform(f1, f2, now, rospy.Duration(.15))
38 return self.listener.lookupTransform(f1, f2, now)
42 for dx
in range(-N, N + 1):
43 for dy
in range(-N, N + 1):
44 index = (x + dx) + (y + dy) * self.map.info.width
45 if index < 0
or index > len(self.map.data):
47 value = self.map.data[index]
48 if value > 50
or value < 0:
58 self.
save = (trans, rot)
62 (trans, rot) = self.
save 64 yaw = euler_from_quaternion(rot)[2]
68 for (i, d)
in enumerate(msg.ranges):
69 if math.isnan(d)
or d > msg.range_max
or d < msg.range_min:
70 nr.append(msg.range_max + 1.0)
72 angle = yaw + msg.angle_min + msg.angle_increment*i
73 dx = math.cos(angle) * d
74 dy = math.sin(angle) * d
78 grid_x = int((map_x - self.map.info.origin.position.x) / self.map.info.resolution)
79 grid_y = int((map_y - self.map.info.origin.position.y) / self.map.info.resolution)
82 nr.append(msg.range_max + 1.0)
89 if __name__ ==
'__main__':
def get_laser_frame(self, msg)
def is_occupied(self, x, y)