|
|
| Line 825: |
Line 825: |
| | | style="border-style: solid; border-width: 1px 0px 0px 0px"|The sensor port to use for the touch sensor.<br />(default: '''''none''''') | | | style="border-style: solid; border-width: 1px 0px 0px 0px"|The sensor port to use for the touch sensor.<br />(default: '''''none''''') |
| | | style="border-style: solid; border-width: 1px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in16</span><br />Or their names setup in Motors and Sensors Setup. | | | style="border-style: solid; border-width: 1px 0px 0px 0px"|<span class="codeStringsNums">in1</span> to <span class="codeStringsNums">in16</span><br />Or their names setup in Motors and Sensors Setup. |
| − | |-
| |
| − | |}
| |
| − | |-
| |
| − | |
| |
| − | {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 0px; border-style: solid; border-color: #000;" cellpadding="5%"
| |
| − | ! style="border-style: solid; border-width: 0px 0px 0px 0px"|Default Usage and Sample
| |
| − | |-
| |
| − | | style="border-style: solid; border-width: 0px 0px 0px 0px"|<syntaxhighlight lang="ROBOTC">
| |
| − | forward();
| |
| − | untilRelease(in10); // wait until the touch sensor in port in10 is released (default)
| |
| − | stop();
| |
| − | </syntaxhighlight>
| |
| | |- | | |- |
| | |} | | |} |
| void moveStraightForTime(long seconds, tSensors rightEncoderPort, tSensors leftEncoderPort)
|
|
|
|
|
(void) The robot will use encoders to maintain a straight course for a length of time in seconds.
- NOTE: This function only supports moving forward and only at one speed setting. Future implementations may include moving backwards and variable speeds.
Acceptable Sensors: A/D ports 1 through 16 + interrupts (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| seconds
|
The amount of time in seconds to drive straight forward. (default: NONE)
|
Any integer amount from 0 to +2,147,483,647.
|
| rightEncoderPort
|
The right-side motor encoder. (default: NONE)
|
in1 to in16 Or their names setup in Motors and Sensors Setup.
|
| leftEncoderPort
|
The left-side motor encoder. (default: NONE)
|
in1 to in16 Or their names setup in Motors and Sensors Setup.
|
|
| Usage and Sample with Parameters
|
moveStraightForTime(7, in5, in3); /* move straight forward for 7 seconds,
using in5 as the right-side encoder
and in3 as the left-side encoder */
stop(); // stop
|
|
| void moveStraightForRotations(long rotations, tSensors rightEncoderPort, tSensors leftEncoderPort)
|
|
|
|
|
(void) The robot will use encoders to maintain a straight course for a distance in rotations (360 encoder counts = 1 rotation).
- NOTE: This function only supports moving forward and only at one speed setting. Future implementations may include moving backwards and variable speeds.
Acceptable Sensors: A/D ports 1 through 16 + interrupts (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| rotations
|
The amount of axle rotations to drive straight forward. (default: NONE)
|
Any integer amount from 0 to +2,147,483,647.
|
| rightEncoderPort
|
The right-side motor encoder. (default: NONE)
|
in1 to in16 Or their names setup in Motors and Sensors Setup.
|
| leftEncoderPort
|
The left-side motor encoder. (default: NONE)
|
in1 to in16 Or their names setup in Motors and Sensors Setup.
|
|
| Usage and Sample with Parameters
|
moveStraightForRotations(4, in5, in3); /* move straight forward for 4 rotations,
using in5 as the right-side encoder
and in3 as the left-side encoder */
stop(); // stop
|
|
| void untilBump(tSensors sensorPort, 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: A/D ports 1 through 16 (and your names for them given in Motors and Sensors Setup.)
Acceptable Range for Delay Time:
0 to 32,767.
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| sensorPort
|
The sensor port to use for the light sensor. (default: none)
|
in1 to in16 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 32,767.
|
|
| Default Usage and Sample
|
forward();
untilBump(in10); /* wait until the touch sensor in port in10 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(in10, 100); /* wait until the touch sensor in port in10 is pressed and
then released with a delay time of 100 milliseconds */
stop(); // stop
|
|
| void untilSonarGreaterThan(short distance = 30, tSensors sensorPort = dgtl8)
|
|
|
|
|
(void) The robot does what it was doing until the sonar sensor reads a value greater than a set distance in centimeters.
Range: 0 to 647 (A value of -1 means it cannot detect anything.)
Acceptable Sensors: digital ports 1 through 11 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| distance
|
The distance in centimeters that an object must be farther than to count (default: 30)
|
Any whole integer amount from 0 to 647.
|
| sensorPort
|
The sensor port to use for the sonar sensor. (default: dgtl8 [+ dgtl9])
|
dgtl1 to dgtl11 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilSonarGreaterThan(); /* wait until the sonar sensor in port dgtl8 (+ dgtl9)
detects an object farther than 30cm away (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // go forward at speed 63
untilSonarGreaterThan(45, dgtl2); /* wait until the sonar sensor in port dgtl2 (+ dgtl3)
detects an object farther than 45cm away */
stop(); // stop
|
|
| void untilSonarLessThan(short distance = 30, tSensors sensorPort = dgtl8)
|
|
|
|
|
(void) The robot does what it was doing until the sonar sensor reads a value less than a set distance in centimeters.
Range: 0 to 647 (A value of -1 means it cannot detect anything.)
Acceptable Sensors: digital ports 1 through 11 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| distance
|
The distance in centimeters that an object must be farther than to count (default: 30)
|
Any whole integer amount from 0 to 647.
|
| sensorPort
|
The sensor port to use for the sonar sensor. (default: dgtl8 [+ dgtl9])
|
dgtl1 to dgtl11 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilSonarLessThan(); /* wait until the sonar sensor in port dgtl8 (+ dgtl 9)
detects an object closer than 30cm away (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // go forward at speed 63
untilSonarLessThan(45, dgtl2); /* wait until the sonar sensor in port dgtl2 (+ dgtl3)
detects an object closer than 45cm away */
stop(); // stop
|
|
| void untilPotentiometerGreaterThan(int position = 2048, tSensors sensorPort = in6)
|
|
|
|
|
(void) The robot does what it was doing until the potentiometer sensor reads a value greater than a set position.
Range: 0 to 4095 (However due to mechanical stops, you may be limited to the range of 5 to 4090.)
Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| position
|
The function passes if the rotation is greater than this value (default: 2048)
|
Any whole integer amount from 0 to 4095.
|
| sensorPort
|
The sensor port to use for the sonar sensor. (default: in6)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilPotentiometerGreaterThan(); /* wait until the potentiometer in port in6
reads a value greater than 2048 (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // go forward at speed 63
untilPotentiometerGreaterThan(40, in4); /* wait until the potentiometer in port in4
reads a value greater than 40 (default) */
stop(); // stop
|
|
| void untilPotentiometerLessThan(int position = 2048, tSensors sensorPort = in6)
|
|
|
|
|
(void) The robot does what it was doing until the potentiometer sensor reads a value less than a set position.
Range: 0 to 4095 (However due to mechanical stops, you may be limited to the range of 5 to 4090.)
Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| position
|
The function passes if the rotation is less than this value (default: 2048)
|
Any whole integer amount from 0 to 4095.
|
| sensorPort
|
The sensor port to use for the sonar sensor. (default: in6)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilPotentiometerLessThan(); /* wait until the potentiometer in port in6
reads a value less than 2048 (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // go forward at speed 63
untilPotentiometerLessThan(40, in4); /* wait until the potentiometer in port in4
reads a value less than 40 (default) */
stop(); // stop
|
|
| void untilLight(int threshold = 505, tSensors sensorPort = in2)
|
|
|
|
|
(void) The robot does what it was doing until the light sensor reads a value lighter than the threshold.
Range: (light) 0 to 4095 (dark)
Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| threshold
|
The threshold value that an object must be lighter than to count (default: 505)
|
Any whole integer amount from 0 to 4095.
|
| sensorPort
|
The sensor port to use for the sonar sensor. (default: in2)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilLight(); /* wait until the light sensor in port in2
detects an object lighter than 505 (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // go forward at speed 63
untilLight(1005, in4); /* wait until the light sensor in port in4
detects an object lighter than 1005 */
stop(); // stop
|
|
| void untilDark(int threshold = 505, tSensors sensorPort = in2)
|
|
|
|
|
(void) The robot does what it was doing until the light sensor reads a value darker than the threshold.
Range: (light) 0 to 4095 (dark)
Acceptable Sensors: analog ports 1 through 8 (and your names for them given in Motors and Sensors Setup.)
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| threshold
|
The threshold value that an object must be darker than to count (default: 505)
|
Any whole integer amount from 0 to 4095.
|
| sensorPort
|
The sensor port to use for the sonar sensor. (default: in2)
|
in1 to in8 Or their names setup in Motors and Sensors Setup.
|
|
| Default Usage and Sample
|
forward();
untilDark(); /* wait until the light sensor in port in2
detects an object darker than 505 (default) */
stop();
|
|
| Usage and Sample with Parameters
|
forward(63); // go forward at speed 63
untilDark(1005, in4); /* wait until the light sensor in port in4
detects an object darker than 1005 */
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(3, dgtl3); /* wait until the quadrature encoder in port
dgtl3 (+ dgtl4)counts 3 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
|
|
| void turnFlashlightOn(tMotor flashlightPort = port4, short brightness = 63)
|
|
|
|
|
(void) Turns a VEX Flashlight in a specfied motor port ON at a specified brightness.
Brightness Range: (off) 0 to 127 (bright)
Acceptable Ports: motor ports 1 through 10 (and your names for them given in Motors and Sensors Setup.)
NOTE: Brightness control only available in motor ports 1 and 10, or 2 through 9 when connected to a VEX Motor Controller 29.
|
|
| Parameter
|
Explanation
|
Acceptable Input
|
| sensorPort
|
The VEX Flashlight to use. (default: port4)
|
port1 to port10 Or their names setup in Motors and Sensors Setup.
|
| brightness
|
The level of brightness to set the VEX Flashlight to. (default: dgtl2)
|
Any whole integer amount from 0 to 127.
|
|
| Default Usage and Sample
|
turnFlashlightOn(); // turn VEX Flashlight in port4 ON to half brightness [63] (default)
|
|
| Usage and Sample with Parameters
|
turnFlashlightOn(port10, 127); // turn VEX Flashlight in port10 ON to full brightness [127]
|
|