OdometryPoseProvider and Rotations

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

Moderators: roger, 99jonathan, imaqine

OdometryPoseProvider and Rotations

Postby FrootLoops » Thu Oct 18, 2012 12:44 pm

Hi there,

i'm working on a project using a DifferentialPilot and a OdometryPoseProvider. My Robot fits the specifications of the DifferentialPilot and is moving as intended. But the OdometryPoseProvider is another story:
For example let the robot travel for 25cm, rotate for 90 degrees to the right and travel for another 25cm:
Code: Select all
public static void main(String[] args) {
      DifferentialPilot pilot = new Pilot(56.0d, 120.0d, Motor.A ,Motor.B);
      OdometryPoseProvider opp = new OdometryPoseProvider(pilot);
      
      // set up
      pilot.setTravelSpeed(100);
      pilot.setRotateSpeed(25);
      // head out
      pilot.travel(250);
      pilot.rotate(-90);
      pilot.travel(250);
      
      Pose pose = opp.getPose();
      System.out.println(pose.getLocation());
      System.out.println(pose.getHeading());
   }

Output from println:
Point2D.Float[501.094, 1.6375242]
0.7520752

The PoseProvider seems to ignore the rotation, leading to wrong values. Further examples are leading to the same / similar results.
Since the OdometryPoseProvider registers as a listener to the MovePorvider, in this case the DifferentialPilot, it should be notified over each movement...
Have a look at this code-example now:
Code: Select all
public static void main(String[] args) {
      DifferentialPilot pilot = new Pilot(56.0d, 120.0d, Motor.A ,Motor.B);
      OdometryPoseProvider opp = new OdometryPoseProvider(pilot);
      
      // set up
      pilot.setTravelSpeed(100);
      pilot.setRotateSpeed(25);
      // head out
      Pose pose = opp.getPose();
      pilot.travel(250);
      pose = opp.getPose();
      pilot.rotate(-90);
      pose = opp.getPose();
      pilot.travel(250);
      pose = opp.getPose();
      
      System.out.println(pose.getLocation());
      System.out.println(pose.getHeading());
   }


Ouput from println:
Point2D.Float[247.7949, -250.77504]
-90.30627

This time i used getPose() to "manualy" call updatePose() ( which is declared as private in OdometryPoseProvider) after every move. And hey, the results match the movement.

Is this a bug? Is this working as intended? Am i missing something? This troubles me for a long time now, i hope someone can help me.
I'm working with lejos 0.9.1beta on a pc-project.

Regards and thx in advance :)

Edit:

While posting i did some further experiments:

Using the first code-exampe but with arc(0,-90) instead of rotate(-90), leads to fitting results. Using steer(200,-90) works correct, too.
And i took further looks at the implementation, and hey, is there a "else if"-section in OdometryPoseProvider.updatePose, handling Move.MoveType.ROTATE, missing ?
FrootLoops
New User
 
Posts: 2
Joined: Thu Oct 18, 2012 11:36 am

Re: OdometryPoseProvider and Rotations

Postby roger » Tue Oct 23, 2012 6:52 am

Hi FrootLoops,
I have run the first version of your code on the NXT and it behaves properly. The DifferentialPilot and OdometryPoseProvider classes were developed on the NXT to run on the NXT. It is possible that the bluetooth delay is causing the problem when you run the code in the PC. Since I never had a reason to run these classes on the PC, I am not sure this is cause of your problem.
Roger
roger
Moderator
 
Posts: 308
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Re: OdometryPoseProvider and Rotations

Postby FrootLoops » Thu Oct 25, 2012 3:47 pm

Hi and thx for your reply :)

I'm using the USB-cable because of this very reason you mentioned. No bluetooth here.

I have run the first version of your code on the NXT and it behaves properly.


Well, that's interesting, beacause it does not behave properly when i run it. But the workarround i posted works for me...i will simply use steer() and / or arc().

Thx so far, regards :)
FrootLoops
New User
 
Posts: 2
Joined: Thu Oct 18, 2012 11:36 am


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff