4 Test plugin gazebo_ros_block_laser using gazebo_ros_block_laser_clipping.world.
9 from sensor_msgs.msg
import PointCloud
18 msg = rospy.wait_for_message(
'test_block_laser', PointCloud)
19 for point
in msg.points:
20 yield math.sqrt(point.x**2 + point.y**2 + point.z**2)
26 bins = [b * BIN_SIZE + self.
MIN_RANGE for b
in range(num_bins)]
27 bin_counts = dict(zip(bins, [0] * len(bins)))
31 closest_dist = float(
'inf')
34 if abs(r - b) < closest_dist:
37 bin_counts[closest_bin] += 1
39 self.assertTrue(0
not in bin_counts.values(), msg=repr(bin_counts))
42 ALLOWED_ERROR = 0.00001
44 self.assertGreater(r, self.
MIN_RANGE - ALLOWED_ERROR)
45 self.assertLess(r, self.
MAX_RANGE + ALLOWED_ERROR)
48 if __name__ ==
'__main__':
50 PKG_NAME =
'gazebo_plugins'
51 TEST_NAME = PKG_NAME +
'block_laser_clipping'
52 rospy.init_node(TEST_NAME)
53 rostest.rosrun(PKG_NAME, TEST_NAME, TestBlockLaserClippingPlugin)