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.getErrorMessage() Tuple[str, int]

Gets error message string for an error code.

wpilib.getTime() 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]

This function gets called in robot.py like so:

if __name__ == '__main__':
    wpilib.run(MyRobot)

This function loads available entry points, parses arguments, and sets things up specific to RobotPy so that the robot can run. This function is used whether the code is running on the roboRIO or a simulation.

Parameters
  • robot_class – A class that inherits from RobotBase

  • kwargs – Keyword arguments that will be passed to the executed entry points

Returns

This function should never return

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: 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.