4

Does anyone know how to make an exact 16 degree turn with a LEGO robot?

2 Answers 2

7

This is actually a surprisingly difficult task. If you search for similar questions over on the Robotics stack exchange, you will find very smart people who can't even get it right with thousand-dollar localization solutions and graduate-level control theory.

If you have a Gyro sensor like Michael suggested, you're on the right track. You can probably get close to 16 degrees with that.

If you don't have a Gyro sensor, you can use the motors' built-in rotation sensors. If you drive the motors in opposite directions, the robot rotates around the point halfway between the wheels, and the formula is:
enter image description here
Where:

  • r_wheel is the radius of your robot's wheels
  • theta_wheel is the angle the wheel has to move
  • r_robot is the radius of the robot (half of the distance between the two wheels)
  • theta_robot is the angle you want the entire robot to turn, in this case 16 degrees.

So measure the radius of the wheel and the robot, plug in 16 degrees for theta_robot, and solve for theta_wheel. Then drive one motor forward theta_wheel degrees, and one motor backward theta_wheel degrees (simultaneously).

Bonus points if you make a MyBlock to have the EV3 do the calculation itself, for any desired theta_robot.

Actually even if you do have the gyro I would recommend trying both to see which gives better results for your specific situation.

2
  • 1
    I think the reason people struggle with this task is due to the difference between maths and the real world - you also need to take into account slippage of the wheels on the surface, play within the components, and so on ;) Oct 31, 2018 at 8:19
  • 1
    @Zhaph-BenDuguid Oh definitely. There's too many unknown variables affecting robot motion, and they add up to bigger and bigger error over time. Generally this task would be done using a Kalman filter, fusing the sensor readings from the motor encoders with an IMU and a compass. Such a task is totally doable with Mindstorms but is more than likely out of the scope of this question.
    – MindS1
    Nov 1, 2018 at 1:52
3

Do you have a gyro sensor on your robot? I'm assuming you're using an EV3 set, and the Mindstorms programming environment.

If so, reset your gyro sensor, and then insert a loop block attached to the gyro sensor. Set the loop settings to >= 16 degrees, and insert a tank move block into the loop. The motor should be set to 'on', with wheels going in opposite directions; the speeds should be relatively low to more accurately stop at your chosen degree setting. After the loop, be sure to insert a stop, or the robot will keep rotating.

m.enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.