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 ?
