def test_waypoints_sensor_with_cut_in_task(cut_in_scenarios): scenario = next(cut_in_scenarios) sim = mock.Mock() nei_vehicle = mock.Mock() nei_vehicle.speed = 10 sim.elapsed_sim_time = 4 nei_vehicle.pose = Pose( position=np.array([25, -68, 0]), orientation=[0, 0, 0, 0], heading_=Heading(0), ) sim.neighborhood_vehicles_around_vehicle = mock.MagicMock( return_value=[nei_vehicle]) vehicle = mock.Mock() vehicle.pose = Pose( position=np.array([35, -65, 0]), orientation=[0, 0, 0, 0], heading_=Heading(0), ) mission_planner = MissionPlanner(scenario.waypoints, scenario.road_network, AgentBehavior(aggressiveness=3)) mission = scenario.missions[AGENT_ID] mission_planner.plan(mission) sensor = WaypointsSensor(sim, vehicle, mission_planner) waypoints = sensor() assert len(waypoints) == 1
def test_waypoints_sensor_with_uturn_task(uturn_scenarios): scenario = next(uturn_scenarios) sim = mock.Mock() vehicle = mock.Mock() sim.elapsed_sim_time = 1 sim.timestep_sec = 0.1 nei_vehicle = mock.Mock() nei_vehicle.pose = Pose( position=np.array([93, -59, 0]), orientation=[0, 0, 0, 0], heading_=Heading(0), ) nei_vehicle.speed = 13.8 sim.neighborhood_vehicles_around_vehicle = mock.MagicMock( return_value=[nei_vehicle]) vehicle.pose = Pose( position=np.array([25, -61, 0]), orientation=[0, 0, 0, 0], heading_=Heading(0), ) mission_planner = MissionPlanner(scenario.waypoints, scenario.road_network, AgentBehavior(aggressiveness=3)) mission = scenario.missions[AGENT_ID] mission_planner.plan(mission) mission_planner._task_is_triggered = True sensor = WaypointsSensor(sim, vehicle, mission_planner) waypoints = sensor() assert len(waypoints) == 1
def test_waypoints_sensor(scenarios): scenario = next(scenarios) sim = mock.Mock() vehicle = mock.Mock() vehicle.pose = Pose( position=np.array([33, -65, 0]), orientation=np.array([0, 0, 0, 0]), heading_=Heading(0), ) mission = scenario.missions[AGENT_ID] plan = Plan(scenario.road_map, mission) sensor = WaypointsSensor(vehicle, plan) waypoints = sensor() assert len(waypoints) == 3
def test_waypoints_sensor(scenarios): scenario = next(scenarios) sim = mock.Mock() vehicle = mock.Mock() vehicle.pose = Pose( position=np.array([33, -65, 0]), orientation=[0, 0, 0, 0], heading_=Heading(0), ) mission_planner = MissionPlanner(scenario.waypoints, scenario.road_network) mission = scenario.missions[AGENT_ID] mission_planner.plan(mission) sensor = WaypointsSensor(sim, vehicle, mission_planner) waypoints = sensor() assert len(waypoints) == 3