wpilib functions
- wpilib.getCurrentThreadPriority() tuple[int, bool]
Get the thread priority for the current thread.
- Parameters:
isRealTime – Set to true if thread is real-time, otherwise false.
- Returns:
The current thread priority. For real-time, this is 1-99 with 99 being highest. For non-real-time, this is 0. See “man 7 sched” for details.
- wpilib.getDeployDirectory() str
Obtains the deploy directory of the program, which is the remote location the deploy directory is deployed to by default. On the roboRIO, this is /home/lvuser/py/deploy. In simulation, it is where the simulation was launched from, in the subdirectory “deploy” (dirname(robot.py)/deploy).
- Returns:
The result of the operating directory lookup
- wpilib.getErrorMessage() tuple[str, int]
Gets error message string for an error code.
- wpilib.getOperatingDirectory() str
Obtains the operating directory of the program. On the roboRIO, this is /home/lvuser/py. In simulation, it is the location of robot.py
- Returns:
The result of the operating directory lookup.
- wpilib.getTime() wpimath.units.seconds
Gives real-time clock system time with nanosecond resolution
- Returns:
The time, just in case you want the robot to start autonomous at 8pm on Saturday.
- wpilib.reportError(error: str, printTrace: bool = False) None [source]
Report error to Driver Station, and also prints error to
sys.stderr
. Optionally appends stack trace to error message.- Parameters:
error – message to show
printTrace – If True, appends stack trace to error string
- wpilib.reportWarning(error: str, printTrace: bool = False) None [source]
Report warning to Driver Station, and also prints error to
sys.stderr
. Optionally appends stack trace to error message.- Parameters:
error – message to show
printTrace – If True, appends stack trace to error string
- wpilib.run(robot_class, **kwargs)[source]
wpilib.run
is no longer used. You should run your robot code via one of the following methods instead:Windows:
py -m robotpy [arguments]
Linux/macOS:
python -m robotpy [arguments]
In a virtualenv the
robotpy
command can be used directly.
- wpilib.setCurrentThreadPriority(realTime: bool, priority: int) bool
Sets the thread priority for the current thread.
- Parameters:
realTime – Set to true to set a real-time priority, false for standard priority.
priority – Priority to set the thread to. For real-time, this is 1-99 with 99 being highest. For non-real-time, this is forced to 0. See “man 7 sched” for more details.
- Returns:
True on success.
- wpilib.wait(seconds: wpimath.units.seconds) None
Pause the task for a specified time.
Pause the execution of the program for a specified period of time given in seconds. Motors will continue to run at their last assigned values, and sensors will continue to update. Only the task containing the wait will pause until the wait time is expired.
- Parameters:
seconds – Length of time to pause, in seconds.