kirkpthompson wrote:Hi.
It appears to be in org.lejos.sample.rcnavmapper:
- Code: Select all
public void execute(int code, float v0, float v1, float v2, boolean immediate)
{
NavCommand command = NavCommand.values()[code]; // convert int to enum
LCD.clear();
LCD.drawString(command.toString(),0,0);
Sound.playTone(800 + 100 * code, 200);;
if(command == NavCommand.STOP)
{
pilot.stop();
nav.stop();
report(pp.getPose());
}
else if(command == NavCommand.GOTO )
{
nav.addWaypoint(new Waypoint(v0, v1));
_report = true;
detector.enableDetection(true);
}
else if(command == NavCommand.TRAVEL)
{
float distance = v0;
LCD.drawString("D " + Math.round(distance), 0, 2);
pilot.travel(distance, true);
_report = true;
detector.enableDetection(true);
}else if (command == NavCommand.ROTATE)
{
float angle = v0;
pilot.rotate(angle,true);
_report = true;
LCD.drawString("A " + Math.round(angle), 0, 2);
} else if (command == NavCommand.SETPOSE)
{
pp.setPose(new Pose(v0, v1, v2));
report(pp.getPose());
}
}
The source is installed with LeJOS on your machine or you can browse the SVN repos:
http://lejos.svn.sourceforge.net/viewvc/lejos/trunk/samples/src/org/lejos/sample/rcnavmapper/RCNavMapper.java?view=log-K
Thanks, sorry for not replying earlier but I was abroad. I have fixed the rotation by changing the track width (note that is far from the real one).
As for the go to command I have made several tries, but in all cases the result is the same and not the desired one. I will explain what I mean and at the end I will conclude 2 of my tries. When I set the initial robot pose to x=0, y=0 and heading=0, and I tell it to go to x=1 and y=0, it goes like a charm. The problem is that when I press again the goto button without changing anything (with x and y still being 1 and 0 respectively), the robot repeats its previous move (it moves forward 1 unit (in my case meters)). Thus, the robot, each time it stops, it sets its position to be the origin. I need a way for the robot to understand that it's already in x=1 and y=0 and doesn't need to move. Could you please help with that? Thanks.
Here are my tries:
//Try No1:
else if(command == NavCommand.GOTO )
{
nav.addWaypoint(new Waypoint(v0, v1));
nav.followPath();
_report = true;
detector.enableDetection(true);
}
//Try No2:
else if(command == NavCommand.GOTO )
{
nav.goTo(v0, v1);
_report = true;
detector.enableDetection(true);
}