Example #1
0
class MyPoseGen:
    
    def set_map(self, world):
        self.raytracer = TexturedRaytracer()
        self.raytracer.set_map(world)
        
    def generate_pose(self):
        pose = get_safe_pose(
                             raytracer=self.raytracer,
                             world_radius=9,
                             safe_zone=1, num_tries=100)
        #print "Found pose %s" % pose
        return pose
    
    def __eq__(self, other):
        ''' Without parameters, they will always compare true ''' 
        return isinstance(other, MyPoseGen)
Example #2
0
 def set_map(self, world):
     self.raytracer = TexturedRaytracer()
     self.raytracer.set_map(world)
        sensor_data = data.all_sensors[i]
            
        if sensor.sensor_type_string() == 'rangefinder':
            draw_rangefinder(ctx, sensor, sensor_pose, sensor_data)
        if sensor.sensor_type_string() == 'optics':
            draw_optics(ctx, sensor, sensor_pose, sensor_data)

    ctx.restore()
    
#    surface.write_to_png('world.png')
    surface.show_page()

if __name__ == '__main__':
    radius = 10
    world = create_random_world(radius)
    rt = TexturedRaytracer()
    rt.set_map(world)
    
    pose = get_safe_pose(rt, world_radius=radius, safe_zone=safe_zone)
    vehicle = Vehicle()
    
    sensor = Rangefinder()
    sensor.add_photoreceptors(linspace(-pi / 2, pi / 2, 45),
                              spatial_sigma=deg2rad(1), sigma=0)
    vehicle.add_sensor(sensor)
    
    sensor = Optics()
    sensor.add_photoreceptors(linspace(-pi / 2, pi / 2, 180),
                              spatial_sigma=deg2rad(1), sigma=0)
    vehicle.add_sensor(sensor)