C++#
This guide provides detailed information on how to use the C++ commands in VEXcode EXP. Here, you will learn how to read and understand each command, with comprehensive descriptions, parameters, and usage examples.
Enabling the VEX Namespace#
In C++, classes from the VEX library are accessed using the vex::
namespace prefix, such as vex::color
. However, you can simplify your code by enabling the entire VEX namespace at the beginning of your file. To do this, add the statement using namespace vex;
at the top of your project. Once enabled, you can directly use VEX classes without the vex::
prefix, allowing you to write color instead of vex::color
.
Understanding the Command Entries#
Each command entry in the API Reference includes the following components:
Command Name and Signature: This is the name of the command and its parameters.
Description: A brief explanation of what the command does.
Blocking/Non-Blocking: Indicates whether the command waits for completion before moving to the next command.
Parameters Table: Lists and describes the parameters that the command accepts.
Returns: Describes what the command returns, if applicable.
Example: Provides a sample code snippet demonstrating how to use the command.
Example Command Entry#
Drivetrain.setRotation()#
The Drivetrain.setRotation()
command sets the rotation for the Drivetrain.
Parameters |
Description |
---|---|
value |
The new value to use for rotation. |
units |
Optional. A valid RotationUnit. The default is |
Returns: None.
// Set the value of rotation to 180 degrees.
Drivetrain.setRotation(180);
- Enums
- accelerometer
- aivision
- analog_in
- arm
- brain
- bumper
- color
- competition
- controller
- digital_in
- digital_out
- distance
- drivetrain
- electromagnet
- encoder
- event
- gyro
- inertial
- led
- light
- limit
- line
- message_link
- motor
- motor29
- motor_group
- motor_victor
- objectdetector
- optical
- pneumatic
- pot
- potV2
- pwm_out
- rotation
- serial_link
- servo
- signaltower
- smartdrive
- sonar
- thread
- triport
- vision