C++#

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

Reading a Command Entry#

Each command entry follows a consistent structure:

  • Command Name – The official name of the command.

  • Description – A brief explanation of what the command does and what it may return.

  • Definition – The syntax of the command, showing how it should be written in code.

  • Parameter Table – Lists all inputs the command accepts.

  • Example Code – A usage example provided as a copy-and-paste code block.

命令输入示例#

rotation#

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

Note: This method will only work with a drivetrain that has been configured with a Gyro Sensor or Brain Inertial Sensor.

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));