Natural Language Cortex
Natural Language Cortex
Setup Functions:
Robot Type
Choose which robot you want to write a program for. Note that not including this command defaults to
"robotType(none);" Also please note that this command should be the first thing in your "task main()".
Command:
robotType(type);
Parameters: type
Valid Robot Types for type:
none - this will not set up any motors and sensors for you (this is the default.)
recbot - sets the motors and sensors to match a default Recbot.
swervebot - sets the motors and sensors to match a default Swervebot.
Movement Functions:
Set Servo
Set a servo to a desired position.
Command:
setServo(servo, position);
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 1
ROBOTC Natural Language - VEX Cortex Reference:
Start Motor
Set a motor to a speed.
Command:
startMotor(motor, speed);
Stop Motor
Stops a motor.
Command:
stopMotor(motor);
Parameters: motor
Acceptable Motors for motor:
MOTOR ports 1 through 10 (and your names for them given in Motors and Sensors Setup.)
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 2
ROBOTC Natural Language - VEX Cortex Reference:
Wait Functions:
Wait
Wait an amount of time measured in seconds. The robot continues to do what it was doing during this time.
Command:
wait(time);
Parameters: time
Valid Range Values for time:
0.0 to 3600.0 and up.
Wait in Milliseconds
Wait an amount of time in milliseconds. The robot continues to do what it was doing during this time.
Command:
waitInMilliseconds(time);
Parameters: time
Valid Range Values for time:
0 to 3600000 and up.
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 3
ROBOTC Natural Language - VEX Cortex Reference:
Robot Movement Functions:
Note that for desirable results with the following set of functions, you must use the "robotType();" Setup Function with either recbot or
swervebot in the beginning of your "task main()".
Forward
Both wheels rotate forward at the same speed, causing the robot to move forward.
Command:
forward(speed);
Parameters: speed
Valid Range Values for speed:
0 to 127 (however forward() will always move your robot forward.)
Backward
Both wheels rotate backward at the same speed, causing the robot to move backward.
Command:
backward(speed);
Parameters: speed
Valid Range Values for speed:
-127 to 0 (however backward() will always move your robot backward.)
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 4
ROBOTC Natural Language - VEX Cortex Reference:
Point Turn
Both wheels rotate at the same speed but in opposite directions, causing the robot to turn in place.
Command:
pointTurn(direction, speed);
Swing Turn
One wheel rotates while the other does not move, causing the robot to make a wide turn around the stopped wheel.
Command:
swingTurn(direction, speed);
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 5
ROBOTC Natural Language - VEX Cortex Reference:
Stop
Both wheels do not move, causing the robot to stop.
Command:
stop();
Parameters: N/A
Command:
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 6
ROBOTC Natural Language - VEX Cortex Reference:
Line Track for Rotations
The robot will track a dark line on a light surface for a specified distance in encoder rotations.
Command:
lineTrackForRotations(rotations, threshold, sensorLeft, sensorCenter, sensorRight);
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 7
ROBOTC Natural Language - VEX Cortex Reference:
Move Straight for Time
The robot will use encoders to maintain a straight course for a specified length of time in seconds.
Command:
Command:
Command:
Arcade Control
The robot will be remote controlled in such a way that the movement of the robot is mapped to a single joystick,
much like a retro arcade game.
Command:
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 9
ROBOTC Natural Language - VEX Cortex Reference:
Until Functions:
Until Touch
The robot continues what it was doing until the touch sensor is pressed in.
Command:
untilTouch(sensorPort);
Parameters: sensorPort
Acceptable Sensors for sensorPort:
DIGITAL ports 1 through 12 (and your names for them given in Motors and Sensors Setup.)
Until Release
The robot continues what it was doing until the touch sensor is released out.
Command:
untilRelease(sensorPort);
Parameters: sensorPort
Acceptable Sensors for sensorPort:
DIGITAL ports 1 through 12 (and your names for them given in Motors and Sensors Setup.)
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 10
ROBOTC Natural Language - VEX Cortex Reference:
Until Bump
The robot continues what it was doing until the touch sensor is pressed in and then released out.
(A delay time in milliseconds can be specified as well.)
Command:
untilBump(sensorPort, delayTimeMS);
Command:
untilButtonPress(lcdButton);
Parameters: lcdButton
Valid LCD Buttons for lcdButton:
centerBtnVEX - VEX LCD center button
rightBtnVEX - VEX LCD right button
leftBtnVEX - VEX LCD left button
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 11
ROBOTC Natural Language - VEX Cortex Reference:
Until Sonar Greater Than
The robot continues what it was doing until the sonar sensor reads a value greater than a set distance in centimeters.
Command:
untilSonarGreaterThan(distance, sensorPort);
Command:
untilSonarLessThan(distance, sensorPort);
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 12
ROBOTC Natural Language - VEX Cortex Reference:
Until Potentiometer Greater Than
The robot continues what it was doing until the potentiometer sensor reads a value greater than a set position.
Command:
untilPotentiometerGreaterThan(position, sensorPort);
Command:
untilPotentiometerLessThan(position, sensorPort);
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 13
ROBOTC Natural Language - VEX Cortex Reference:
Until Dark
The robot continues what it was doing until the line tracking sensor reads a value darker than a specified threshold.
Command:
untilDark(threshold, sensorPort);
Until Light
The robot continues what it was doing until the line tracking sensor reads a value lighter than a specified threshold.
Command:
untilLight(threshold, sensorPort);
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 14
ROBOTC Natural Language - VEX Cortex Reference:
Until Rotations
The robot continues what it was doing until the quadrature encoder rotations reach the desired value.
Command:
untilRotations(rotations, sensorPort);
Command:
untilEncoderCounts(counts, sensorPort);
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 15
ROBOTC Natural Language - VEX Cortex Reference:
Special Functions:
LED ON
Turn an LED in a specified digital-port ON.
Command:
turnLEDOn(sensorPort);
Parameters: sensorPort
Acceptable Sensors for sensorPort:
DIGITAL ports 1 through 12 (and your names for them given in Motors and Sensors Setup.)
Note that you must set these digital-ports to "VEX LED".
LED OFF
Turn an LED in a specified digital-port OFF.
Command:
turnLEDOff(sensorPort);
Parameters: sensorPort
Acceptable Sensors for sensorPort:
DIGITAL ports 1 through 12 (and your names for them given in Motors and Sensors Setup.)
Note that you must set these digital-ports to "VEX LED".
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 16
ROBOTC Natural Language - VEX Cortex Reference:
Flashlight ON
Turn a VEX Flashlight in a specified motor-port ON at a specified brightness.
Command:
turnFlashlightOn(motorPort, brightness);
Flashlight OFF
Turn a VEX Flashlight in a specified motor-port OFF.
Command:
turnFlashlightOff(motorPort);
Parameters: motorPort
Acceptable Motors for motorPort:
MOTOR ports 1 through 10 (and your names for them given in Motors and Sensors Setup.)
© 2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems ROBOTC Natural Language - VEX Cortex Reference • 17