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) vehicle.set_map(world) data = vehicle.compute_observations(pose) simple_drawing(world, vehicle, pose, data)
def vehicles_list_A(): """ Returns a list of vehicles to compare. Returns a list of tuples (name, vehicle) """ vlist = [] # XXX something smells here in deg2rad(25) kin = OmnidirectionalKinematics(\ max_linear_velocity=0.5, max_angular_velocity=deg2rad(25)) vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_uniform_sensor(Optics(), fov_deg=360, num_rays=180, spatial_sigma_deg=2, sigma=0.01) vehicle.add_sensor(sensor) vlist.append(('v_optic_unif', vehicle)) vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_example_nonuniform(Optics()) vehicle.add_sensor(sensor) vlist.append(('v_optic_nonunif', vehicle)) vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_uniform_sensor(Rangefinder(), fov_deg=360, num_rays=180, spatial_sigma_deg=2, sigma=0.01) vehicle.add_sensor(sensor) vlist.append(('v_rangefinder_unif', vehicle)) vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_uniform_sensor(Nearnessfinder(), fov_deg=360, num_rays=180, spatial_sigma_deg=2, sigma=0.01) vehicle.add_sensor(sensor) vlist.append(('v_nearness_unif', vehicle)) vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_example_nonuniform(Rangefinder()) vehicle.add_sensor(sensor) vlist.append(('v_rangefinder_nonunif', vehicle)) mountpoints = [ ('center', RigidBodyState([0, 0], 0)), ('left30', RigidBodyState([0, 0.30], 0)), ('front30', RigidBodyState([0.30, 0], 0)), ('rot45', RigidBodyState([0, 0], deg2rad(45)))] for name, mountpoint in mountpoints: vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_uniform_sensor(Rangefinder(), fov_deg=180, num_rays=180, spatial_sigma_deg=0.1, sigma=0.01) vehicle.add_sensor(sensor, mountpoint) vname = 'v_rangefinder180_%s' % name vlist.append((vname, vehicle)) olfaction_radius = 0.5 vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_ring_olfaction_sensor(fov_deg=180, num_sensors=40, radius=olfaction_radius) vehicle.add_sensor(sensor) vlist.append(('v_olfaction180o', vehicle)) vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_ring_olfaction_sensor(fov_deg=180, num_sensors=40, radius=olfaction_radius) sensor.normalize_mean = True sensor.normalize_sum = True vehicle.add_sensor(sensor) vlist.append(('v_olfaction180n', vehicle)) vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_ring_olfaction_sensor(fov_deg=360, num_sensors=40, radius=olfaction_radius) vehicle.add_sensor(sensor) vlist.append(('v_olfaction360o', vehicle)) vehicle = Vehicle() vehicle.set_dynamics(kin) sensor = create_ring_olfaction_sensor(fov_deg=360, num_sensors=40, radius=olfaction_radius) sensor.normalize_mean = True sensor.normalize_sum = True vehicle.add_sensor(sensor) vlist.append(('v_olfaction360n', vehicle)) vehicle = Vehicle() vehicle.set_dynamics(kin) vehicle.add_sensor(PolarizedLightSensor(45)) vlist.append(('v_polarized', vehicle)) return vlist