VEX2 Natural Language
(→turnFlashlightOn) |
|||
| (18 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | <yambe:breadcrumb self="Natural Language">VEX2|CORTEX</yambe:breadcrumb> | |
| − | + | <br /> | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | {| | |
| − | {| | + | |
|- | |- | ||
|The ROBOTC Natural Language Library aims at making learning and using text-based programming languages easier for beginners. The Natural Language Library is filled with commands that are both easy to use and easy to remember. Natural Language commands encompass entire robot behaviors into a single command. | |The ROBOTC Natural Language Library aims at making learning and using text-based programming languages easier for beginners. The Natural Language Library is filled with commands that are both easy to use and easy to remember. Natural Language commands encompass entire robot behaviors into a single command. | ||
| Line 14: | Line 9: | ||
|- | |- | ||
|} | |} | ||
| + | <br /> | ||
| − | { | + | {{tl|1|1}} |
| − | + | <br /> | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
== Video == | == Video == | ||
| Line 807: | Line 789: | ||
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.#### | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.#### | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-2,048.0000 to +2,048.0000 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.### | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.### | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-32,768.000 to +32,768.000 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.## | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.## | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-262,144.00 to +262,144.00 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.# | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.# | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-2,097,200.0 to +2,097,200.0 |
|- | |- | ||
|} | |} | ||
| Line 872: | Line 854: | ||
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
| − | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">moveStraightForTime</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">float </span><span class="bigCodeBasic">seconds</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">5.0</span><span class="bigCodePunc">, </span><span class="bigCodeBasic"> | + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">moveStraightForTime</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">float </span><span class="bigCodeBasic">seconds</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">5.0</span><span class="bigCodePunc">, </span><span class="bigCodeBasic">tSensors </span><span class="bigCodeBasic">rightEncoderPort</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">dgtl1</span><span class="bigCodePunc">, </span><span class="bigCodeBasic">tSensors </span><span class="bigCodeBasic">leftEncoderPort</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">dgtl3</span><span class="bigCodePunc">)</span> |
|- | |- | ||
| | | | ||
| Line 957: | Line 939: | ||
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | {| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0" | ||
|- | |- | ||
| − | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">moveStraightForRotations</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">float </span><span class="bigCodeBasic">rotations</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">1.0</span><span class="bigCodePunc">, </span><span class="bigCodeBasic"> | + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">moveStraightForRotations</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">float </span><span class="bigCodeBasic">rotations</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">1.0</span><span class="bigCodePunc">, </span><span class="bigCodeBasic">tSensors </span><span class="bigCodeBasic">rightEncoderPort</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">dgtl1</span><span class="bigCodePunc">, </span><span class="bigCodeBasic">tSensors </span><span class="bigCodeBasic">leftEncoderPort</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">dgtl3</span><span class="bigCodePunc">)</span> |
|- | |- | ||
| | | | ||
| Line 987: | Line 969: | ||
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.#### | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.#### | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-2,048.0000 to +2,048.0000 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.### | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.### | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-32,768.000 to +32,768.000 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.## | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.## | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-262,144.00 to +262,144.00 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.# | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.# | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-2,097,200.0 to +2,097,200.0 |
|- | |- | ||
|} | |} | ||
| Line 1,208: | Line 1,190: | ||
|- | |- | ||
| style="border-style: solid; border-width: 1px 0px 0px 0px"|''sensorPort'' | | style="border-style: solid; border-width: 1px 0px 0px 0px"|''sensorPort'' | ||
| − | | style="border-style: solid; border-width: 1px 0px 0px 0px"|The sensor port to use for the | + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|The sensor port to use for the touch sensor.<br />(default: <span class="codeStringsNums">dgtl6</span>) |
| style="border-style: solid; border-width: 1px 0px 0px 0px"|<span class="codeStringsNums">dgtl1</span> to <span class="codeStringsNums">dgtl12</span><br />Or their names setup in Motors and Sensors Setup. | | style="border-style: solid; border-width: 1px 0px 0px 0px"|<span class="codeStringsNums">dgtl1</span> to <span class="codeStringsNums">dgtl12</span><br />Or their names setup in Motors and Sensors Setup. | ||
|- | |- | ||
| Line 1,264: | Line 1,246: | ||
|- | |- | ||
| style="border-style: solid; border-width: 1px 0px 0px 0px"|''sensorPort'' | | style="border-style: solid; border-width: 1px 0px 0px 0px"|''sensorPort'' | ||
| − | | style="border-style: solid; border-width: 1px 0px 0px 0px"|The sensor port to use for the | + | | style="border-style: solid; border-width: 1px 0px 0px 0px"|The sensor port to use for the touch sensor.<br />(default: <span class="codeStringsNums">dgtl6</span>) |
| style="border-style: solid; border-width: 1px 0px 0px 0px"|<span class="codeStringsNums">dgtl1</span> to <span class="codeStringsNums">dgtl12</span><br />Or their names setup in Motors and Sensors Setup. | | style="border-style: solid; border-width: 1px 0px 0px 0px"|<span class="codeStringsNums">dgtl1</span> to <span class="codeStringsNums">dgtl12</span><br />Or their names setup in Motors and Sensors Setup. | ||
|- | |- | ||
| Line 1,323: | Line 1,305: | ||
|- | |- | ||
| style="border-style: solid; border-width: 1px 0px 1px 0px"|''sensorPort'' | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''sensorPort'' | ||
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The sensor port to use for the | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The sensor port to use for the touch sensor.<br />(default: <span class="codeStringsNums">dgtl6</span>) |
| style="border-style: solid; border-width: 1px 0px 1px 0px"|<span class="codeStringsNums">dgtl1</span> to <span class="codeStringsNums">dgtl12</span><br />Or their names setup in Motors and Sensors Setup. | | style="border-style: solid; border-width: 1px 0px 1px 0px"|<span class="codeStringsNums">dgtl1</span> to <span class="codeStringsNums">dgtl12</span><br />Or their names setup in Motors and Sensors Setup. | ||
|- | |- | ||
| Line 1,519: | Line 1,501: | ||
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the potentiometer sensor.<br />(default: <span class="codeStringsNums">in6</span>) |
| style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | ||
|- | |- | ||
| Line 1,583: | Line 1,565: | ||
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the potentiometer sensor.<br />(default: <span class="codeStringsNums">in6</span>) |
| style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | ||
|- | |- | ||
| Line 1,706: | Line 1,688: | ||
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the potentiometer sensor.<br />(default: <span class="codeStringsNums">in2</span>) |
| style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | ||
|- | |- | ||
| Line 1,770: | Line 1,752: | ||
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''sensorPort'' | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The sensor port to use for the potentiometer sensor.<br />(default: <span class="codeStringsNums">in2</span>) |
| style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in8</span><br />Or their names setup in Motors and Sensors Setup. | ||
|- | |- | ||
| Line 1,837: | Line 1,819: | ||
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.#### | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.#### | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-2,048.0000 to +2,048.0000 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.### | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.### | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-32,768.000 to +32,768.000 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.## | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.## | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-262,144.00 to +262,144.00 |
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|0.# | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0.# | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"| | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|-2,097,200.0 to +2,097,200.0 |
|- | |- | ||
|} | |} | ||
| Line 1,876: | Line 1,858: | ||
forward(63); // move forward at speed 63 | forward(63); // move forward at speed 63 | ||
untilRotations(2.75, dgtl3); /* wait until the quadrature encoder in port | untilRotations(2.75, dgtl3); /* wait until the quadrature encoder in port | ||
| − | dgtl3 (+ dgtl4)counts 2.75 rotations */ | + | dgtl3 (+ dgtl4) counts 2.75 rotations */ |
stop(); // stop | stop(); // stop | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 1,940: | Line 1,922: | ||
forward(63); // move forward at speed 63 | forward(63); // move forward at speed 63 | ||
untilEncoderCounts(990, dgtl3); /* wait until the quadrature encoder in port | untilEncoderCounts(990, dgtl3); /* wait until the quadrature encoder in port | ||
| − | dgtl3 (+ dgtl4)counts 990 encoder counts */ | + | dgtl3 (+ dgtl4) counts 990 encoder counts */ |
stop(); // stop | stop(); // stop | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 2,086: | Line 2,068: | ||
|- | |- | ||
| style="border-style: solid; border-width: 0px 0px 0px 0px"|''brightness'' | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''brightness'' | ||
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The level of brightness to<br />set the VEX Flashlight to.<br />(default: <span class="codeStringsNums"> | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|The level of brightness to<br />set the VEX Flashlight to.<br />(default: <span class="codeStringsNums">63</span>) |
| style="border-style: solid; border-width: 0px 0px 0px 0px"|Any whole integer amount from 0 to 127. | | style="border-style: solid; border-width: 0px 0px 0px 0px"|Any whole integer amount from 0 to 127. | ||
|- | |- | ||
Latest revision as of 12:41, 30 April 2012
| The ROBOTC Natural Language Library aims at making learning and using text-based programming languages easier for beginners. The Natural Language Library is filled with commands that are both easy to use and easy to remember. Natural Language commands encompass entire robot behaviors into a single command.
Natural Language can be enabled in ROBOTC by going to the Robot menu, then Platform Type, and then by selecting one of the Natural Language options. |
|
| |||||||
Video
| This video explains the ROBOTC Natural Language:
|
Setup Functions
robotType
| void robotType(tRobotType type = none) | ||||||
| ||||||
| ||||||
| ||||||
|
Wait Functions
wait
| void wait(float waitTime = 1.0) | ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
|
waitInMilliseconds
| void waitInMilliseconds(long waitTime = 1000) | ||||||
| ||||||
| ||||||
| ||||||
|
Movement Functions
startMotor
| void startMotor(tMotor motorPort = port6, byte speed = 95) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
stopMotor
| void stopMotor(tMotor motorPort = port6) | ||||||
| ||||||
| ||||||
| ||||||
|
setServo
| void setServo(tMotor servoPort = port6, int position = 0) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
Robot Movement Functions
forward
| void forward(byte speed = 95) | ||||||
| ||||||
| ||||||
| ||||||
|
backward
| void backward(byte speed = -95) | ||||||
| ||||||
| ||||||
| ||||||
|
pointTurn
| void pointTurn(tDirections direction = right, byte speed = 95) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
swingTurn
| void swingTurn(tDirections direction = right, byte speed = 95) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
stop
| void stop() | ||||
| ||||
| ||||
|
lineTrackForTime
| void lineTrackForTime(float trackTime = 5.0, int threshold = 505, tSensors sensorLeft = in1, tSensors sensorCenter = in2, tSensors sensorRight = in3) | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
|
lineTrackForRotations
| void lineTrackForRotations(float rotations = 3.0, int threshold = 505, tSensors sensorLeft = in1, tSensors sensorCenter = in2, tSensors sensorRight = in3) | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
|
moveStraightForTime
| void moveStraightForTime(float seconds = 5.0, tSensors rightEncoderPort = dgtl1, tSensors leftEncoderPort = dgtl3) | ||||||||||||||||||||||
| ||||||||||||||||||||||
| ||||||||||||||||||||||
| ||||||||||||||||||||||
|
moveStraightForRotations
| void moveStraightForRotations(float rotations = 1.0, tSensors rightEncoderPort = dgtl1, tSensors leftEncoderPort = dgtl3) | ||||||||||||||||||||||
| ||||||||||||||||||||||
| ||||||||||||||||||||||
| ||||||||||||||||||||||
|
tankControl
| void tankControl(TVexJoysticks rightJoystick = Ch2, TVexJoysticks leftJoystick = Ch3, short threshold = 10) | ||||||||||||
| ||||||||||||
| ||||||||||||
| ||||||||||||
|
arcadeControl
| void arcadeControl(TVexJoysticks verticalJoystick = Ch2, TVexJoysticks horizontalJoystick = Ch1, short threshold = 10) | ||||||||||||
| ||||||||||||
| ||||||||||||
| ||||||||||||
|
Until Functions
untilTouch
| void untilTouch(tSensors sensorPort = dgtl6) | ||||||
| ||||||
| ||||||
| ||||||
|
untilRelease
| void untilRelease(tSensors sensorPort = dgtl6) | ||||||
| ||||||
| ||||||
| ||||||
|
untilBump
| void untilBump(tSensors sensorPort = dgtl6, int delayTimeMS = 10) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
untilSonarGreaterThan
| void untilSonarGreaterThan(short distance = 30, tSensors sensorPort = dgtl8) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
untilSonarLessThan
| void untilSonarLessThan(short distance = 30, tSensors sensorPort = dgtl8) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
untilPotentiometerGreaterThan
| void untilPotentiometerGreaterThan(int position = 2048, tSensors sensorPort = in6) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
untilPotentiometerLessThan
| void untilPotentiometerLessThan(int position = 2048, tSensors sensorPort = in6) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
untilButtonPress
| void untilButtonPress(short button = centerBtnVEX) | ||||||
| ||||||
| ||||||
| ||||||
|
untilLight
| void untilLight(int threshold = 505, tSensors sensorPort = in2) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
untilDark
| void untilDark(int threshold = 505, tSensors sensorPort = in2) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
untilRotations
| void untilRotations(float rotations = 1.0, tSensors sensorPort = dgtl1) | |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
|
untilEncoderCounts
| void untilEncoderCounts(long distance = 360, tSensors sensorPort = dgtl1) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
Special Functions
turnLEDOn
| void turnLEDOn(tSensors sensorPort = dgtl2) | ||||||
| ||||||
| ||||||
| ||||||
|
turnLEDOff
| void turnLEDOff(tSensors sensorPort = dgtl2) | ||||||
| ||||||
| ||||||
| ||||||
|
turnFlashlightOn
| void turnFlashlightOn(tMotor flashlightPort = port4, short brightness = 63) | |||||||||
| |||||||||
| |||||||||
| |||||||||
|
turnFlashlightOff
| void turnFlashlightOff(tMotor flashlightPort = port4) | ||||||
| ||||||
| ||||||
| ||||||
|
































