DifferentialPilot and MotorPort together

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

Moderators: 99jonathan, roger, imaqine

DifferentialPilot and MotorPort together

Postby Philipp15b » Mon Nov 28, 2011 6:23 pm

Hello,

I'm experimenting with leJOS and I have ran into a problem: In my program, I want to use the DifferentialPilot together with MotorPort (for a line follower).
But it seems that the DifferentialPilot 'blocks' the motors, even if I call 'stop()' before controlling the motors with MotorPort, so that the motors dont move at all.

Code: Select all
...
pilot.stop();
while(true) {
if (light.readValue() > 34){
   // On white, turn left
   LCD.drawString("Turn left", 3, 3);
   MotorPort.B.controlMotor(50, 3);
   MotorPort.C.controlMotor(100, 1);
} else {
   // On black, turn right
   LCD.drawString("Turn right", 3, 3);
   MotorPort.B.controlMotor(100, 1);
   MotorPort.C.controlMotor(50, 3);
}
}
...


From the docs:
An object of this class assumes that it has exclusive control of its motors. If any other object makes calls to its motors, the results are unpredictable.


Is there any way to use them both?

Thank you,
Philipp
Philipp15b
New User
 
Posts: 6
Joined: Mon Nov 28, 2011 6:12 pm

Re: DifferentialPilot and MotorPort together

Postby sioux » Tue Nov 29, 2011 9:10 am

Hello Philipp.

I think that since you are using the differential pilot use the pilot's

arc() method, in which you define the arc that the turn will be plotted on.
Specifically, you provide the distance from the centre of your differential
to the centre of the arc and the motor speeds are adjusted automatically,
provided that you have set the differential pilot's measurements correctly.
sioux
New User
 
Posts: 8
Joined: Sun Nov 27, 2011 4:19 pm

Re: DifferentialPilot and MotorPort together

Postby Philipp15b » Tue Nov 29, 2011 6:55 pm

Thanks sioux, that worked well.
Philipp15b
New User
 
Posts: 6
Joined: Mon Nov 28, 2011 6:12 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff