Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   FIRST Tech Challenge (http://www.chiefdelphi.com/forums/forumdisplay.php?f=146)
-   -   [FTC]: Lag and Teleop (Labview) (http://www.chiefdelphi.com/forums/showthread.php?t=87593)

wilsonmw04 22-11-2010 14:28

[FTC]: Lag and Teleop (Labview)
 
Greetings,

My team seems to be having a recurring issue. Every year we have to fight lag in our FTC robots. It seems to me that the robot isn't checking for the position of the controls often enough. The robot misses quick corrections while driving and may take up to 2 seconds to respond to commands.

My students are thinking that we are overloading the NXT with commands and the packets are being dropped. I am not sold on this explanation considering we are only using 1 touch sensor, 2 encoders, 4 DC motors (skid drive) 1 Lego motor and 6 servos. I have a hard time believing that our hardware is so... anemic that this would be too much for it.

So I have two questions: 1. Is anyone else having this issue? 2. Would someone with experience be willing to look at our code to see what is going on? (I will post it as soon as I can figure out how...)

wilsonmw04 22-11-2010 17:58

Re: [FTC]: Lag and Teleop (Labview)
 
1 Attachment(s)
Here is the code. I'm really looking for some Labview/NI support. However, if we can't find the cause of this lag we will be dropping Labview and going to robotC where we have heard there isn't this lag issue.

iblis432 22-11-2010 21:23

Re: [FTC]: Lag and Teleop (Labview)
 
To add to my mentor's post, we also experimented with a vi I found last year on the FTC forums known as Read Packet Flush.vi that replaced the read packet vi, in which it erased the inbox before accepting the next packet (least I think that is how it worked, the help file was a little lacking in the technical aspect). Last year this completely got rid of our lag for competition. This year I tried it with a vi of using only the drivetrain and it worked, however when I add the other code for the rest of the robot the lag seems to return.

My first idea is that the NXT is simply running too much code in each iterative and that it wasn't reading fast enough because of this, but I've seen teams with more complex setups than this, so I find it hard to believe. I understand that LABview is not as commonly used in FTC (least not from who we asked at competition last year), but help would be appreciated. The only idea I have left is run the NXT in two states, one for the first controller functions, one for the second, but i can't imagine this being easy or helping much.

aklego 22-11-2010 22:17

Re: [FTC]: Lag and Teleop (Labview)
 
Greetings,

Could you also post the HEY LOOK AT THIS!!!.vi? I'll go through your code and see it I can find some optimizations.

wilsonmw04 22-11-2010 22:19

Re: [FTC]: Lag and Teleop (Labview)
 
Umm Bobby,
Do we have they VI? ;-)

ProgramLuke 23-11-2010 08:16

Re: [FTC]: Lag and Teleop (Labview)
 
Could you post a picture of the code (I don't have access to LV right now).

PhilBot 23-11-2010 11:55

Re: [FTC]: Lag and Teleop (Labview)
 
Quote:

Originally Posted by wilsonmw04 (Post 981613)
Here is the code. I'm really looking for some Labview/NI support. However, if we can't find the cause of this lag we will be dropping Labview and going to robotC where we have heard there isn't this lag issue.

First...

You don't need to use "Read Packet Flush.vi" this year because the Samantha Module uses USB, which doesn't suffer the 5 packet buffer problems that Bluetooth does.

Next...

To drive your wheels you are running tank mode, and you have TWO Move MotorS (group) VIs, that are each controlling one wheel. That's OK, but you are using the "Multiple Motor" version of each one. So you are passing each one an array of motors, that only contains ONE motor. This will double your processing. I suggest changing these to single Move Motor VI's by clicking on the pull-down list below them and chosing "Move DC Motor" (Without the Group or Multi option). This will require that you also delete the Arrays of DC motors an inputs, and replace them with Single DC Motor inputs.

Finally

I suspect that your lags are really due to the MANY 0.7 second delays that you have in your servo processing code. Whenever you hit an arm function you are moving your servos and putting in a big delay. This delay will prevent the code from processing any new joystick inputs. Yeah... it will be sluggish.

The best way to do this (As shown in the templates) is to read the controls in one loop, and then share the button actions via local variables. Put your servo actions in another loop that can run independantly.

I also noticed that you have set your Message timeout to 10 Ms. (Going into FTC Robot Status). I can't imagine this is helping.
This tiemout is for detecting loss of link. 1000 ms Is more than adequate.

Phil.

iblis432 23-11-2010 12:02

Re: [FTC]: Lag and Teleop (Labview)
 
oddly, I totally forgot that the original template shows manipulators as being in a second loop, I will definiatly try that. As for the increase in the timeout, we found that the NXT kept switching between enabled and disabled without us doing anything to the FCS (we were using the Samantha module when this happened) and when we heightened the number, it stopped doing that. But again, that could be because we were processing so much. I will definiatly make those changes and test the robot with that ASAP. I am planning however to make a backup piece of code using RobotC, if that is ok with my mentor.

wilsonmw04 23-11-2010 12:04

Re: [FTC]: Lag and Teleop (Labview)
 
Excellent responses so far. Thanks!
We have our next meeting Saturday. This will give the programmers something to chew on.

iblis432 23-11-2010 13:37

Re: [FTC]: Lag and Teleop (Labview)
 
While working on the code i have a question that I was wondering if anyone knew. Is the NXT capable of handling flat sequence structures with multiple frames this year? I know in the past multiple frames were not allowed, but this year I'm not getting a broken vi icon on my run button, but I don't have the robot with me right this second so I don't know if it will maybe say something when I try to download the code.

iblis432 23-11-2010 15:23

Re: [FTC]: Lag and Teleop (Labview)
 
1 Attachment(s)
I have just finished a revised version of how teleop code. I think I've ironed out most of the problems, but I would like to submit it here for review while I'm waiting on a chance to work on the robot.

The zip file contains the revised version known as 0035 teleopstate.vi plus all the subvis. All of the comments and context help data is up to date, and the front panel contains information the vis.

Ether 23-11-2010 15:47

Re: [FTC]: Lag and Teleop (Labview)
 
1 Attachment(s)
Quote:

Originally Posted by iblis432 (Post 981747)
I have just finished a revised version of how teleop code. I think I've ironed out most of the problems, but I would like to submit it here for review while I'm waiting on a chance to work on the robot.

The zip file contains the revised version known as 0035 teleopstate.vi plus all the subvis. All of the comments and context help data is up to date, and the front panel contains information the vis.


See attached screen shot.

By saving the vi in LabVIEW9, you have significantly reduced the pool of people who would potentially be willing and able to help you.


iblis432 23-11-2010 16:02

Re: [FTC]: Lag and Teleop (Labview)
 
my understanding is that 2009 is the only version of labview you are allowed to use in FTC. I know when FTC first started with 8.5, but after that 2009 was what came in the kits. I have both versions on my computer, and if I have time i'll make a similar one in 8.5 if I find we are still having problems, otherwise I will keep the format in 2009 until I have a significant reason to change it.

Ether 23-11-2010 16:34

Re: [FTC]: Lag and Teleop (Labview)
 
1 Attachment(s)
Quote:

Originally Posted by iblis432 (Post 981754)
if I have time i'll make a similar one in 8.5

See attached screenshot.

You don't have to manually reconstruct the vi in a different version of LabVIEW.

Just use the "save for previous version" menu item from the File drop-down menu.




iblis432 23-11-2010 18:55

Re: [FTC]: Lag and Teleop (Labview)
 
I am not allowed to save it for a previous version because I do not have the password to save certain FTC toolkit vis.

The code was just tested on the robot however, and everything is working perfectly. It is all thanks to the suggestions here. Thanks so much.


All times are GMT -5. The time now is 18:43.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi