ROBOTC for MINDSTORMS - Robot Movement Functions  

ROBOTC Natural Language - TETRIX: (PDF) 

Robot Movement Functions:
Title Picture Description Default Usage and Sample Usage and Sample with Parameters

Forward Forward 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.)

forward(speed)
default speed: 75

forward();
wait();
stop();


forward(speed)
To go forward at speed 50 for 2.0 seconds:

forward(50);
wait(2.0);
stop();



Backward Backward 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.)

backward(speed)
default speed: -75

backward();
wait();
stop();


backward(speed)
To go backward at speed 50 for 2.0 seconds:

backward(50);
wait(2.0);
stop();



Point Turn Point Turn 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

pointTurn(direction, speed)
default direction: right
default speed: 75

pointTurn();
wait();
stop();

pointTurn(direction, speed)
To point turn left at speed 50 for 0.4 seconds:

pointTurn(left, 50);
wait(0.4);
stop();


Swing Turn Swing Turn 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

swingTurn(direction, speed)
default direction: right
default speed: 75

swingTurn();
wait();
stop();

swingTurn(direction, speed)
To swing turn left at speed 50 for 0.75 seconds:

swingTurn(left, 50);
wait(0.75);
stop();


Stop Stop Both wheels do not move, causing the robot to stop.

stop()

forward();
wait();
stop();


stop()

forward(50);
wait(2.0);
stop();



Line Track - For Time Line Track for Time 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.)

lineTrackForTime(time, threshold, sensorPort)
default time: 5.0 seconds
default threshold: 45
default sensors: S3

lineTrackForTime();
stop();


lineTrackForTime(time, threshold, sensorPort)
To track a line for 7.5 seconds, using a threshold of 25, with the line tracking sensor in port S1:

lineTrackForTime(7.5, 25, S1);
stop();



Line Track - For Rotations Line Track for Rotations 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.)

lineTrackForRotations(rot, threshold, sensorPort)
default rotations: 3.0 rotations
default threshold: 45
default sensors: S3

lineTrackForRotations();
stop();


lineTrackForRotations(rot, threshold, sensorPort)
To track a line for 4.7 rotations, using a threshold of 25, with the line tracking sensors in port S1:

lineTrackForRotations(4.75, 25, S1);
stop();



Move Straight
- For Time
Move Straight for Time 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.)

moveStraightForTime(time, rightEncoder, leftEncoder)
default time: 5.0 seconds
default motor encoders: motorB, motorC (Right, Left)

moveStraightForTime();
stop();


moveStraightForTime(time, rightEncoder,
leftEncoder
)
To move straight for 7.5 seconds, with the right motor encoder in motorA and the left motor encoder in motorC:

moveStraightForTime(7.5, motorA, motorC);
stop();



Move Straight
- For Rotations
Move Straight for Rotations 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.)

moveStraightForRotations(rot, rightEncoder, leftEncoder)
default rotations: 1.0 rotations
default motor encoders: motorB, motorC (Right, Left)

moveStraightForRotations();
stop();


moveStraightForRotations(rot, rightEncoder,
leftEncoder
)
To move straight for 4.75 rotations, with the right motor encoder in motorA and the left motor encoder in motorC:

moveStraightForRotations(4.75, motorA, motorC);
stop();



Tank Control Tank Control 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.

tankControl(rightJoystick, leftJoystick, threshold)
default joysticks: joystick.joy1_y2, joystick.joy1_y1 (Right, Left)

default threshold: 10

while(true)
{
  tankControl();
}


tankControl(rightJoystick, leftJoystick, threshold)
To remote control the robot using tank control with the right joystick as joy1_y2 and the left joystick as joy1_y2, with a threshold of 5:

while(true)
{
  tankControl ( joystick.joy1_y1 ,
  joystick.joy1_y2,5);
}



Arcade Control Arcade Control 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.

arcadeControl(verticalJoystick,
horizontalJoystick, threshold)
default joysticks: joystick.joy1_y2, joystick.joy1_x2 (Vertical, Horizontal)

default threshold: 10

while(true)
{
  arcadeControl();
}


arcadeControl(verticalJoystick,
horizontalJoystick, threshold)
To remote control the robot using arcade control with the vertical joystick as joy1_y1 and the horizontal joystick as joy1_x1 (arcade control with the left-side joystick) and a threshold of 5:



while(true)
{
  arcadeControl ( joystick.joy1_y1 ,
  joystick.joy1_y2,5);
}



Start Joystick Control Arcade Control This tells the program to enable joystick control.

startJoystickControl();
default joysticks; depends on user defined control style

startJoystickControl();
wait();
startJoystickControl();


startJoystickControl()
To enable remote control of the robot using whichever control structure is defined by the user (in this example, arcade style control) for 30 seconds then disable remote control.


arcadeControl();
startJoystickControl();
wait(30);
stopJoystickControl();



Stop Joystick Control Arcade Control This tells the program to disable joystick control.

stopJoystickControl();
default joysticks; depends on user defined control style

startJoystickControl();
wait();
stopJoystickControl();


stopJoystickControl()
To enable remote control of the robot using whichever control structure is defined by the user (in this example, arcade style control) for 30 seconds and then disable remote control.


arcadeControl();
startJoystickControl();
wait(30);
startJoystickControl();



(print me in landscape mode)

 

 


Copyright © 2012 Robotics Academy/Robomatter - http://robotc.net/