RoboCatz.com

Turning

There are three types of turning:
  1. Point Turn
  2. Swing Turn
  3. Gradual Turn

Point Turn

In a Point Turn both wheels turn. However, they are turning in opposite directions. The wheels will trace a circular path in which the diameter is equal to the distance between the wheels.

What if you wanted the robot to make a 90 degree turn? How many times does each wheel have to rotate?
What if you wanted the robot to make a 180 degree turn? How many times does each wheel have to rotate?

There are a couple of ways you could determine how many rotations of the wheel is needed:

  1. View Mode The NXT Brick supports a "View Mode" which lets you move (push) the robot and the rotations would be shown on the LCD screen.
  2. Trial and Error You could enter different values for the motor to turn until you found the value that makes the robot do what you wanted it to do.
  3. Simple Algebra/Geometry You can find out the circumference of the circle of that the wheels make (see the drawing). This circumference is equal to PI (3.14159) times the distance between the two drive wheels on the robot. Now divide this product by the circumference of the wheel. The circumference of the wheel is equal to PI (3.14159) times the diameter of the wheel. The diameter of each wheel is printed on the side of the wheel.
  4. Algebra/Geometry with help from some Programming This method takes advantage of the power of computer programs to simplify your tasks. In this method, a small program (subroutine, MyBlock, function) would convert a desired degree of rotation for the robot into specific rotations of the motors.
You can determine the number of degrees to turn using simple Algebra. Divide circumference of the wheel into the product of PI times the distance between the wheels.

Let's take a look at a working example. If the distance between the two wheels on your robot is 117 millimeters, we can then multiply that number by PI (3.14159) to get the number of millimeters the tires will travel on the ground to get the robot to make a complete circle: 368 millimeters. If each tire itself has a diameter of 56 millimeters, then we know that each tire will travel (56 x 3.14) 176 millimeters when the tire makes one complete rotation on its axle. Therefore, it will take (368/176) 2.1 rotations of each axle to make the robot make 1 complete turn.

If we only want the robot to turn 90 degrees (1/4th of a complete turn), we would need to rotate each wheel only 1/4th of 2.1 which is 0.52 rotations. We can then tell the robot to turn each wheel 0.52 rotations (in opposite directions) to get the robot to make a 90 degree turn.

Programming in NXT-G

If you are programming in NXT-G and you want to make the robot perform a point turn, use the "Move" block and slide the steering pointer to the left or right side (see image). Then enter the number of rotations or degrees for each wheel to turn.

Using the Move block in this way to make a point turn is very simple and is often used by students who are just learning about robotics. If you are competing in FLL tournaments and wish to show your skills in programming, you may want to try using MyBlocks to allow you to more quickly develop programs and harness the power of the programming language.

Using MyBlocks in Programming Point-Turns in NXT-G

A MyBlock is a subroutine (or function) written in NXT-G that enables you to store/execute a variety of actions or programming steps within just one (user defined) block known as a "MyBlock". An example of a MyBlock for a Point Turn could be:


In this example, the MyBlock created has two input values: power level and degrees. The degrees entered here would be the degrees that you want the robot to turn. The MyBlock will multiple the input degrees by a "constant" (in this example the constant is 4.1) to determine how many degrees to rotate each wheel axle. Notice how the arrow on the B-Motor block is point down while the arrow on the C-Motor block is point up. This means that the two motors will move in opposite directions.


Programming in RobotC

void TurnRight(int turnDegrees, int power, bool KeepGoing) {
  float targetDegrees = (2 * centerOfWheelToCenterOfRobotMM * PI) /
    wheelCircumference * gearRatio * turnDegrees;
  targetDegrees = targetDegrees + nMotorEncoder[motorB];
  nSyncedMotors = synchBC; //motor B is the master, motor C is the slave
  if(KeepGoing) {
    bFloatDuringInactiveMotorPWM = true;  // coast or float
  } else {
    bFloatDuringInactiveMotorPWM = false; // brake
    nMotorEncoderTarget[motorB] = targetDegrees; // sets a target
  }
  nSyncedTurnRatio = -100; //motors move in opposite directions of one another
  motor[motorB] = power; //turns the motor on at specified power
  while(nMotorRunState[motorB] != runStateIdle &&
    nMotorRunState[motorB] != runStateHoldPosition &&
    nMotorEncoder[motorB] <= targetDegrees) {
    //continue to power motorB until the motor nMotorEncoderTarget position is reached
  }
  if(!KeepGoing) motor[motorB] = 0;  // turn the motor off.
  bFloatDuringInactiveMotorPWM = false; // brake
}
In RobotC you can synchronize the two wheels even if you want them to move in opposite directions. Just set the Turn Ratio value to -100 as in:

nSyncedTurnRatio = -100;

In the above example, the distance of each wheel to the center of the robot is stored in a single variable. You need to multiply this by 2 to get the diameter of the large circle that the wheels will make.


Swing Turn

In a Swing Turn ONLY ONE wheel actually turns. The other wheel is stopped completely. In this case, the wheel that turns will trace a circular path in which the diameter is equal to twice the distance between the wheels.

What if you wanted the robot to make a 90 degree turn? How many times does each wheel have to rotate?
What if you wanted the robot to make a 180 degree turn? How many times does each wheel have to rotate?



Gradual Turn