C++#

本指南详细介绍了如何在 VEXcode IQ(第二代)中使用 C++ 命令。您将学习如何阅读和理解每个命令,并了解其详尽的描述、参数和使用示例。

读取命令条目#

每个命令条目遵循一致的结构:

  • 命令名称 – 命令的正式名称。

  • 描述 – 对命令的作用和可能返回的内容的简要说明。

  • 定义 – 命令的语法,显示如何在代码中编写它。

  • 参数表——列出命令接受的所有输入。

  • 示例代码 – 以复制粘贴代码块形式提供的使用示例。

命令输入示例#

旋转#

rotation returns the current rotational value of a smart drivetrain as a double.

注意:此方法仅适用于配置了陀螺仪传感器或脑惯性传感器的传动系统。

Usage:
Drivetrain.rotation(units)

参数

描述

单位

Optional. The unit that represents the rotational value:

  • degrees (default)
  • turns

// Turn to the right for 400 degrees.
Drivetrain.turnFor(right, 400, degrees);
// Print the Robot's current angle of rotation.
Brain.Screen.print(Drivetrain.rotation(degrees));