竞赛#
初始化竞赛类#
竞争控制是使用以下构造函数创建的:
Competition(driver, autonomous)
此构造函数使用两个参数:
范围 |
描述 |
---|---|
|
当驱动程序控制周期开始时,作为线程调用的先前定义的函数。 |
|
当自主控制期开始时,作为线程调用的先前定义的函数。 |
# Define a function "driver".
def driver()
brain.screen.print("Driver called")
# Define a function "autonomous".
def autonomous()
brain.screen.print("Autonomous called")
# Construct a Competition Control object "competition"
# with the Competition class.
competition = Competition(driver, autonomous)
This competition
object will be used in all subsequent examples throughout this API documentation when referring to Competition class methods.
类方法#
is_enabled()#
The is_enabled()
method checks if the state of the robot is enabled or disabled.
Returns: True
if the competition mode is enabled. False
if it is disabled.
is_driver_control()#
The is_driver_control()
method checks if the state of the robot is driver control.
Returns: True
if the robot is in driver control mode. False
if it is not in driver control mode.
is_autonomous()#
The is_autonomous()
method checks if the state of the robot is autonomous.
Returns: True
if the robot is in autonomous mode. False
if it is not in autonomous.
is_competition_switch()#
The is_competition_switch()
method checks if the competition switch is connected.
Returns: True
if the competition switch is connected. False
if it is not connected.
is_field_control()#
The is_field_control()
method checks if the field control is connected.
Returns: True
if the field control is connected. False
if it is not connected.