wpilib functions

wpilib.getCurrentThreadPriority() int

Gets the current thread’s priority.

Priorities range from 0 to 99 where 0 is non-real-time, 1-99 are real-time, and 99 is highest priority. See “man 7 sched” for details.

Returns:

The current thread’s priority.

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 robot, this is /home/systemcore/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 robot, this is /home/systemcore/py. In simulation, it is the location of robot.py

Returns:

The result of the operating directory lookup.

wpilib.getPOVAngle(angle: wpilib._wpilib.POVDirection) wpimath._wpimath.Rotation2d | None

Gets the angle of a POVDirection.

Parameters:

angle – The POVDirection to convert.

Returns:

The angle clockwise from straight up, or std::nullopt if the POVDirection is CENTER.

wpilib.getSystemTime() 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.setCurrentThreadPriority(priority: SupportsInt | SupportsIndex) bool

Sets the current thread’s priority.

Priorities range from 0 to 99 where 0 is non-real-time, 1-99 are real-time, and 99 is highest priority. See “man 7 sched” for details.

Deprecated:

Incorrect usage of real-time priority can lead to system lockups. Only use this function if you are trained in real-time software development.

Parameters:

priority – The priority.

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.