RacingInterface
In addition to the methods and attributes described in the overview, this object provides the method below.
Methods
| Name | Description |
|---|---|
RacingInterface.set_controls(throttle=None, brake=None, steering=None) |
Sets the controls you name, at once. A control you leave out, or pass as None, keeps the value it had. Each one you give must be a finite real number: anything else raises before anything is sent, a TypeError for what is not a number and a ValueError for NaN or infinity. The engine holds each to its own range, throttle and brake from 0 to 1 and steering from -1 to 1. Every control starts at 0. |
Sending a move
set_controls is the only way to work the controls, and it sends as soon as it is called:
RacingInterface.set_controls(throttle=0.5, steering=0.2)
RacingInterface.set_controls(0.5, 0.0, 0.2) # throttle, brake, steering
RacingInterface.set_controls(brake=1.0) # throttle and steering stay as they were
The engine keeps every control as the last value you sent for it. So calls add up: when the tick comes round, each control is the last value any call gave it, and one you never named in an update stays where it was. Calling it with nothing to set sends nothing, and not calling it at all leaves the car on the controls it already had. A non-numeric control value raises a TypeError.
Control ranges
| Input | Range | Meaning |
|---|---|---|
steering |
-1 to 1 | Positive steers right, negative steers left. This is a steering angle request, not a heading - holding it constant turns the kart continuously. |
throttle |
0 to 1 | Fraction of available drive force. |
brake |
0 to 1 | Fraction of available braking force. Braking and throttling at once wastes both. |