Navigator, Pilot, PoseProvider, coordinate System questions

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

Moderators: roger, gloomyandy, skoehler

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

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby gloomyandy » Sat Aug 20, 2016 12:00 pm

The DiffernetialPilot has been replaced, it will still work, but there is a newer set of classes that do the same sort of thing but which can be used with a wider collection of robots. See:
https://lejosnews.wordpress.com/2015/05 ... e-chassis/

See:
http://www.lejos.org/ev3/docs/index.htm ... Pilot.html
http://www.lejos.org/ev3/docs/lejos/rob ... assis.html

As I said you can continue to use the DiffernetialPilot but at some point we will no longer update it.
leJOS news https://lejosnews.wordpress.com/

RoboRobo
Novice
Posts: 29
Joined: Sat Jun 18, 2016 2:10 pm

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby RoboRobo » Sun Aug 21, 2016 11:26 am

I'll provide a bit more information. DifferentialPilot works itself as well as OdometryPoseProvider. But still, nothing happens when used with Navigator.
The code is really primitive:

Code: Select all

      final double Diam = DifferentialPilot.WHEEL_SIZE_EV3;
      final double Trackwith = 23;
      
      EV3LargeRegulatedMotor Motor_Left = new EV3LargeRegulatedMotor(MotorPort.B);
      EV3LargeRegulatedMotor Motor_Right = new EV3LargeRegulatedMotor(MotorPort.D);
      
      DifferentialPilot Cool_Nav = new DifferentialPilot(Diam, Trackwith, Motor_Left, Motor_Right);
      Cool_Nav.setLinearSpeed(5);
      Cool_Nav.setAngularSpeed(15);
      
      Navigator Nav = new Navigator(Cool_Nav);
      Nav.goTo(100, 100);
      

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

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby gloomyandy » Sun Aug 21, 2016 11:56 am

Can't be 100% sure but what does your program do after calling goTo? The goTo call is non blocking so you need to wait for the movement to complete. If your program exits then it is likely nothing will happen. Try adding a call to waitForStop after the goTo. If things are still not working then you should be able to debug things using the standard remote debug capabilities. Remember you can always look at the source code if you need to understand things better:
https://sourceforge.net/p/lejos/ev3/cod ... gator.java
Looking at this it is easy to see that gotTo (which in turn calls followPath) is non blocking.
leJOS news https://lejosnews.wordpress.com/

RoboRobo
Novice
Posts: 29
Joined: Sat Jun 18, 2016 2:10 pm

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby RoboRobo » Sun Aug 21, 2016 12:37 pm

Thanks, gloomyandy, when I added waitForStop, Navigator works fine! Also I am thankful for the links you provided, I need to understand those things more deeply...

RoboRobo
Novice
Posts: 29
Joined: Sat Jun 18, 2016 2:10 pm

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby RoboRobo » Sun Jun 18, 2017 6:18 pm

Hi,

I placed simple code, use version 0.9.1-beta:

Wheel wheel1 = WheeledChassis.modelWheel(new EV3LargeRegulatedMotor(MotorPort.B), 4.32).offset(11.5).invert(true);
Wheel wheel2 = WheeledChassis.modelWheel(new EV3LargeRegulatedMotor(MotorPort.D), 4.32).offset(-11.5).invert(true);
Chassis chassis = new WheeledChassis(new Wheel[] { wheel1, wheel2 }, WheeledChassis.TYPE_DIFFERENTIAL);

MovePilot pilot = new MovePilot(chassis);
Navigator navigator = new Navigator(pilot);
navigator.goTo(10, 10);

The problem is that Navigator does not work at all, I can't execute any method, my program does nothing.
Did I miss something?

Thank you in advance for your help!

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

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby gloomyandy » Sun Jun 18, 2017 7:05 pm

Does your MovePilot work? Have you tested that?
Are you running this code directly on the EV3 or is it on a PC?
What does your code do after the call to goto? goto is non-blocking so you may need to call one of the wait methods (like waitForStop) to prevent your program simply exiting (which will stop the motors).
leJOS news https://lejosnews.wordpress.com/

RoboRobo
Novice
Posts: 29
Joined: Sat Jun 18, 2016 2:10 pm

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby RoboRobo » Mon Jun 19, 2017 9:01 am

Thanks, gloomyandy, missing waitForStop was the issue.

RoboRobo
Novice
Posts: 29
Joined: Sat Jun 18, 2016 2:10 pm

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby RoboRobo » Tue Jun 20, 2017 5:00 pm

Hi,

I was trying to develop some kind of cyclical robot movement, but had some problems and those problems had been the same with the following simple example:

Code: Select all

 navigator.addWaypoint(0, -20, 0);
         navigator.addWaypoint(10, -20, 0);
         navigator.addWaypoint(10, 20, 0);
         navigator.addWaypoint(20, 20, 0);
         navigator.addWaypoint(20, -20, 0);
         navigator.addWaypoint(0, 0, 0);
         navigator.addWaypoint(20, -20, 0);
         
         navigator.followPath();
        navigator.waitForStop();
       
       navigator.clearPath();
         


Or when addWaypoint was replaced with goTo.
If I launch the program for the first time, everything works as it should. However, when launching the code again, counting from the third or fourth step my robot starts to move almost randomly at turning points. Did i make something totally wrong when writing the code?

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

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby gloomyandy » Wed Jun 21, 2017 6:47 am

Sorry I have no idea. Those waypoints do seem very close together though given the size of your robot. I'm not really sure what pattern of movement I would expect to see. It looks like your robot has a wheelbase of 22cm is this correct? Have you tried making the robot move over a larger distance? Perhaps if you post a video with the expected path marked on the floor it would be easier to understand what is going on?
leJOS news https://lejosnews.wordpress.com/

RoboRobo
Novice
Posts: 29
Joined: Sat Jun 18, 2016 2:10 pm

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby RoboRobo » Wed Jun 21, 2017 8:37 am

Here are my chassis inputs:

Wheel wheel1 = WheeledChassis.modelWheel(new EV3LargeRegulatedMotor(MotorPort.B), 4.32).offset(11.5).invert(true);
Wheel wheel2 = WheeledChassis.modelWheel(new EV3LargeRegulatedMotor(MotorPort.D), 4.32).offset(-11.5).invert(true);
Chassis chassis = new WheeledChassis(new Wheel[] { wheel1, wheel2 }, WheeledChassis.TYPE_DIFFERENTIAL);

I tried your proposal to increase length of travel distance, and it seemed it worked few times in a row. However, I also tried to return back to a code where inputs from OdometryPoseProvider are saved into file, and then the problem came back also. Here is an example of my loop and the log of robot position, maybe it could tell as much as video.

Code: Select all

navigator.goTo(0, -20, 0);
            navigator.waitForStop();

         x = 0;
            y = -20;
            z = 0;
         
         for (i = 0; i <= ; i ++) {
         
            x = x + 10;
                 
            navigator.goTo(x, y, z);
            navigator.waitForStop();
         
           LCD.clear(3);
            LCD.drawString("P " + pp.getPose(), 0, 3);
         
            Last_Pose = pp.getPose().toString();
           Rec.PP();
         
            y = y * (-1);
         
            navigator.goTo(x, y, z);
            navigator.waitForStop();
         
           LCD.clear(3);
           LCD.drawString("P " + pp.getPose(), 0, 3);
         
         }
                
         navigator.goTo(0, 0, 0);
         navigator.waitForStop();
         
         Last_Pose = pp.getPose().toString();
         Rec.PP();
         
        navigator.goTo(pp.getPose().getX(), pp.getPose().getY(), pp.getPose().getHeading());
        navigator.waitForStop(); //way to the last measured position
         
         Last_Pose = pp.getPose().toString();
        Rec.PP();
         
         Last_Pose = "---------------";
         Rec.PP();
         


And below you may find output (3 times) from OdometryPoseProvider of the code above:

X:0 Y:0 H:0
X:20 Y:0 H:0
X:20 Y:0 H:0
X:20 Y:10 H:90
X:-20 Y:20 H:90
X:20 Y:20 H:0
X:49 Y:-8 H:-134
---------------
X:0 Y:0 H:0
X:0 Y:0 H:-90
X:0 Y:0 H:-90
X:-0 Y:-22 H:-90
X:-31 Y:27 H:122
X:-5 Y:-2 H:-135
X:-9 Y:-5 H:-45
---------------
X:0 Y:0 H:0
X:0 Y:0 H:-90
X:0 Y:0 H:-90
X:20 Y:10 H:26
X:-40 Y:10 H:180
X:-10 Y:-10 H:-135
X:-0 Y:-20 H:-45

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

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby gloomyandy » Wed Jun 21, 2017 9:30 am

Sorry I can't make any sense of what that code is doing or how the results relate to it.

You still seem to be making what seems to me very small move requests (only 10 or 20cm or so), those are very short moves for a robot to that is the size of yours to make without getting all sorts of errors. Also remember that you may need to calibrate your robot to get accurate turns and distance moves. Try just getting it to drive a large square, this will show you how accurate your turns are, if you tape out the square on the floor (say 1m sides) you get a much better feel for how things are working.
leJOS news https://lejosnews.wordpress.com/

RoboRobo
Novice
Posts: 29
Joined: Sat Jun 18, 2016 2:10 pm

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby RoboRobo » Wed Jun 21, 2017 11:16 am

The problem is that the same code provides completely different output from Pose provider. I'll definitely try this with longer distances, but I have troubles not with accuracy of movement, but sometimes opposite turns at all :)

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

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby gloomyandy » Wed Jun 21, 2017 3:08 pm

You need to be careful when you are specifying the pose remember that it includes an element that defines the direction the robot is facing. Perhaps that is causing you some problems?

Remember that you have all of the leJOS source code and with Eclipse you have a powerful remote debug tool. There is nothing to stop you from using them to work out what is going on...
leJOS news https://lejosnews.wordpress.com/

RoboRobo
Novice
Posts: 29
Joined: Sat Jun 18, 2016 2:10 pm

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby RoboRobo » Wed Jun 21, 2017 5:34 pm

Well, I have very little experience with programming Java, so any efforts to get deeper into solving this problem look really challenging for me. Even pose provider has stopped to work for me despite it worked before, I just uncommented code lines :) However, I'll try to go step by step through this task and maybe I'll be able to find from which point the problem starts. Anyway, many thanks for your help!

Aswin
leJOS Team Member
Posts: 310
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands
Contact:

Re: Navigator, Pilot, PoseProvider, coordinate System questions

Postby Aswin » Wed Jun 21, 2017 11:26 pm

Hi,

Could you write and run a simple program for me? One that instructs the robot to go from origin to x=20, y=0, z=0. Make it print these numbers and then print the results from the pose provider. Tell me where it actually is *you need to measure!). Then goto x=20, y=20, z=0. Again print the input and result from the pose provider and measure where it is.

Aswin
My NXT blog: http://nxttime.wordpress.com/


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 3 guests