NXT Natural Language

From ROBOTC API Guide
Jump to: navigation, search
NXT → Natural Language


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.


Contents

Color Key
Function:
Variable:


Video

This video explains the ROBOTC Natural Language:



Setup Functions

robotType

void robotType(tRobotType type = none)
Robot type.png (void) Choose which robot you want to write a program for.

Acceptable robots: Rembot or none (no setup).

(If you don't use this function at all, it will default to none!)

Parameter Explanation Acceptable Input
type The robot model to use.
(default: none)
none
rembot
Default Usage and Sample
robotType();  // default (none) is used
Usage and Sample with Parameters
robotType(rembot);  // rembot will be used


Wait Functions

wait

void wait(float waitTime = 1.0)
Wait seconds.png (void) Wait an amount of time measured in seconds.
Parameter Explanation Acceptable Input
waitTime Amount of time to wait, in seconds.
(default: 1.0)
Any floating point amount:
0.#### 0.0000 to +2,048.0000
0.### 0.000 to +32,768.000
0.## 0.00 to +262,144.00
0.# 0.0 to +2,097,200.0
Default Usage and Sample
forward();
wait();     // wait for 1.0 seconds (default)
stop();
Usage and Sample with Parameters
forward(50);  // go forward at speed 50
wait(2.7);    // wait for 2.7 seconds
stop();       // stop


waitInMilliseconds

void waitInMilliseconds(long waitTime = 1000)
Wait milliseconds.png (void) Wait an amount of time measured in milliseconds.
Parameter Explanation Acceptable Input
waitTime Amount of time to wait, in seconds.
(default: 1000)
Any integer amount from
0 to +2,147,483,647.
Default Usage and Sample
forward();
waitInMilliseconds();  // wait for 1000 milliseconds (default)
stop();
Usage and Sample with Parameters
forward(50);               // go forward at speed 50
waitInMilliseconds(2700);  // wait for 2700 milliseconds (2.7 seconds)
stop();                    // stop


Movement Functions

startMotor

void startMotor(tMotor motorPort = motorA, byte speed = 75)
Set motor.png (void) Set a motor to a speed.

Range: -100 to 100

Acceptable Motors: ports A through C, (and your names for them given in Motors and Sensors Setup.)

Parameter Explanation Acceptable Input
motorPort The motor port to use.
(default: motorA)
motorA
motorB
motorC

Or their names setup in Motors and Sensors Setup.
speed The speed to set the motor to.
(default: 75)
-100 to +100
Default Usage and Sample
startMotor();  // starts motorA at speed 75 (default)
wait();
stopMotor();
Usage and Sample with Parameters
startMotor(motorB, -25);  // start motorB at speed -25
wait(0.5);                // wait 0.5 seconds
stopMotor(motorB);        // stop motorB


stopMotor

void stopMotor(tMotor motorPort = motorA)
Arm stop.png (void) Stops a motor.

Acceptable Motors: ports A through C, (and your names for them given in Motors and Sensors Setup.)

Parameter Explanation Acceptable Input
motorPort The motor port to use.
(default: motorA)
motorA
motorB
motorC

Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
startMotor();
wait();
stopMotor();   // stop motorA (default)
Usage and Sample with Parameters
startMotor(motorB, -25);  // start motorB at speed -25
wait(0.5);                // wait 0.5 seconds
stopMotor(motorB);        // stop motorB


Robot Movement Functions

forward

void forward(byte speed = 75)
Forward.png (void) Both wheels rotate forward at the same speed and the robot moves straight forward.

Range: -100 to 100 (Forward will always move your robot forward.)

Parameter Explanation Acceptable Input
speed The speed to move forward at.
(default: 75)
-100 to +100
Default Usage and Sample
forward();  // move forward at speed 75 (default)
wait();
stop();
Usage and Sample with Parameters
forward(50);  // move forward at speed 50
wait(2.0);    // wait 2.0 seconds
stop();       // stop


backward

void backward(byte speed = -75)
Backward.png (void) Both wheels rotate backward at the same speed and the robot moves straight backward.

Range: -100 to 100 (Backward will always move your robot backward.)

Parameter Explanation Acceptable Input
speed The speed to move backward at.
(default: -75)
-100 to +100
Default Usage and Sample
backward();  // move backward at speed -75 (default)
wait();
stop();
Usage and Sample with Parameters
backward(-50);  // move backward at speed -50
wait(2.0);      // wait 2.0 seconds
stop();         // stop


pointTurn

void pointTurn(tDirections direction = right, byte speed = 75)
Point turn.png (void) Both wheels rotate at the same speed but in opposite directions, causing the robot to turn around it's center. This makes a sharp turn in place.

Range: -100 to 100

Parameter Explanation Acceptable Input
direction The direction to turn.
(default: right)
right
left
speed The speed to move turn at.
(default: 75)
-100 to +100
Default Usage and Sample
pointTurn();  // point turn right at speed 75 (default)
wait();
stop();
Usage and Sample with Parameters
pointTurn(left, 50);  // point turn LEFT at speed 50
wait(0.4);            // wait 0.4 seconds
stop();               // stop


swingTurn

void swingTurn(tDirections direction = right, byte speed = 75)
Swing turn.png (void) One wheel rotates while the other does not move, causing the robot to turn around the stopped wheel. This makes a wide turn.

Range: -100 to 100

Parameter Explanation Acceptable Input
direction The direction to turn.
(default: right)
right
left
speed The speed to move turn at.
(default: 75)
-100 to +100
Default Usage and Sample
swingTurn();  // swing turn right at speed 75 (default)
wait();
stop();
Usage and Sample with Parameters
swingTurn(left, 50);  // swing turn LEFT at speed 50
wait(0.75);           // wait 0.75 seconds
stop();               // stop


stop

void stop()
Stop.png (void) Both wheels do not move, causing the robot to stop.
Default Usage and Sample
forward();
wait();
stop();     // stop the robot
Usage and Sample with Parameters
forward(50);  // move forward at speed 50
wait(2.0);    // wait 2.0 seconds
stop();       // stop


lineTrackForTime

void lineTrackForTime(float trackTime = 5.0, int threshold = 45, tSensors sensorPort = S3)
LineTrackTime.png (void) The robot will track a black line on a white surface for a specified time in seconds.

Threshold Range: (dark) 0 to 100 (light)

Acceptable Sensors: sensor ports 1 through 4 (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.#### 0.0000 to +2,048.0000
0.### 0.000 to +32,768.000
0.## 0.00 to +262,144.00
0.# 0.0 to +2,097,200.0
threshold The threshold to compare colors against.
(default: 45)
0 to +100
sensorPort The sensor port to use for the light sensor.
(default: S3)
S1
S2
S3
S4
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 45 and a 
                        light sensor in port S3 (default) */
stop();
Usage and Sample with Parameters
lineTrackForTime(7.5, 25, S1);  /* track a black line for 7.5 seconds, 
                                   using a threshold of 25 and a 
                                   light sensor in port S1 */
stop();                         // stop


lineTrackForRotations

void lineTrackForRotations(float rotations = 3.0, int threshold = 45, tSensors sensorPort = S3)
LineTrackDist.png (void) The robot will track a black line on a white surface for a specified distance in rotations.

Threshold Range: (dark) 0 to 100 (light)

Acceptable Sensors: sensor ports 1 through 4 (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: 45)
0 to +100
sensorPort The sensor port to use for the light sensor.
(default: S3)
S1
S2
S3
S4
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 45 and a 
                             light sensor in port S3 (default) */
stop();
Usage and Sample with Parameters
lineTrackForRotations(4.75, 25, S1);  /* track a black line for 4.75 rotations, 
                                         using a threshold of 25 and a 
                                         light sensor in port S1 */
stop();                               // stop


moveStraightForTime

void moveStraightForTime(float seconds = 5.0, tMotor rightEncoderPort = motorB, tMotor leftEncoderPort = motorC)
Move straight time.png (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: sensor ports 1 through 4 (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: 5.0)
Any floating point amount:
0.#### 0.0000 to +2,048.0000
0.### 0.000 to +32,768.000
0.## 0.00 to +262,144.00
0.# 0.0 to +2,097,200.0
rightEncoderPort The right-side motor encoder.
(default: motorB)
motorA
motorB
motorC
Or their names setup in Motors and Sensors Setup.
leftEncoderPort The left-side motor encoder.
(default: motorC)
motorA
motorB
motorC
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
moveStraightForTime();  /* move straight forward for 5.0 seconds, 
                           using motorB as the right-side encoder and
                           motorC as the left-side encoder (default) */
stop();
Usage and Sample with Parameters
moveStraightForTime(7.5, motorA, motorC);  /* move straight forward for 7.5 seconds, 
                                              using motorA as the right-side encoder
                                              and motorC as the left-side encoder */
stop();                                    // stop


moveStraightForRotations

void moveStraightForRotations(float rotations = 1.0, tMotor rightEncoderPort = motorB, tMotor leftEncoderPort = motorC)
Move straight dist.png (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: sensor ports 1 through 4 (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: 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
rightEncoderPort The right-side motor encoder.
(default: motorB)
motorA
motorB
motorC
Or their names setup in Motors and Sensors Setup.
leftEncoderPort The left-side motor encoder.
(default: motorC)
motorA
motorB
motorC
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
moveStraightForRotations();  /* move straight forward for 1.0 rotations, 
                                using motorB as the right-side encoder and
                                motorC as the left-side encoder (default) */
stop();
Usage and Sample with Parameters
moveStraightForRotations(4.75, motorA, motorC);  /* move straight forward for 4.75 rotations, 
                                                    using motorA as the right-side encoder
                                                    and motorC as the left-side encoder */
stop();                                          // stop


tankControl

void tankControl(short &rightJoystick = joystick.joy1_y2, short &leftJoystick = joystick.joy1_y1, short threshold = 10)
Tank control.png (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: joystick.joy1_y2)
Any joystick:
joy1_x1
joy1_x2
joy1_y1
joy1_y2
joy2_x1
joy2_x2
joy2_y1
joy2_y2
leftJoystick The joystick to use as the LEFT-side joystick.
(default: joystick.joy1_y1)
Any joystick:
joy1_x1
joy1_x2
joy1_y1
joy1_y2
joy2_x1
joy2_x2
joy2_y1
joy2_y2
threshold This variable eliminates 'noise' caused by joysticks not returning back to the exact center.
(default: 10)
0 to 100
Default Usage and Sample
while(true)
{ 
  tankControl();  /* control the robot in 'tank' fashion
                     with the RIGHT joystick as joy1_y2 and
                     the LEFT joystick as joy1_y1, with a
                     threshold of 10 (default) */
}
Usage and Sample with Parameters
while(true)
{ 
  tankControl(joystick.joy1_y1, joystick.joy1_y2, 5);  /* control the robot in 'tank' fashion
                                                          with the RIGHT joystick as joy1_y1 and
                                                          the LEFT joystick as joy1_y2, with a
                                                          threshold of 5 */
}


arcadeControl

void arcadeControl(short &verticalJoystick = joystick.joy1_y2, short &horizontalJoystick = joystick.joy1_y1, short threshold = 10)
Arcade control.png (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: joystick.joy1_y2)
Any joystick:
joy1_x1
joy1_x2
joy1_y1
joy1_y2
joy2_x1
joy2_x2
joy2_y1
joy2_y2
horizontalJoystick The joystick to use as the horizontal joystick.
(default: joystick.joy1_x2)
Any joystick:
joy1_x1
joy1_x2
joy1_y1
joy1_y2
joy2_x1
joy2_x2
joy2_y1
joy2_y2
threshold This variable eliminates 'noise' caused by joysticks not returning back to the exact center.
(default: 10)
0 to 100
Default Usage and Sample
while(true)
{ 
  arcadeControl();  /* control the robot in 'arcade' fashion
                       with the VERTICAL joystick as joy1_y2
                       and the HORIZONTAL joystick as joy1_x2,
                       with a threshold of 10 (default) */
}
Usage and Sample with Parameters
while(true)
{ 
  arcadeControl(joystick.joy1_y1, joystick.joy1_y2, 5);  /* control the robot in 'arcade' fashion
                                                            with the VERTICAL joystick as joy1_y1
                                                            and the HORIZONTAL joystick as joy1_y2,
                                                            with a threshold of 5 */
}


Until Functions

untilTouch

void untilTouch(tSensors sensorPort = S1)
Touch in.png (void) The robot does what it was doing until the touch sensor is pressed in.

Acceptable Sensors: sensor ports 1 through 4 (and your names for them given in Motors and Sensors Setup.)

Parameter Explanation Acceptable Input
sensorPort The sensor port to use for the light sensor.
(default: S1)
S1
S2
S3
S4
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilTouch();  // wait until the touch sensor in port S1 is pressed (default)
stop();
Usage and Sample with Parameters
forward(50);     // go forward at speed 50
untilTouch(S3);  // wait until the touch sensor in port S3 is pressed
stop();          // stop


untilRelease

void untilRelease(tSensors sensorPort = S1)
Touch out.png (void) The robot does what it was doing until the touch sensor is released.

Acceptable Sensors: sensor ports 1 through 4 (and your names for them given in Motors and Sensors Setup.)

Parameter Explanation Acceptable Input
sensorPort The sensor port to use for the light sensor.
(default: S1)
S1
S2
S3
S4
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilRelease();  // wait until the touch sensor in port S1 is released (default)
stop();
Usage and Sample with Parameters
forward(50);       // go forward at speed 50
untilRelease(S3);  // wait until the touch sensor in port S3 is released
stop();            // stop


untilBump

void untilBump(tSensors sensorPort = S1, int delayTimeMS = 10)
Touch bump.png (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: sensor ports 1 through 4 (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: S1)
S1
S2
S3
S4
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 S1 is pressed and 
                 then released with a delay time of 10 milliseconds (default) */
stop();
Usage and Sample with Parameters
forward(50);         // go forward at speed 50
untilBump(S3, 100);  /* wait until the touch sensor in port S3 is pressed and 
                        then released with a delay time of 100 milliseconds */
stop();              // stop


untilSonarGreaterThan

void untilSonarGreaterThan(short distance = 30, tSensors sensorPort = S4)
Sonar greater.png (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 254 (A value of 255 means it cannot detect anything.)

Acceptable Sensors: sensor ports 1 through 4 (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 255.
sensorPort The sensor port to use for the sonar sensor.
(default: S4)
S1
S2
S3
S4
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilSonarGreaterThan();  /* wait until the sonar sensor in port S4 detects
                             an object farther than 30cm away (default) */
stop();
Usage and Sample with Parameters
forward(50);                    // go forward at speed 50
untilSonarGreaterThan(45, S2);  /* wait until the sonar sensor in port S2
                                   detects an object farther than 45cm away */
stop();                         // stop


untilSonarLessThan

void untilSonarLessThan(short distance = 30, tSensors sensorPort = S4)
Sonar less.png (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 254 (A value of 255 means it cannot detect anything.)

Acceptable Sensors: sensor ports 1 through 4 (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 closer than to count
(default: 30)
Any whole integer amount from 0 to 255.
sensorPort The sensor port to use for the sonar sensor.
(default: S4)
S1
S2
S3
S4
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilSonarLessThan();  /* wait until the sonar sensor in port S4 detects
                          an object closer than 30cm away (default) */
stop();
Usage and Sample with Parameters
forward(50);                 // go forward at speed 50
untilSonarLessThan(45, S2);  /* wait until the sonar sensor in port S2
                                detects an object closer than 45cm away */
stop();                      // stop


untilSoundGreaterThan

void untilSoundGreaterThan(int threshold = 50, tSensors sensorPort = S2)
Sound greater.png (void) The robot does what it was doing until the sound sensor reads a value greater than a set threshold level.

Range: (quiet) 0 to 100 (loud)

Acceptable Sensors: sensor ports 1 through 4 (and your names for them given in Motors and Sensors Setup.)

Parameter Explanation Acceptable Input
threshold The threshold value that
a sound must be louder than to count
(default: 50)
Any whole integer amount from 0 to 100.
sensorPort The sensor port to use for the sonar sensor.
(default: S2)
S1
S2
S3
S4
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilSoundGreaterThan();  /* wait until the sound sensor in port S2
                             detects a sound louder than 50 (default) */
stop();
Usage and Sample with Parameters
forward(50);                    // go forward at speed 50
untilSoundGreaterThan(85, S3);  /* wait until the sound sensor in port
                                   S3 detects a sound louder than 85 */
stop();                         // stop


untilSoundLessThan

void untilSoundLessThan(int threshold = 50, tSensors sensorPort = S2)
Sound less.png (void) The robot does what it was doing until the sound sensor reads a value less than a set threshold level.

Range: (quiet) 0 to 100 (loud)

Acceptable Sensors: sensor ports 1 through 4 (and your names for them given in Motors and Sensors Setup.)

Parameter Explanation Acceptable Input
threshold The threshold value that
a sound must be quieter than to count
(default: 50)
Any whole integer amount from 0 to 100.
sensorPort The sensor port to use for the sonar sensor.
(default: S2)
S1
S2
S3
S4
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilSoundLessThan();  /* wait until the sound sensor in port S2
                          detects a sound quieter than 50 (default) */
stop();
Usage and Sample with Parameters
forward(50);                 // go forward at speed 50
untilSoundLessThan(15, S3);  /* wait until the sound sensor in port
                                S3 detects a sound quieter than 15 */
stop();                      // stop


untilButtonPress

void untilButtonPress(short button = centerBtnNXT)
Press right.png (void) The robot does what it was doing until a button on the NXT is pressed.

Acceptable Buttons: centerBtnNXT, rightBtnNXT, leftBtnNXT

Parameter Explanation Acceptable Input
button The button to press.
(default: centerBtnNXT)
centerBtnNXT
rightBtnNXT
leftBtnNXT
Default Usage and Sample
forward();
untilButtonPress();  /* wait until the center button
                        is pressed on the NXT LCD (default) */
stop();
Usage and Sample with Parameters
forward(50);                    // go forward at speed 50
untilButtonPress(rightBtnNXT);  /* wait until the right button
                                   is pressed on the NXT LCD */
stop();                         // stop


untilLight

void untilLight(int threshold = 30, tSensors sensorPort = S3)
Until light.png (void) The robot does what it was doing until the light sensor reads a value lighter than the threshold.

Range: (light) 0 to 100 (dark)

Acceptable Sensors: sensor ports 1 through 4 (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: 30)
Any whole integer amount from 0 to 100.
sensorPort The sensor port to use for the sonar sensor.
(default: S3)
S1
S2
S3
S4
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilLight();  /* wait until the light sensor in port S3
                  detects an object lighter than 30 (default) */
stop();
Usage and Sample with Parameters
forward(50);         // go forward at speed 50
untilLight(75, S1);  /* wait until the light sensor in port S1
                        detects an object lighter than 75 */
stop();              // stop


untilDark

void untilDark(int threshold = 30, tSensors sensorPort = S3)
Until dark.png (void) The robot does what it was doing until the light sensor reads a value darker than the threshold.

Range: (light) 0 to 100 (dark)

Acceptable Sensors: sensor ports 1 through 4 (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: 30)
Any whole integer amount from 0 to 100.
sensorPort The sensor port to use for the sonar sensor.
(default: S3)
S1
S2
S3
S4
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilDark();  /* wait until the light sensor in port S3
                 detects an object darker than 30 (default) */
stop();
Usage and Sample with Parameters
forward(50);        // go forward at speed 50
untilDark(75, S1);  /* wait until the light sensor in port S1
                       detects an object darker than 75 */
stop();             // stop


untilRotations

void untilRotations(float rotations = 1.0, tMotor motorPort = motorB)
Rotations.png (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 Encoders: motor ports A through C (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
motorPort The motor encoder to use.
(default: motorB)
motorA
motorB
motorC
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilRotations();  /* wait until the motor encoder on
                      motorB counts 1.0 rotations (default) */
stop();
Usage and Sample with Parameters
forward(50);                   // move forward at speed 50
untilRotations(2.75, motorA);  /* wait until the motor encoder on
                                  motorA counts 2.75 rotations */
stop();                        // stop


untilEncoderCounts

void untilEncoderCounts(long distance = 360, tMotor motorPort = motorB)
Encoder counts.png (void) The robot does what it was doing until the motor encoder rotations match the desired value.

Range: -2,147,483,648 to +2,147,483,647

Acceptable Encoders: motor ports A through C (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.
motorPort The motor encoder to use.
(default: motorB)
motorA
motorB
motorC
Or their names setup in Motors and Sensors Setup.
Default Usage and Sample
forward();
untilEncoderCounts();  /* wait until the motor encoder on
                          motorB counts 360 ticks (default) */
stop();
Usage and Sample with Parameters
forward(50);                      // move forward at speed 50
untilEncoderCounts(990, motorA);  /* wait until the motor encoder on
                                     motorA counts 990 ticks (default) */
stop();                           // stop


Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox