Putting everything together, to assign the value of a channel, say, channel 2, to motor 4, you would write As in the case of motors, the constants act as accessors for the array, so to access the value of Joystick 2 Button 6 Up, you would write vexRT. So the equivalent of button 6 up on the operator joystick would be Btn6UXmtr2. Furthermore, you add Xmtr2 to access the equivalent inputs from joystick 2 (operator joystick).
So to access the Up button in button set 6, you would write Btn6U. "Direction" is Up (U), Down (D), Left(L), or Right(R). The array is called vexRT and the constants corresponding to the input sources are Ch1 - Ch4 and Btn6 ( direction) - Btn8 (direction). Both input types are accessed in the program in a similar fashion to motors: an array holds all possible input values on both joysticks.
In ROBOTC, the buttons and analog sticks on the VEXnet joystick are interpreted as 2 different types: Channels, which correspond to the analog sticks and buttons, which correspond to the various push buttons on the joystick.
Robotc commands driver#
In driver control, motor power levels are determined by the joystick output. The value assigned to a motor does not have to be a number it can also be a variable. So if you wanted to set the power level of the motor in port 4 to 127, you would write, motor = 127. Important to note is that motor port numbers are not accessed as they would be in a regular array instead, ROBOTC has predefined constants corresponding to each motor port. To change the power level of a particular motor, use this syntax: motor = your power level. Power levels for motors can range from -127 to 127. The value assigned to any given motor port is constantly read and output by the program to the actual motor hardware. In ROBOTC, the value of power outputs to every motor is stored inside an array called motor.
The goal of any robot program is to get the robot to do something, most often move a motor. Driver control runs on a loop until the robot is powered off and accepts commands from the driver and operator via joystick. The logic behind these instructions can vary from a simple linear set of commands to complex branching decision logic.
Robotc commands series#
Autonomous runs once, executing a series of commands allowing the robot t follow a preset list of instructions. Pre-autonomous runs once before startup and is used to configure user variables for instance, if you have a global variable and you want to decide its value at the very beginning you should do so in pre-autonomous. Commands to the robot go inside these functions. VirtualVEX has these tasks predefined in the program template (as of Alpha 4, only driver control is available). ROBOTC programs are generally split into 3 functions or tasks: pre-autonomous, autonomous, and driver control. This is not an appropriate resource for those wishing to adopt ROBOTC full-time for their physical VEX robot the best guide to learning ROBOTC can be found at the official website ( Furthermore, since ROBOTC is based off the C programming language, a rudimentary knowledge of C is required. This is intended for teams that do not program in ROBOTC (since some teams use Eas圜) but still want to customize the drive controls of the virtual robot.
This section covers some basic concepts of the ROBOTC API.