|
|
| Line 259: |
Line 259: |
| | |- | | |- |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> |
| − | startMotor(port8, -32); // start port8 at speed -32 | + | startMotor(port8, -32); // start port8 at speed -32 |
| − | wait(0.5); // wait 0.5 seconds
| + | waitInMilliseconds(500); // wait 0.5 seconds |
| − | stopMotor(port8); // stop port8 | + | stopMotor(port8); // stop port8 |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | |- | | |- |
| Line 316: |
Line 316: |
| | |- | | |- |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> |
| − | startMotor(port8, -32); // start port8 at speed -32 | + | startMotor(port8, -32); // start port8 at speed -32 |
| − | wait(0.5); // wait 0.5 seconds
| + | waitInMilliseconds(500); // wait 0.5 seconds |
| − | stopMotor(port8); // stop port8 | + | stopMotor(port8); // stop port8 |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | |- | | |- |
| Line 550: |
Line 550: |
| | |- | | |- |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> |
| − | pointTurn(left, 63); // point turn LEFT at speed 63 | + | pointTurn(left, 63); // point turn LEFT at speed 63 |
| − | wait(0.4); // wait 0.4 seconds
| + | waitInMilliseconds(400); // wait 0.4 seconds |
| − | stop(); // stop | + | stop(); // stop |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | |- | | |- |
| Line 610: |
Line 610: |
| | |- | | |- |
| | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> | | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC"> |
| − | swingTurn(left, 63); // swing turn LEFT at speed 63 | + | swingTurn(left, 63); // swing turn LEFT at speed 63 |
| − | wait(0.75); // wait 0.75 seconds
| + | waitInMilliseconds(750); // wait 0.75 seconds |
| − | stop(); // stop | + | stop(); // stop |
| | </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 tankControl(TVexJoysticks rightJoystick = Ch2, TVexJoysticks leftJoystick = Ch3, short threshold = 10)
|
|
|
|
|
(void) The robot will be remote controlled in such a way that the left motor is mapped to the left joystick and the right motor is mapped to the right joystick.
- NOTE: This function only supports 2 channels and works best with the joystics.
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| rightJoystick
|
The joystick to use as the RIGHT-side joystick. (default: Ch2)
|
Any channel: Ch1 Ch2 Ch3 Ch4
|
| leftJoystick
|
The joystick to use as the LEFT-side joystick. (default: Ch3)
|
Any channel: Ch1 Ch2 Ch3 Ch4
|
| threshold
|
This variable eliminates 'noise' caused by joysticks not returning back to the exact center. (default: 10)
|
0 to 127
|
|
| Default Usage and Sample
|
while(true)
{
tankControl(); /* control the robot in 'tank' fashion
with the RIGHT joystick as Ch2 and
the LEFT joystick as Ch1, with a
threshold of 10 (default) */
}
|
|
| Usage and Sample with Parameters
|
while(true)
{
tankControl(Ch1, Ch4, 5); /* control the robot in 'tank' fashion
with the RIGHT joystick as Ch1 and
the LEFT joystick as Ch2, with a
threshold of 5 */
}
|
|
| void arcadeControl(TVexJoysticks verticalJoystick = Ch2, TVexJoysticks horizontalJoystick = Ch1, short threshold = 10)
|
|
|
|
|
(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.
- NOTE: This function only supports 2 channels and works best with the joystics.
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| verticalJoystick
|
The joystick to use as the VERTICAL joystick. (default: Ch2)
|
Any channel: Ch1 Ch2 Ch3 Ch4
|
| horizontalJoystick
|
The joystick to use as the HORIZONTAL joystick. (default: Ch1)
|
Any channel: Ch1 Ch2 Ch3 Ch4
|
| threshold
|
This variable eliminates 'noise' caused by joysticks not returning back to the exact center. (default: 10)
|
0 to 127
|
|
| Default Usage and Sample
|
while(true)
{
arcadeControl(); /* control the robot in 'arcade' fashion
with the VERTICAL joystick as Ch2
and the HORIZONTAL joystick as Ch1,
with a threshold of 10 (default) */
}
|
|
| Usage and Sample with Parameters
|
while(true)
{
arcadeControl(Ch3, Ch4, 5); /* control the robot in 'arcade' fashion
with the VERTICAL joystick as Ch3
and the HORIZONTAL joystick as Ch4,
with a threshold of 5 */
}
|
|
| void untilBump(tSensors sensorPort = dgtl6, int delayTimeMS = 10)
|
|
|
|
|
(void) The robot does what it was doing until the touch sensor is pressed in and then released out. A delay time in milliseconds can be specified.
Acceptable Sensors: digital ports 1 through 12 (and your names for them given in Motors and Sensors Setup.)
Acceptable Range for Delay Time:
0 to 2,147,483,647.
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| sensorPort
|
The sensor port to use for the light sensor. (default: dgtl6)
|
dgtl1 to dgtl12 Or their names setup in Motors and Sensors Setup.
|
| delayTimeMS
|
The amount of milliseconds that MUST PASS between press and release of the sensor for it to count. (default: 10)
|
Any whole integer amount from 0 to 2,147,483,647.
|
|
| Default Usage and Sample
|
forward();
untilBump(); /* wait until the touch sensor in port dgtl6 is pressed and
then released with a delay time of 10 milliseconds (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // go forward at speed 63
untilBump(dgtl10, 100); /* wait until the touch sensor in port dgtl10 is pressed and
then released with a delay time of 100 milliseconds */
stop(); // stop
|
|
| void untilRotations(float rotations = 1.0, tSensors sensorPort = dgtl1)
|
|
|
|
|
(void) The robot does what it was doing until the motor encoder rotations match the desired value.
Range: -262,144.00 to +262,144.00
Acceptable Sensors: digital ports 1 through 11 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| rotations
|
The amount of axle rotations to reach. (default: 1.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
|
|
| sensorPort
|
The quadrature encoder to use. (default: dgtl1 [+ dgtl1])
|
dgtl1 to dgtl11 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilRotations(); /* wait until the quadrature encoder in port
dgtl1 (+ dgtl2) counts 1.0 rotations (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // move forward at speed 63
untilRotations(2.75, dgtl3); /* wait until the quadrature encoder in port
dgtl3 (+ dgtl4)counts 2.75 rotations */
stop(); // stop
|
|
| void untilEncoderCounts(long distance = 360, tSensors sensorPort = dgtl1)
|
|
|
|
|
(void) The robot does what it was doing until the motor encoder counts match the desired value.
Range: -2,147,483,648 to +2,147,483,647
Acceptable Sensors: digital ports 1 through 11 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| distance
|
The amount of encoder counts to reach. (default: 360)
|
Any whole integer amount from -2,147,483,648 to +2,147,483,647
|
| sensorPort
|
The quadrature encoder to use. (default: dgtl1 [+ dgtl1])
|
dgtl1 to dgtl11 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilEncoderCounts(); /* wait until the quadrature encoder in port
dgtl1 (+ dgtl2) counts 360 encoder counts (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // move forward at speed 63
untilEncoderCounts(990, dgtl3); /* wait until the quadrature encoder in port
dgtl3 (+ dgtl4)counts 990 encoder counts */
stop(); // stop
|
|