def m1(): outdir = get_comptests_output_dir() gm = load_map("udem1") # dw = DuckietownWorld() # for map_name, tm in gym_maps.items(): # DW.root.set_object(map_name, tm) root = PlacedObject() world = PlacedObject() root.set_object("world", world) origin = SE2Transform([1, 10], np.deg2rad(10)) world.set_object("tile_map", gm, ground_truth=Constant[SE2Transform](origin)) # d = dw.as_json_dict() # print(json.dumps(d, indent=4)) # print(yaml.safe_dump(d, default_flow_style=False)) # G = get_meausurements_graph(root) fn = os.path.join(outdir, "out1.pdf") plot_measurement_graph(root, G, fn)
def lane_pose_test1(): outdir = get_comptests_output_dir() # load one of the maps (see the list using dt-world-draw-maps) dw = load_map("udem1") v = 5 # define a SampledSequence with timestamp, command commands_sequence = SampledSequence.from_iterator( [ # we set these velocities at 1.0 (1.0, WheelVelocityCommands(0.1 * v, 0.1 * v)), # at 2.0 we switch and so on (2.0, WheelVelocityCommands(0.1 * v, 0.4 * v)), (4.0, WheelVelocityCommands(0.1 * v, 0.4 * v)), (5.0, WheelVelocityCommands(0.1 * v, 0.2 * v)), (6.0, WheelVelocityCommands(0.1 * v, 0.1 * v)), ] ) # we upsample the sequence by 5 commands_sequence = commands_sequence.upsample(5) ## Simulate the dynamics of the vehicle # start from q0 q0 = geo.SE2_from_translation_angle([1.8, 0.7], 0) # instantiate the class that represents the dynamics dynamics = reasonable_duckiebot() # this function integrates the dynamics poses_sequence = get_robot_trajectory(dynamics, q0, commands_sequence) ################# # Visualization and rule evaluation # Creates an object 'duckiebot' ego_name = "duckiebot" db = DB18() # class that gives the appearance # convert from SE2 to SE2Transform representation transforms_sequence = poses_sequence.transform_values(SE2Transform.from_SE2) # puts the object in the world with a certain "ground_truth" constraint dw.set_object(ego_name, db, ground_truth=transforms_sequence) # Rule evaluation (do not touch) interval = SampledSequence.from_iterator(enumerate(commands_sequence.timestamps)) evaluated = evaluate_rules( poses_sequence=transforms_sequence, interval=interval, world=dw, ego_name=ego_name, ) timeseries = make_timeseries(evaluated) # Drawing area = RectangularArea((0, 0), (3, 3)) draw_static(dw, outdir, area=area, timeseries=timeseries)
def maps(): outdir = get_comptests_output_dir() map_names = list_maps() print(map_names) for map_name in map_names: duckietown_map = load_map(map_name) out = os.path.join(outdir, map_name) draw_map(out, duckietown_map)
def wb2(): root = PlacedObject() for map_name in list_maps(): tm = load_map(map_name) root.set_object(map_name, tm) d = root.as_json_dict() # print(json.dumps(d, indent=4)) # print(yaml.safe_dump(d, default_flow_style=False)) # print('------') r1 = Serializable.from_json_dict(d) d1 = r1.as_json_dict()
def lane_pose_test1(): outdir = get_comptests_output_dir() dm = load_map('udem1') print(get_object_tree(dm, attributes=True)) res = get_skeleton_graph(dm) # area = RectangularArea((0, 0), (3, 3)) draw_static(res.root2, outdir + '/root2') # draw_static(dm, outdir + '/orig') print(get_object_tree(res.root2, attributes=True))
def lane_pose_segment1(): outdir = get_comptests_output_dir() dm = load_map("udem1") _ = get_object_tree(dm, attributes=True) res = get_skeleton_graph(dm) # area = RectangularArea((0, 0), (3, 3)) draw_static(res.root2, outdir + "/root2") # draw_static(dm, outdir + '/orig') _ = get_object_tree(res.root2, attributes=True)
def __init__(self, env_config, eval_lenght_sec=15, eval_map=DEFAULT_EVALUATION_MAP): _env_config = copy.deepcopy(env_config) # An official evaluation episode is 15 seconds long _env_config['episode_max_steps'] = eval_lenght_sec * _env_config[ 'simulation_framerate'] # Agets should be evaluated on the official eval map _env_config['training_map'] = eval_map self.map_name = _env_config['training_map'] # Make testing env self.env = launch_and_wrap_env(_env_config) # Set up evaluator # Creates an object 'duckiebot' self.ego_name = 'duckiebot' self.db = DB18() # class that gives the appearance # load one of the maps self.dw = load_map(self.map_name)
def check_car_dynamics_correct(klass, CarCommands, CarParams): """ :param klass: the implementation :return: """ # load one of the maps (see the list using dt-world-draw-maps) outdir = get_comptests_output_dir() dw = load_map('udem1') v = 5 # define a SampledSequence with timestamp, command commands_sequence = SampledSequence.from_iterator([ # we set these velocities at 1.0 (1.0, CarCommands(0.1 * v, 0.1 * v)), # at 2.0 we switch and so on (2.0, CarCommands(0.1 * v, 0.4 * v)), (4.0, CarCommands(0.1 * v, 0.4 * v)), (5.0, CarCommands(0.1 * v, 0.2 * v)), (6.0, CarCommands(0.1 * v, 0.1 * v)), ]) # we upsample the sequence by 5 commands_sequence = commands_sequence.upsample(5) ## Simulate the dynamics of the vehicle # start from q0 and v0 q0 = geo.SE2_from_translation_angle([1.8, 0.7], 0) v0 = geo.se2.zero() c0 = q0, v0 # instantiate the class that represents the dynamics dynamics = CarParams(10.0) # this function integrates the dynamics poses_sequence = get_robot_trajectory(dynamics, q0, commands_sequence) ################# # Visualization and rule evaluation # Creates an object 'duckiebot' ego_name = 'duckiebot' db = DB18() # class that gives the appearance # convert from SE2 to SE2Transform representation transforms_sequence = poses_sequence.transform_values( SE2Transform.from_SE2) # puts the object in the world with a certain "ground_truth" constraint dw.set_object(ego_name, db, ground_truth=transforms_sequence) # Rule evaluation (do not touch) interval = SampledSequence.from_iterator( enumerate(commands_sequence.timestamps)) evaluated = evaluate_rules(poses_sequence=transforms_sequence, interval=interval, world=dw, ego_name=ego_name) timeseries = make_timeseries(evaluated) # Drawing area = RectangularArea((0, 0), (3, 3)) draw_static(dw, outdir, area=area, timeseries=timeseries) expected = { 1.0: geo.SE2_from_translation_angle([1.8, 0.7], 0.0), 1.6: geo.SE2_from_translation_angle([2.09998657, 0.70245831], 0.016389074695313716), 2.0: geo.SE2_from_translation_angle([2.29993783, 0.70682836], 0.027315124492189525), 2.4: geo.SE2_from_translation_angle([2.49991893, 0.70792121], -0.016385672773040847), 2.8: geo.SE2_from_translation_angle([2.69975684, 0.70027647], -0.060086470038271216), 3.2: geo.SE2_from_translation_angle([2.89906999, 0.68390873], -0.10378726730350164), 3.6: geo.SE2_from_translation_angle([3.09747779, 0.65884924], -0.14748806456873198), 4.0: geo.SE2_from_translation_angle([3.2946014, 0.62514586], -0.19118886183396236), 4.6: geo.SE2_from_translation_angle([3.58705642, 0.55852875], -0.25674005773180786), 5.0: geo.SE2_from_translation_angle([3.77932992, 0.50353298], -0.3004408549970382), 6.0: geo.SE2_from_translation_angle([4.2622088, 0.37429798], -0.22257046876429318), } for t, expected_pose in expected.items(): assert np.allclose(poses_sequence.at(t=t), expected_pose), t print('All tests passed successfully!')