Esempio n. 1
0
def estimate_time(car: Car, target, dd=1) -> float:
    turning_radius = 1 / Drive.max_turning_curvature(norm(car.velocity) + 500)
    turning = angle_between(car.forward() * dd, direction(
        car, target)) * turning_radius / 1800
    if turning < 0.5: turning = 0

    dist = ground_distance(car, target) - 200
    if dist < 0: return turning
    speed = dot(car.velocity, car.forward())

    time = 0
    result = None
    if car.boost > 0 and dd > 0:
        boost_time = car.boost / 33.33
        result = BOOST.simulate_until_limit(speed,
                                            distance_limit=dist,
                                            time_limit=boost_time)
        dist -= result.distance_traveled
        time += result.time_passed
        speed = result.speed_reached

    if dist > 0 and speed < 1410:
        result = THROTTLE.simulate_until_limit(speed, distance_limit=dist)
        dist -= result.distance_traveled
        time += result.time_passed
        speed = result.speed_reached

    if result is None or not result.distance_limit_reached:
        time += dist / speed

    return time * 1.05 + turning
Esempio n. 2
0
 def determine_max_speed(self, local_target):
     low = 100
     high = 2200
     if self.kickoff:
         return high
     for i in range(5):
         mid = (low + high) / 2
         radius = (1 / RLUDrive.max_turning_curvature(mid))
         local_circle = vec3(0, copysign(radius, local_target[1]), 0)
         dist = norm(local_circle - xy(local_target))
         if dist < radius:
             high = mid
         else:
             low = mid
     return high
Esempio n. 3
0
    def align(car: Car, target: vec3, direction: vec3):

        turnAngleAmount = math.acos(dot(car.forward(), direction))
        rotateToZeroAngle = -atan2(direction)
        posOffset = rotate2(target - car.position, rotateToZeroAngle)

        towardsZeroVector = rotate2(car.forward(), rotateToZeroAngle)
        turnDirection = math.copysign(1, -towardsZeroVector[1])

        turnRadius = 1 / RLUDrive.max_turning_curvature(norm(car.velocity))

        ANGLETERM = 10
        ANGULARTERM = -0.3
        CORRECTIONTERM = 1 / 40
        angleP = turnDirection * min(2, ANGLETERM * turnAngleAmount)
        angleD = ANGULARTERM * car.angular_velocity[2]

        finalOffset = posOffset[1] + turnDirection * turnRadius / .85 * (
            1 - math.cos(turnAngleAmount))
        offsetCorrection = CORRECTIONTERM * finalOffset

        return min(1, max(-1, angleP + angleD + offsetCorrection))