Waypoint inconsistency

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

New User
Posts: 2
Joined: Wed Nov 01, 2017 6:44 am

Waypoint inconsistency

Postby breakbeatkid » Wed Nov 01, 2017 4:22 pm

Hey, Im new here, please be kind! :D

Is there anyone that can shed some light on a problem I'm having with the navigator class and waypoints?

Code: Select all

import lejos.hardware.Brick;
import lejos.hardware.BrickFinder;
import lejos.hardware.Button;
import lejos.hardware.motor.EV3LargeRegulatedMotor;
import lejos.robotics.chassis.Chassis;
import lejos.robotics.chassis.Wheel;
import lejos.robotics.chassis.WheeledChassis;
import lejos.robotics.navigation.MovePilot;
import lejos.robotics.navigation.Navigator;

public class Waypoints {
   public static void main(String[] args) {
      Brick ev3 = BrickFinder.getDefault();

      //Set up pilot
      EV3LargeRegulatedMotor leftMotor = new EV3LargeRegulatedMotor(ev3.getPort("B"));
      EV3LargeRegulatedMotor rightMotor = new EV3LargeRegulatedMotor(ev3.getPort("C"));

      Wheel leftWheel = WheeledChassis.modelWheel(leftMotor, 3.3).offset(-10.3);
      Wheel rightWheel = WheeledChassis.modelWheel(rightMotor, 3.3).offset(10.3);
      Chassis myChassis = new WheeledChassis( new Wheel[]{leftWheel, rightWheel}, WheeledChassis.TYPE_DIFFERENTIAL);

      MovePilot pilot = new MovePilot(myChassis);
      Navigator navigator = new Navigator(pilot);
      String msg = "Enter to start...";

      navigator.addWaypoint(40, 0);
      navigator.addWaypoint(40, 40);
      navigator.addWaypoint(0, 40);
      navigator.addWaypoint(0, 0);

      while (!navigator.pathCompleted()) {            
         if(!navigator.isMoving()) {
            msg = "[" + navigator.getPoseProvider().getPose().getX() + ", " + navigator.getPoseProvider().getPose().getY() + "]\n";
//            Button.waitForAnyPress();
      msg = "[" + navigator.getPoseProvider().getPose().getX() + ", " + navigator.getPoseProvider().getPose().getY() + "]";
      msg = "Any key to finish...";


The issue i'm encountering is that there is no consistency across multiple executions of this code on my EV3. Some times it finishes close enough to be ok, but sometimes it turns to a random degree at different waypoints and sometimes it travels a random distance in the wrong direction. I'm at my wits end and deadlines are FAST approaching :(

It appears to be the same issue as was stated in this thread, but I can't see a clear solution in the whole post:

Correct (ish) outcome:

Randomly turns the wrong direction and gets lost:

Any suggestions?

New User
Posts: 2
Joined: Wed Nov 01, 2017 6:44 am

Re: Waypoint inconsistency

Postby breakbeatkid » Wed Nov 01, 2017 6:58 pm


Code: Select all

Navigator navigator = new Navigator(pilot, myChassis.getPoseProvider());

appears to have fixed it!

User avatar
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Waypoint inconsistency

Postby gloomyandy » Wed Nov 01, 2017 9:35 pm

Yes it seems there is a threading problem when using the standard pose provider that uses move notifications. The alternative pose provider (that monitors odometry), seemd to work fine. You can see the discussion of the bug here:

I don't think any fix has been made for this bug, so what you are doing is the current way to work around it.
leJOS news https://lejosnews.wordpress.com/

Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest