控制器#

介绍#

VEX AIR 无人机控制器采用 12 个按钮布局和两个操纵杆。这些输入使无人机能够检测按钮按下和操纵杆移动,从而实现交互式和灵敏的控制。

以下是所有可用块的列表:

controller button pressed#

The controller button pressed Boolean block reports if a specific controller button is being pressed.

  • True — The specified button is being pressed.

  • False — The specified button is not being pressed.

控制器按钮按下布尔块。#
<遥控器按键 [5 v] 按下了?>

VEX AIR 无人机控制器,图中显示了按钮 5 至 12。按钮 5 和 6 位于控制器右侧背面,与操纵杆垂直。按钮 7 和 8 位于左侧相同位置。按钮 9 至 12 位于控制器底部,其中按钮 9 位于右上角(按钮 10 上方),按钮 11 位于左上角(按钮 12 上方)。

参数

描述

按钮

检查是否被按下的按钮,范围从5到12。

例子

当开始
[Take a picture when button 5 is pressed.]
起飞至 [500] [毫米 v] ▶
永久循环
使用遥控器移动
如果 <遥控器按键 [5 v] 按下了?> 那么
在 [向前 v] 相机上捕捉图像
结束
结束

控制器轴位置#

The controller axis position reporter block reports the position of the specified joystick axis. This reports an integer from –100 to 100.

控制器轴位置报告块。#
(控制器轴 [1 v] 位置)

图中高亮显示了VEX AIR无人机控制器的操纵杆轴。轴1和轴2位于左侧操纵杆附近,轴3和轴4位于右侧操纵杆附近。

参数

描述

报告位置的轴:

  • 1 — 左摇杆垂直轴。2
  • — 左
      水平轴。4
    • — 右摇杆水平轴。6
    • — 右摇杆垂直轴。8

例子

当开始
[Climb when the left joystick is moved up.]
起飞至 [500] [毫米 v] ▶
永久循环
如果 <(控制器轴 [1 v] 位置) [math_greater_than v] [0]> 那么
爬升 [向上 v]
否则
徘徊
结束

controller is connected#

The controller is connected Boolean block reports if the controller is connected to the drone.

  • True — The controller is connected.

  • False — The controller is not connected.

控制器轴位置报告块。#
<控制器是否连接到无人机?>

参数

描述

该块没有参数。

例子

当开始
[Print controller connection status on screen.]
永久循环
如果 <控制器是否连接到无人机?> 那么
清屏
在屏幕上设定光标至 (1) 行 (1) 列
在屏幕上打印 [Controller connected]▶
等待 (0.5) 秒
结束
结束

控制器电池电量#

The controller battery level reporter block reports the battery level of the controller, as a percentage from 0% to 100%.

控制器轴位置报告块。#
(控制器电池电量百分比)

参数

描述

该块没有参数。

例子

当开始
[Show controller's battery level.]
如果 <(控制器电池电量百分比) [math_greater_than v] [50]> 那么
在屏幕上打印 [Battery level ok]▶
否则
在屏幕上打印 [Battery level low]▶

当控制器按钮#

The when controller button hat block runs the attached stack of blocks when the button is being pressed or released.

当控制器按钮帽子块。#
当遥控器按键 [5 v] [pressed v]

VEX AIR 无人机控制器,图中显示了按钮 5 至 12。按钮 5 和 6 位于控制器右侧背面,与操纵杆垂直。按钮 7 和 8 位于左侧相同位置。按钮 9 至 12 位于控制器底部,其中按钮 9 位于右上角(按钮 10 上方),按钮 11 位于左上角(按钮 12 上方)。

参数

描述

按钮

Determines which button will trigger the event, ranging from 5 to 12.

action

Determines when the attached stack of blocks will execute: pressed will run when a button is pressed, and released will run when a button is released.

例子

当开始
起飞至 [500] [毫米 v] ▶
永久循环
使用遥控器移动
结束

当遥控器按键 [5 v] [pressed v]
[Take a picture when button 5 is pressed.]
在 [向前 v] 相机上捕捉图像

当控制器轴改变时#

The when controller axis is changed hat block runs the attached stack of blocks when the specified axis is being changed.

当控制器轴改变时帽子块。#
当遥控器 [1 v] 轴改变

图中高亮显示了VEX AIR无人机控制器的操纵杆轴。轴1和轴2位于左侧操纵杆附近,轴3和轴4位于右侧操纵杆附近。

参数

描述

The axis to monitor for changes:

  • 1 — The left joystick vertical axis.
  • 2 — The left joystick horizontal axis.
  • 3 — The right joystick horizontal axis.
  • 4 — The right joystick vertical axis.

例子

当开始
[Move forward when the left joystick moves.]
起飞至 [500] [毫米 v] ▶

当遥控器 [1 v] 轴改变
将 [向前 v] 移至 (200) [毫米 v] ▶