O'Reilly logo

Lego Mindstorms EV3 Essentials by Abid H. Mujtaba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The final version

We are now in a position to make a few major changes and arrive upon the final version of Controller, which is fully capable of autonomously following a multisegment path. Let me start by presenting the code in full, with the changes highlighted, and then I will explain the pertinent parts of the code.

Code (Controller.java)

We begin with the Controller class, the heart of the code, which is responsible for making the robot follow the path:

import lejos.hardware.Sound;
import lejos.hardware.port.Port;
import lejos.utility.Delay;

public class Controller
{
    private final static int DELAY = 50;

    private final static int SKIP_FORWARD = 20;

    private final static double DELAYS_PER_DEG = 100.0 / 180;

    private final static int SMALL_ROT = 10; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required