竞赛#
Competition 类在比赛期间与场地控制系统一起使用。有关 Python Competition 的更多信息,请阅读在 VEXcode V5 中使用 Python Competition 模板。
初始化竞赛类#
竞争控制是使用以下构造函数创建的:
竞赛(驾驶员、自动驾驶)
此构造函数使用两个参数:
范围 |
描述 |
---|---|
|
当驱动程序控制周期开始时,作为线程调用的先前定义的函数。 |
|
当自主控制期开始时,作为线程调用的先前定义的函数。 |
# 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)
当引用 Competition 类方法时,此“competition”对象将在整个 API 文档的所有后续示例中使用。
类方法#
is_enabled()#
is_enabled()
方法检查机器人的状态是启用还是禁用。
返回: 如果比赛模式已启用,则返回 True
。如果比赛模式已禁用,则返回 False
。
is_driver_control()#
is_driver_control()
方法检查机器人的状态是否为驱动器控制。
返回: 如果机器人处于驱动控制模式,则返回 True
。如果不处于驱动控制模式,则返回 False
。
is_autonomous()#
is_autonomous()
方法检查机器人的状态是否为自主。
返回: 如果机器人处于自主模式,则返回 True
。如果不是自主模式,则返回 False
。
is_competition_switch()#
is_competition_switch()
方法检查比赛开关是否已连接。
返回: 如果比赛开关已连接,则返回 True
。如果未连接,则返回 False
。
is_field_control()#
is_field_control()
方法检查字段控件是否已连接。
返回: 如果字段控件已连接,则返回 True
。如果未连接,则返回 False
。