Problem with simple arc moves

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

Moderators: roger, imaqine, 99jonathan

benjamin7
New User
Posts: 6
Joined: Tue Dec 13, 2011 4:49 pm

Problem with simple arc moves

Postby benjamin7 » Fri Mar 02, 2012 12:43 pm

According to both the leJOS NXT API documentation and Chapter 9 of 'Intelligence Unleashed', a pilot (robot) should travel a forward-directed, clockwise arc if the radius is negative and the angle is positive.

I tried to let my robot (the Carpet Pilot built in Intelligence Unleashed) travel the shape of the number eight, i.e., one full forward-directed, counter-clockwise circle, followed by a full forward-directed, clockwise circle. So I typed:

robot.arc(30, 360);
robot.arc(-30, 360);

The first circle was as expected. However, in the second circle the robot traveled counter-clockwise and backward instead of forward. I had to set both the radius and the angle negative to get a clockwise, forward-directed circle. Could someone please tell me, what I am doing wrong.

skoehler
leJOS Team Member
Posts: 1545
Joined: Thu Oct 30, 2008 4:54 pm

Re: Problem with simple arc moves

Postby skoehler » Fri Mar 02, 2012 1:06 pm

Have you tried robot.arc(30, -360); ? Which Pilot Class are you using? I'm not aware of the implementation of the "Carpet Pilot".

The implementation might have a bug. I will ask the other developers for a comment.

benjamin7
New User
Posts: 6
Joined: Tue Dec 13, 2011 4:49 pm

Re: Problem with simple arc moves

Postby benjamin7 » Fri Mar 02, 2012 4:10 pm

Thank you for your quick reply.

I have now tried all types of arc movements. When I set a positive radius, everything is fine: in combination with a positve/negative angle the robot travels forward/backward with the center of the circle left of the NXT.
When I set a negative radius, the center of the circle is right of the NXT (which is also fine), but the forward and backward directions are mixed up (negative angle -> forward (clockwise) movement, positive angle -> backward (counter-clockwise) movement. It should be the other way around.

I am using the DifferentialPilot class. The 'Carpet Pilot' is not a piece of implemented software but a real, physical robot. Its building instruction is in the book 'Intelligence Unleashed'. Sorry for the misunderstanding. I am using leJOS 0.9.1.

This is my complete code:
-----------------------------------------------------------------
package nxt.intelligence.unleashed;
import lejos.nxt.*;
import lejos.robotics.navigation.DifferentialPilot;

public class ArcMoves {

public static void main (String[] args) {
double diam = DifferentialPilot.WHEEL_SIZE_NXT1;
double width = 16.4;

DifferentialPilot robot = new DifferentialPilot(diam, width, Motor.B, Motor.C);

robot.setAcceleration(500);

robot.arc(30, 360); // OK
robot.arc(30, -360); // OK
// in the following two cases the center of the circle is right of
// the NXT but the forward/backward directions are mixed up
robot.arc(-30, 360); // the robot drives backward in a counter-clockwise circle
robot.arc(-30, -360);// the robot drives forward in a clockwise circle
Button.waitForAnyPress();
}
}
-----------------------------------------------------------------------------------

roger
Moderator
Posts: 372
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Re: Problem with simple arc moves

Postby roger » Sun Mar 04, 2012 7:34 am

Hi Benjamin,
The sign of the angle parameter has the same meaning in all methods of the DifferentialPilot class. A positive angle means that the heading increases, and a negative angle means that heading decreases. (Heading = the angle relative to the X axis of the direction in which the robot is heading.)
If the initial heading is zero, steer(30,-90) and steer(-30,-90) both result in the robot heading of -90 degrees.
So arc(-30,-360) will cause the robot to travel in a circle or radius 30, centered on the right side of the robot, and the heading angle will decrease from 0 to -360. The robot moves forward to do this.
Unfortunately, the JavaDocs for Differential Pilot are incorrect - I hope to make the correction soon.
Roger

benjamin7
New User
Posts: 6
Joined: Tue Dec 13, 2011 4:49 pm

Re: Problem with simple arc moves

Postby benjamin7 » Sun Mar 04, 2012 9:43 am

Hi Roger,
now I understand the meaning of the angle parameter and the behavior of my robot during arc moves. Thank you very much for your detailed explanation.


Return to “NXJ Software”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests