Differentialpilot over bluetooth delay

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

Moderators: roger, 99jonathan, imaqine

Differentialpilot over bluetooth delay

Postby maigel » Tue Oct 16, 2012 8:59 pm

Hi,

I'm currently using the Lejos eclipse plugin to create a PC project. This project sets up a bluetooth connection for me so I can remotly send commands to the NXJ.
Now I'm trying to write a program that allows me to use my arrow keys on my laptop to control the robot.
I tried using a DifferentialPilot object to send the forward(), backward(), etc messages. Where as this works, I can notice a pretty hard delay on it. When I press a key the robot starts moving 1 - 1.5 seconds later.

If I use a RemoteMotor object and write my own forward, rotate etc functions directly controlling the RemoteMotor's the delay is gone.

Though, I would prefer to use a differentialpilot, does anyone know what causes the delay/lag and how to fix it?
maigel
New User
 
Posts: 4
Joined: Tue Oct 16, 2012 8:55 pm

Re: Differentialpilot over bluetooth delay

Postby skoehler » Tue Oct 16, 2012 9:03 pm

If delay matters, don't control use DifferentialPilot on the PC, but instead write a program that runs locally on the NXT. Of course, that program can communicate with a program running on the PC.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: Differentialpilot over bluetooth delay

Postby maigel » Tue Oct 16, 2012 9:10 pm

So there's no way to fix the delay with only the program running on the pc?
maigel
New User
 
Posts: 4
Joined: Tue Oct 16, 2012 8:55 pm

Re: Differentialpilot over bluetooth delay

Postby skoehler » Tue Oct 16, 2012 9:47 pm

maigel wrote:So there's no way to fix the delay with only the program running on the pc?

Not really.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: Differentialpilot over bluetooth delay

Postby maigel » Wed Oct 17, 2012 12:03 am

What I don't get though, is when I use for example

Code: Select all
Motor.A.forward();
Motor.B.forward();


instead of
Code: Select all
pilot.forward();


to tell my robot to go forward, the first one with the motor's has a way lower delay
maigel
New User
 
Posts: 4
Joined: Tue Oct 16, 2012 8:55 pm

Re: Differentialpilot over bluetooth delay

Postby gloomyandy » Wed Oct 17, 2012 8:51 am

Not surprisingly this is probably because the Differential pilot version does a lot more than simply making the motors move forward. So perhaps you could reduce the delay by writing your own version of the pilot (after all you have the source code). But as Sven has already mentioned to get good real time control the best way will almost certainly be to have some of your code running on the NXT and use your own protocol between the PC and the NXT.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Differentialpilot over bluetooth delay

Postby maigel » Wed Oct 17, 2012 12:51 pm

Turns out it's the inbuilt motorlisteners in the differential pilot class causing the delay.

Thanks all for the help! :)
maigel
New User
 
Posts: 4
Joined: Tue Oct 16, 2012 8:55 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff