Beispiel #1
0
    def run(self):
        self.ego.on_collision(self.on_collision)
        self.npc1.on_collision(self.on_collision)
        self.npc2.on_collision(self.on_collision)

        try:
            t0 = time.time()
            self.sim.run(TIME_DELAY)
            # self.npc1.follow(self.npc1Waypoints)
            self.npc2.follow(self.npc2Waypoints)

            distance = None
            ttc = None

            while True:
                distance, ttc = self.ttc(distance, ttc)

                egoCurrentState = self.ego.state
                if egoCurrentState.speed > MAX_SPEED + SPEED_VARIANCE:
                    raise evaluator.TestException(
                        "EGO speed exceeded limit, {} > {} m/s".format(
                            egoCurrentState.speed, MAX_SPEED + SPEED_VARIANCE))

                NPC1CurrentState = self.npc1.state
                if NPC1CurrentState.speed > MAX_SPEED + SPEED_VARIANCE:
                    raise evaluator.TestException(
                        "NPC1 speed exceeded limit, {} > {} m/s".format(
                            NPC1CurrentState.speed,
                            MAX_SPEED + SPEED_VARIANCE))

                NPC2CurrentState = self.npc2.state
                if NPC2CurrentState.speed > MAX_SPEED + SPEED_VARIANCE:
                    raise evaluator.TestException(
                        "NPC2 speed exceeded limit, {} > {} m/s".format(
                            NPC2CurrentState.speed,
                            MAX_SPEED + SPEED_VARIANCE))

                self.sim.run(0.5)

                if time.time() - t0 > TIME_LIMIT:
                    break

        except evaluator.TestException as e:
            print("FAILED: " + repr(e))
            exit()

        print("Program Terminated")
def on_collision(agent1, agent2, contact):
    raise evaluator.TestException("Ego collided with {}".format(agent2))
ego.on_collision(on_collision)
POV.on_collision(on_collision)

try:
    t0 = time.time()
    sim.run(TIME_DELAY)  # The EGO should start moving first
    POV.follow_closest_lane(True, MAX_POV_SPEED, False)

    while True:
        sim.run(0.5)

        egoCurrentState = ego.state
        if egoCurrentState.speed > MAX_EGO_SPEED + SPEED_VARIANCE:
            raise evaluator.TestException(
                "Ego speed exceeded limit, {} > {} m/s".format(
                    egoCurrentState.speed, MAX_EGO_SPEED + SPEED_VARIANCE))

        POVCurrentState = POV.state
        if POVCurrentState.speed > MAX_POV_SPEED + SPEED_VARIANCE:
            raise evaluator.TestException(
                "POV speed exceeded limit, {} > {} m/s".format(
                    POVCurrentState.speed, MAX_POV_SPEED + SPEED_VARIANCE))
        if POVCurrentState.angular_velocity.y > MAX_POV_ROTATION:
            raise evaluator.TestException(
                "POV angular rotation exceeded limit, {} > {} deg/s".format(
                    POVCurrentState.angular_velocity, MAX_POV_ROTATION))

        if time.time() - t0 > TIME_LIMIT:
            break
except evaluator.TestException as e:
    raise evaluator.TestException("Ego collided with {}".format(agent2))


ego.on_collision(on_collision)
POV.on_collision(on_collision)

try:
    t0 = time.time()
    sim.run(TIME_DELAY)
    POV.follow(POVWaypoints)

    while True:
        egoCurrentState = ego.state
        if egoCurrentState.speed > MAX_EGO_SPEED + SPEED_VARIANCE:
            raise evaluator.TestException(
                "Ego speed exceeded limit, {} > {} m/s".format(
                    egoCurrentState.speed, MAX_EGO_SPEED + SPEED_VARIANCE))

        POVCurrentState = POV.state
        if POVCurrentState.speed > MAX_EGO_SPEED + SPEED_VARIANCE:
            raise evaluator.TestException(
                "POV1 speed exceeded limit, {} > {} m/s".format(
                    POVCurrentState.speed, MAX_POV_SPEED + SPEED_VARIANCE))

        sim.run(0.5)

        if time.time() - t0 > TIME_LIMIT:
            break
except evaluator.TestException as e:
    print("FAILED: " + repr(e))
    exit()
Beispiel #5
0
 def on_collision(self, agent1, agent2, contact):
     raise evaluator.TestException("Colision between {} and {}".format(
         agent1, agent2))
POV3.follow_closest_lane(True, MAX_SPEED, False)

def on_collision(agent1, agent2, contact):
    raise evaluator.TestException("{} collided with {}".format(agent1, agent2))

ego.on_collision(on_collision)
POV1.on_collision(on_collision)
POV2.on_collision(on_collision)
POV3.on_collision(on_collision)

try:
    t0 = time.time()
    while True:
        egoCurrentState = ego.state
        if egoCurrentState.speed > MAX_SPEED + SPEED_VARIANCE:
            raise evaluator.TestException("Ego speed exceeded limit, {} > {} m/s".format(egoCurrentState.speed, MAX_SPEED + SPEED_VARIANCE))

        POV1CurrentState = POV1.state
        POV2CurrentState = POV2.state
        POV3CurrentState = POV3.state
        POVSeparation = evaluator.separation(POV1CurrentState.position, POV2CurrentState.position)
        if POVSeparation > MAX_POV_SEPARATION + SEPARATION_VARIANCE:
            raise evaluator.TestException("POV1 and POV2 are too far apart: {} > {}".format(POVSeparation, MAX_POV_SEPARATION + SEPARATION_VARIANCE))

        if POV1CurrentState.speed > MAX_SPEED + SPEED_VARIANCE:
            raise evaluator.TestException("POV1 speed exceeded limit, {} > {} m/s".format(POV1CurrentState.speed, MAX_SPEED + SPEED_VARIANCE))
        
        if POV2CurrentState.speed > MAX_SPEED + SPEED_VARIANCE:
            raise evaluator.TestException("POV2 speed exceeded limit, {} > {} m/s".format(POV2CurrentState.speed, MAX_SPEED + SPEED_VARIANCE))

        if POV3CurrentState.speed > MAX_SPEED + SPEED_VARIANCE: