-
Notifications
You must be signed in to change notification settings - Fork 4
Utils
Returns x but capped between low and high.
-
x- A number. -
low- A number. -
high- A number.
Caps target so the bot won't drive through walls when going to it.
-
agent- An instance of VirxERLU. If you're running this from an instance of VirxERLU, pass inself. -
target- AVector.
Using the given parameters, this method makes the bot drive towards local_target with a speed of target_speed.
This util understands going backwards (negative target speed) as well as how to use handbrake.
This is the recommended util for driving to a target.
Returns the target angles and the car's forward velocity.
-
agent- An instance of VirxERLU. If you're running this from an instance of VirxERLU, pass inself. -
local_target- The local location of the target to face. Seelocal_locationundercar_objectinutil/agent.py. -
target_speed- A number between -1410 and 2300.
Alters the agent's controller to face a given target. Works for backwards and forwards driving.
-
agent- An instance of VirxERLU. If you're running this from an instance of VirxERLU, pass inself. -
local_target- The local location of the target to face. Seelocal_locationundercar_objectinutil/agent.py. -
upside_down- IfTrue, then this will have the top of the car face the ground. Only works when airborne. -
up- Which direction to face via rolling. Only works when airborne. Defaults to actually facing upwards.
Alters the agent's controller to accelerate to a given speed using throttle and boost.
-
agent- An instance of VirxERLU. If you're running this from an instance of VirxERLU, pass inself. -
target_speed- A number between -1410 and 2300.
Returns the velocity of the car from the car's turning curvature.
-
curve- A number that represents the turning curvature of the car.
Example:
turn_rad = turn_radius(abs(agent.me.local_velocity().x))
velocity_from_turn_rad = curvature_to_velocity(1 / turn_rad)Returns the acceleration that the throttle can give when set to 1 when the car is traveling at car_velocity_x speed.
-
car_velocity_x- A number that represents the forward velocity of the car.
Returns whether or not the car needs to use handbrake to reach local_target.
-
turn_rad- The turning radius of the car. Seeturn_radiusinutil/util.py -
local_target- The local location of the target to face. Seelocal_locationundercar_objectinutil/agent.py. -
steer_direction- Either -1 or 1 that represents the direction that the car wants to turn in. -1 for left, 1 for right.
Returns the turning radius of the car.
-
v- A number that represents the forward velocity of the car.
Returns the curvature of the turning radius of the car.
-
v- A number that represents the forward velocity of the car.
Returns whether or not point with a radius of radius is in the field or not.
-
point- AVector. -
radius- A number.
Returns the slope of the bot's position relative to the shot vector.
10 = The bot is on the axis and the ball is between you and the direction to shoot in.
-10 = The bot is on the wrong side.
1 = The bot is about 45 degrees offcenter.
-
shot_vector- AVector. -
car_to_target- AVectorthat is the target's location minus the bot's location.
Returns the 2 roots of a quadratic.
-
a- A number. -
b- A number. -
c- A number.
Returns whether or not the ball is still where the shot anticipates it to be.
-
agent- An instance of VirxERLU. If you're running this from an instance of VirxERLU, pass inself. -
shot- An instance of a shot routine. Seeutil/routines.py. -
target- AVector. If undefined, it will default toshot.ball_location.
Returns 1 for orange team and -1 for blue team
-
x- A team. If you're running this from an instance of VirxERLU, pass inself.team(for current team) ornot self.team(for the enemy team).
Returns the sign of x - either -1, 0, or 1. Python doesn't have built-in method to do this like it should, so it's here instead.
-
x- A number.
A Proportional-Derivative control loop used for defaultPD.
-
angle- Angle in radians. -
rate- A number.
Returns the linear interpolation from a to b using t.
For instance, when t == 0, a is returned, and when t is 1, b is returned, and when t is 0.5, the midpoint from a to b it returned.
Returns the inverse linear interpolation from a to b with value v.
For instance, it returns 0 if v is a, and returns 1 if v is b, and returns 0.5 if v is exactly between a and b
Sends the object msg to the match communication server after attaching the bot's index and team.
-
agent- An instance of VirxERLU. If you're running this from an instance of VirxERLU, pass inself. -
msg- A Python object.
Returns the next value in a generator. If there isn't another value, it will return None.
-
generator- A Python generator.
Returns if x is equals to y within the range of threshold.
-
x- Some value that supports basic math. -
y- Some value that supports basic math. -
threshold- Some value that supports basic math.
Return whether or not a 2d point is inside a 2d quadrilateral
-
point- AVector. Thezcoordinate will be ignored. -
quadrilateral- A tuple of 4Vectors, in either a clockwise or counter-clockwise order. Thezcoordinate on each will be ignored.
Returns the approximate perimeter of an ellipse.
-
a- A number representing 1 of the 2 radii of the ellipse. -
b- A number representing the other radius of the ellipse.
Returns the maximum speed gain from a flip or wave dash.
-
agent- An instance of VirxERLU. If you're running this from an instance of VirxERLU, pass inself.
Returns whether or not a ray intersects with a line.
-
origin- The origin of the ray on the field, represented by aVector. -
direction- The direction of the ray, represented by aVector. -
point1- The first point of the line, represented by aVector. -
point2- The second point of the line, represented by aVector.
Returns whether or not a ray intersects with a circle.
-
origin- AVectorrepresenting the origin of the ray on the field. -
direction- AVectorrepresenting the direction of the ray. -
center- AVectorrepresenting the center of the circle on the field. -
radius- A number representing the radius of the circle.
Returns the smallest non-negative value.
-
x- A number. -
y- A number.
Plugs a, h, k and y into a quadratic's vertex form (y = a(x - h)^2 + k) and return the lowest non-negative value of x.
-
a- A number. -
h- A number. -
k- A number. -
y- A number.
get_landing_time(fall_distance, falling_time_until_terminal_velocity, falling_distance_until_terminal_velocity, terminal_velocity, k, h, g)
Returns the time that the object will land on some plane when accounting for gravity and terminal velocity.
-
fall_distance- A number. The distance to some plane. -
falling_time_until_terminal_velocity- A number. The time until the object reaches terminal velocity. -
falling_distance_until_terminal_velocity- A number. The distance until the object reaches terminal velocity. -
terminal_velocity- A number. The terminal velocity of the object. -
k- A number. Thekvalue in a quadratic's vertex form (y = a(x - h)^2 + k). -
h- A number. Thehvalue in a quadratic's vertex form (y = a(x - h)^2 + k). -
g- A number. The current world gravity in the z axis.
Find the plane (side wall, back wall, ceiling, or floor) that the car will collide with first
-
l- AVectorwhich represents the location of the car. -
v- AVectorwhich represents the velocity of the car. -
g- A number that represents the z value of the world gravity. SeegravityunderVirxERLUinutil/agent.py.
Return a number. 0 and 1 for the side walls, 2 and 3 for the back walls, 4 for the ceiling and 5 for the floor.