|
|
| Line 1,114: |
Line 1,114: |
| | {| 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">arcadeControl</span><span class="bigCodePunc">(</span><span class="bigKeywordBI">short </span><span class="bigCodeBasic">&verticalJoystick</span><span class="bigCodePunc"> = </span><span class="bigCodeBasic">joystick.</span><span class="bigKeywordB">joy1_y2</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">short </span><span class="bigCodeBasic">&horizontalJoystick</span><span class="bigCodePunc"> = </span><span class="bigCodeBasic">joystick.</span><span class="bigKeywordB">joy1_y1</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">short </span><span class="bigCodeBasic">threshold</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">10</span><span class="bigCodePunc">)</span> | + | | class="functionType"| <span class="bigKeywordBI">void </span><span class="bigKeywordB">arcadeControl</span><span class="bigCodePunc">(</span><span class="bigKeywordB">TVexJoysticks </span><span class="bigCodeBasic">verticalJoystick</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">Ch2</span><span class="bigCodePunc">, </span><span class="bigKeywordB">TVexJoysticks </span><span class="bigCodeBasic">horizontalJoystick</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">Ch1</span><span class="bigCodePunc">, </span><span class="bigKeywordBI">short </span><span class="bigCodeBasic">threshold</span><span class="bigCodePunc"> = </span><span class="bigCodeStringsNums">10</span><span class="bigCodePunc">)</span> |
| | |- | | |- |
| | | | | | |
| Line 1,121: |
Line 1,121: |
| | ! style="border-style: solid; border-width: 0px 0px 0px 0px"| | | ! style="border-style: solid; border-width: 0px 0px 0px 0px"| |
| | |- | | |- |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|[[File:arcade_control.png]] | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|[[File:arcade_control_vex.png]] |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|([[Data_Types#dataType_void|void]]) 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. | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|([[Data_Types#dataType_void|void]]) 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. |
| | | | |
| Line 1,133: |
Line 1,133: |
| | ! style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation | | ! style="border-style: solid; border-width: 0px 0px 1px 0px"|Explanation |
| | ! style="border-style: solid; border-width: 0px 0px 1px 0px"|Acceptable Input | | ! style="border-style: solid; border-width: 0px 0px 1px 0px"|Acceptable Input |
| − | |-
| |
| | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''verticalJoystick'' | | | style="border-style: solid; border-width: 1px 0px 1px 0px"|''verticalJoystick'' |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The joystick to use as the vertical joystick.<br />(default: <span class="bigCodeBasic">joystick.</span><span class="bigKeywordB">joy1_y2</span>) | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|The joystick to use as the VERTICAL joystick.<br />(default: <span class="codeStringsNums">Ch2</span>) |
| − | | style="border-style: solid; border-width: 1px 0px 1px 0px"|Any joystick:<br /><span class="bigKeywordB">joy1_x1<br />joy1_x2<br />joy1_y1<br />joy1_y2<br />joy2_x1<br />joy2_x2<br />joy2_y1<br />joy2_y2</span> | + | | style="border-style: solid; border-width: 1px 0px 1px 0px"|Any channel:<br /><span class="codeStringsNums">Ch1<br />Ch2<br />Ch3<br />Ch4</span> |
| | |- | | |- |
| | | style="border-style: solid; border-width: 0px 0px 1px 0px"|''horizontalJoystick'' | | | style="border-style: solid; border-width: 0px 0px 1px 0px"|''horizontalJoystick'' |
| − | | style="border-style: solid; border-width: 0px 0px 1px 0px"|The joystick to use as the horizontal joystick.<br />(default: <span class="bigCodeBasic">joystick.</span><span class="bigKeywordB">joy1_x2</span>) | + | | style="border-style: solid; border-width: 0px 0px 1px 0px"|The joystick to use as the HORIZONTAL joystick.<br />(default: <span class="codeStringsNums">Ch1</span>) |
| − | | style="border-style: solid; border-width: 0px 0px 1px 0px"|Any joystick:<br /><span class="bigKeywordB">joy1_x1<br />joy1_x2<br />joy1_y1<br />joy1_y2<br />joy2_x1<br />joy2_x2<br />joy2_y1<br />joy2_y2</span> | + | | style="border-style: solid; border-width: 0px 0px 1px 0px"|Any channel:<br /><span class="codeStringsNums">Ch1<br />Ch2<br />Ch3<br />Ch4</span> |
| | |- | | |- |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''threshold'' | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|''threshold'' |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|This variable eliminates 'noise' caused by joysticks not returning back to the exact center.<br />(default: <span class="codeStringsNums">10</span>) | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|This variable eliminates 'noise' caused by joysticks not returning back to the exact center.<br />(default: <span class="codeStringsNums">10</span>) |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0 to 100 | + | | style="border-style: solid; border-width: 0px 0px 0px 0px"|0 to 127 |
| | |- | | |- |
| | |} | | |} |
| Line 1,156: |
Line 1,155: |
| | { | | { |
| | arcadeControl(); /* control the robot in 'arcade' fashion | | arcadeControl(); /* control the robot in 'arcade' fashion |
| − | with the VERTICAL joystick as joy1_y2 | + | with the VERTICAL joystick as Ch2 |
| − | and the HORIZONTAL joystick as joy1_x2, | + | and the HORIZONTAL joystick as Ch1, |
| | with a threshold of 10 (default) */ | | with a threshold of 10 (default) */ |
| | } | | } |
| Line 1,171: |
Line 1,170: |
| | while(true) | | while(true) |
| | { | | { |
| − | arcadeControl(joystick.joy1_y1, joystick.joy1_y2, 5); /* control the robot in 'arcade' fashion | + | arcadeControl(Ch3, Ch4, 5); /* control the robot in 'arcade' fashion |
| − | with the VERTICAL joystick as joy1_y1
| + | with the VERTICAL joystick as Ch3 |
| − | and the HORIZONTAL joystick as joy1_y2,
| + | and the HORIZONTAL joystick as Ch4, |
| − | with a threshold of 5 */
| + | with a threshold of 5 */ |
| | } | | } |
| | </syntaxhighlight> | | </syntaxhighlight> |
| 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.
|
| void lineTrackForTime(float trackTime = 5.0, int threshold = 505, tSensors sensorLeft = in1, tSensors sensorCenter = in2, tSensors sensorRight = in3)
|
|
|
|
|
(void) The robot will track a black line on a white surface for a specified time in seconds.
Threshold Range: (dark) 0 to 4095 (light)
Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| trackTime
|
The amount of time in seconds to track a line. (default: 5.0)
|
Any floating point amount:
|
|
|
| 0.####
|
-2,048.0000 to +2,048.0000
|
| 0.###
|
-32,768.000 to +32,768.000
|
| 0.##
|
-262,144.00 to +262,144.00
|
| 0.#
|
-2,097,200.0 to +2,097,200.0
|
|
| threshold
|
The threshold to compare colors against. (default: 505)
|
0 to +4095
|
| sensorLeft
|
The sensor port to use for the LEFT line tracking sensor. (default: in1)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
| sensorCenter
|
The sensor port to use for the CENTER line tracking sensor. (default: in2)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
| sensorRight
|
The sensor port to use for the RIGHT line tracking sensor. (default: in3)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
lineTrackForTime(); /* track a black line for 5.0 seconds,
using a threshold of 505, with the
line tracking sensors in ports:
in1, in2, in3(default) */
stop();
|
|
| Usage and Sample with Parameters
|
lineTrackForTime(7.5, 99, in6, in7, in8); /* track a black line for 7.5 seconds,
using a threshold of 99, with the
line tracking sensors in ports:
in6, in7, in8 */
stop(); // stop
|
|
| void lineTrackForRotations(float rotations = 3.0, int threshold = 505, tSensors sensorLeft = in1, tSensors sensorCenter = in2, tSensors sensorRight = in3)
|
|
|
|
|
(void) The robot will track a black line on a white surface for a specified distance in rotations.
Threshold Range: (dark) 0 to 4095 (light)
Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| rotations
|
The amount of axle rotations to track a line. (default: 3.0)
|
Any floating point amount:
|
|
|
| 0.####
|
-2,048.0000 to +2,048.0000
|
| 0.###
|
-32,768.000 to +32,768.000
|
| 0.##
|
-262,144.00 to +262,144.00
|
| 0.#
|
-2,097,200.0 to +2,097,200.0
|
|
| threshold
|
The threshold to compare colors against. (default: 505)
|
0 to +4095
|
| sensorLeft
|
The sensor port to use for the LEFT line tracking sensor. (default: in1)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
| sensorCenter
|
The sensor port to use for the CENTER line tracking sensor. (default: in2)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
| sensorRight
|
The sensor port to use for the RIGHT line tracking sensor. (default: in3)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
lineTrackForRotations(); /* track a black line for 3.0 rotations,
using a threshold of 505, with the
line tracking sensors in ports:
in1, in2, in3(default) */
stop();
|
|
| Usage and Sample with Parameters
|
lineTrackForRotations(4.75, 99, in6, in7, in8); /* track a black line for 4.75 rotations,
using a threshold of 99, with the
line tracking sensors in ports:
in6, in7, in8 */
stop(); // stop
|
|