Go to Post Angry Teams will not get the field going any quicker trust me on that! - mtaman02 [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-04-2016, 21:37
Bradley Boxer's Avatar
Bradley Boxer Bradley Boxer is offline
Registered User
AKA: Bradley Boxer
FRC #0303 (TEST Team 303)
Team Role: Programmer
 
Join Date: May 2015
Rookie Year: 2015
Location: United States
Posts: 12
Bradley Boxer is an unknown quantity at this point
Exclamation Robot Drive Not Running Fast Enough - PLEASE HELP!

Our code this year (written in LabVIEW) runs really slow. Extremely slow. I have taken out all the refnums in teleop and in periodic tasks, but this did not seem to help. This would normally not be a problem, but we have several (4) PID loops update in teleop (running on CAN Talon SRX's), and if they are not updated every ~120ms they will tell the motor to stop spinning. Right now, teleop runs every ~100-200ms (measured with "Elapsed Times.vi"). This is a huge problem when we are shooting and need our two wheel motors to spin at exact and fast speeds. Although at this point in the season we aren't adding much code, the problem seems to be getting worse. It also may be worth noting that we are using the LabVIEW 2016 Vision Example to find the goal coordinates, although it is disabled with a global variable when not in use.

Does anyone have any fixes/ideas/suggestions/tips as to how to speed up our code?

Here is the link to Team 303's LabVIEW Robot Code if it helps anyone. Feel free to redistribute if you so please.

https://drive.google.com/file/d/0B9k...ew?usp=sharing

Thanks so much,
Bradley Boxer
Team 303 Programming

Last edited by Bradley Boxer : 12-04-2016 at 21:46. Reason: included link to code
Reply With Quote
  #2   Spotlight this post!  
Unread 13-04-2016, 00:33
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

I am unable to try out your code. You are using several Vis that are not included in your project or in the WPI library.

Are any error messages shown on the Driver Station message display? Catching and displaying errors slows down a LabVIEW program.

It looks like you are doing a lot of Talon SRX status checks in Teleop. Do those all need to take place every time a data packet arrives, or can you move some of the processing to Periodic Tasks?


Your Teleop is very busy and I'm finding it a little hard to follow without signposts. It all looks connected in a big collection of wires. Are there any functional groups that could be split out into individual SubVIs? That might clean up how the code looks and make it easier to understand.
Reply With Quote
  #3   Spotlight this post!  
Unread 13-04-2016, 08:09
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

@Alan - You need to install the NavX library to have his code load properly.

Looking at Teleop... Oh my...

There is a lot going on here. Forgive me if I miss something. Generally, when your code starts getting really complex, it's a good idea to start creating SubVIs. It makes the code a lot easier to understand.

I'm not seeing anything that stands out. The only Wait blocks you have are in Periodic Tasks, which is good.

Are you trying to run this as built code or by pressing Run on Robot Main? I've experienced slow downs when running Robot Main if I have too many running LabVIEW windows open. This occurs because it has to sync all the values from the robot back to the front panel, and the issue gets worse if your are probing values as well. I can see how having just the Teleop window open might cause it to lag since there are so many Front Panel controls and indicators to update.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
Reply With Quote
  #4   Spotlight this post!  
Unread 13-04-2016, 10:13
Greg McKaskle Greg McKaskle is online now
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

I didn't try to run your code, but just looked at it.

Please run the code and give some indication of CPU usage from the DS chart. If your usage is high while the robot is disabled, your periodic tasks may be running too fast or doing too much.

If teleOp has high CPU usage when the panel is open, it is because you have lots of debug info shown and updated frequently. When you run without opening the panel, it should be far better, and will be better still when built and deployed.

Don't forget that you can also put the Support Code/Elapsed Times into your teleOp code to see how often it runs. Your log file will also how how many of your teleOp control packets are not being processed.

Please post some more data and I'll be happy to make a suggestion.
Greg McKaskle
Reply With Quote
  #5   Spotlight this post!  
Unread 13-04-2016, 15:49
Bradley Boxer's Avatar
Bradley Boxer Bradley Boxer is offline
Registered User
AKA: Bradley Boxer
FRC #0303 (TEST Team 303)
Team Role: Programmer
 
Join Date: May 2015
Rookie Year: 2015
Location: United States
Posts: 12
Bradley Boxer is an unknown quantity at this point
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

Thanks guys for your help.

I split Teleop into a few more subVIs and used the clean-up-diagram button, so it should be more readable now. I also took out most of the debug indicators and controls, and necessary Talon SRX get status', since we don't need them anymore. We were running the code from a build-deploy, and we got "Not running fast enough" errors a few times every second as of yesterday.

I will test again today and post logs when I get to our workshop.

If you want to look at the new code:
https://drive.google.com/file/d/0B9k...ew?usp=sharing
I added the navx libraries this time.
Reply With Quote
  #6   Spotlight this post!  
Unread 15-04-2016, 07:46
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

Quote:
Originally Posted by Bradley Boxer View Post
Thanks guys for your help.

I split Teleop into a few more subVIs and used the clean-up-diagram button, so it should be more readable now. I also took out most of the debug indicators and controls, and necessary Talon SRX get status', since we don't need them anymore. We were running the code from a build-deploy, and we got "Not running fast enough" errors a few times every second as of yesterday.

I will test again today and post logs when I get to our workshop.

If you want to look at the new code:
https://drive.google.com/file/d/0B9k...ew?usp=sharing
I added the navx libraries this time.
I'm still not seeing anything that would ultimately cause the "Not running fast enough" errors. As The_Waffling said, you could replace that huge Refnum cluster to all the Joystick, Motor, Robot Drive, Solenoid, and Encoder Refnum_Get functions. If you're debugging, those controls will still get updated and that is quite a few front panel controls to update every 50ms. Keep in mind all of this is going over the network.

You should definitely check your CPU usage like Greg said. If you're running at 100%, that will likely cause you issues. You can easily check that using the Driver Station or you can Profile your program within LabVIEW while it's running on the target.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
Reply With Quote
  #7   Spotlight this post!  
Unread 15-04-2016, 08:42
Greg McKaskle Greg McKaskle is online now
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

The CPU and elapsed time of teleOp are hard numerical quantities that will help you diagnose if you have a problem, and what that problem likely is. It is like the doctor taking your temperature and blood pressure. If you don't measure these things, you may very well be trying to fix something that isn't broken or making something worse.

I glanced at your code and didn't see anything horrible. The next step is to measure. Without that, we quickly get into code poetry and opinions. I much prefer to stay on the engineering side of programming. So, please, when you have access to the log files or the robot, post the CPU usage for a couple robot modes. Look at or post some log files. And if you think you have an issue with teleOp, add the Elapsed times VI, run the code, start teleOp on the DS, and open the subVI to see what the elapsed time is.

Greg McKaskle
Reply With Quote
  #8   Spotlight this post!  
Unread 14-04-2016, 05:22
The_Waffleing's Avatar
The_Waffleing The_Waffleing is offline
The Horse Shaman
AKA: Mitchel
FRC #0753 (The High Desert Droids)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2012
Location: Bend
Posts: 32
The_Waffleing is an unknown quantity at this point
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

Quote:
Originally Posted by Bradley Boxer View Post
Our code this year (written in LabVIEW) runs really slow. Extremely slow. I have taken out all the refnums in teleop and in periodic tasks, but this did not seem to help. This would normally not be a problem, but we have several (4) PID loops update in teleop (running on CAN Talon SRX's), and if they are not updated every ~120ms they will tell the motor to stop spinning. Right now, teleop runs every ~100-200ms (measured with "Elapsed Times.vi"). This is a huge problem when we are shooting and need our two wheel motors to spin at exact and fast speeds. Although at this point in the season we aren't adding much code, the problem seems to be getting worse. It also may be worth noting that we are using the LabVIEW 2016 Vision Example to find the goal coordinates, although it is disabled with a global variable when not in use.

Does anyone have any fixes/ideas/suggestions/tips as to how to speed up our code?

Here is the link to Team 303's LabVIEW Robot Code if it helps anyone. Feel free to redistribute if you so please.

https://drive.google.com/file/d/0B9k...ew?usp=sharing

Thanks so much,
Bradley Boxer
Team 303 Programming
So one of things that you can do is remove all the get/set refnums in you're project and bundle them together like you have done but make it a type def. I'm currently busy with other things so I do apologize if I'm not going into very much detail, I'll sit down a write a proper response to your request however I will leave you with a link that another user had passed along to me when I was trying to optimize my code. Hope this helps!

http://frclabviewtutorials.com/teleop/
Reply With Quote
  #9   Spotlight this post!  
Unread 14-04-2016, 08:23
Greg McKaskle Greg McKaskle is online now
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

I looked at your updated code, and still don't see anything that scary. Moving the code into subVIs helps readability, but won't affect performance.

So do you have CPU numbers? Do you have a log file? Do you have an elapsed time for TeleOp?

The only thing that looks like it may be excessive is the amount of stuff you have inside the 10ms periodic task. Doing NavX and CAN status and quite a few network tables may add a pretty hefty background load which would be present even during disabled mode. So if we see the logs, I can know roughly what that takes.

Greg McKaskle
Reply With Quote
  #10   Spotlight this post!  
Unread 15-04-2016, 01:21
The_Waffleing's Avatar
The_Waffleing The_Waffleing is offline
The Horse Shaman
AKA: Mitchel
FRC #0753 (The High Desert Droids)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2012
Location: Bend
Posts: 32
The_Waffleing is an unknown quantity at this point
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

Quote:
Originally Posted by Greg McKaskle View Post
I looked at your updated code, and still don't see anything that scary. Moving the code into subVIs helps readability, but won't affect performance.

So do you have CPU numbers? Do you have a log file? Do you have an elapsed time for TeleOp?

The only thing that looks like it may be excessive is the amount of stuff you have inside the 10ms periodic task. Doing NavX and CAN status and quite a few network tables may add a pretty hefty background load which would be present even during disabled mode. So if we see the logs, I can know roughly what that takes.

Greg McKaskle
This might be a ridiculous question to ask but would finding a way to move the majority of this stuff to a state machine be of any use when trying to make the code efficient? I feel like there's a few things that could probably go without the constant update that the Teleop.vi has. Do point out if I'm wrong in this case. Also Bradley, I've noticed that there are some unused values in your teleop code that can be attributing to the whole clutter issue that is evident in the project overall; I would assess whether or not you need those values anymore. Great job on your code however I've had fun puzzling your code out and have been able to glean a few concepts from this that are rather interesting and will keep a note on them for next robotics season. I'll continue to with my efforts and will point out anything that I see that might want to be addressed.
Reply With Quote
  #11   Spotlight this post!  
Unread 18-04-2016, 03:00
The_Waffleing's Avatar
The_Waffleing The_Waffleing is offline
The Horse Shaman
AKA: Mitchel
FRC #0753 (The High Desert Droids)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2012
Location: Bend
Posts: 32
The_Waffleing is an unknown quantity at this point
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

Quote:
Originally Posted by Bradley Boxer View Post
Our code this year (written in LabVIEW) runs really slow. Extremely slow. I have taken out all the refnums in teleop and in periodic tasks, but this did not seem to help. This would normally not be a problem, but we have several (4) PID loops update in teleop (running on CAN Talon SRX's), and if they are not updated every ~120ms they will tell the motor to stop spinning. Right now, teleop runs every ~100-200ms (measured with "Elapsed Times.vi"). This is a huge problem when we are shooting and need our two wheel motors to spin at exact and fast speeds. Although at this point in the season we aren't adding much code, the problem seems to be getting worse. It also may be worth noting that we are using the LabVIEW 2016 Vision Example to find the goal coordinates, although it is disabled with a global variable when not in use.

Does anyone have any fixes/ideas/suggestions/tips as to how to speed up our code?

Here is the link to Team 303's LabVIEW Robot Code if it helps anyone. Feel free to redistribute if you so please.

https://drive.google.com/file/d/0B9k...ew?usp=sharing

Thanks so much,
Bradley Boxer
Team 303 Programming
Okay so after doing a lot of clean up in the teleop in order to see what's going on, I noticed that there are some values that are being written in teleop to global variables but never read anywhere else. Is there any particular reason for doing that. another thing that you can do for your begin.vi is replacing the write global variable that you have going with a funcional global variable (FGV) since the only place your are needing all that information is in autonomous. Like everyone else has said though check your CPU usage and try to locate any logs that might be pertinent to this issue. The logs will answer several questions.
Reply With Quote
  #12   Spotlight this post!  
Unread 19-04-2016, 09:11
aeastet aeastet is offline
Programming Mentor
AKA: Tim Easterling
FRC #6043 (Allegan Tigers Robotics)
Team Role: Coach
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Holland, MI
Posts: 116
aeastet is an unknown quantity at this point
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

I am working on a major upgrade to your code. Even if you choose not to use it you should look through it and try to learn from it. Do you have a place for me to put the code when I am done?
Reply With Quote
  #13   Spotlight this post!  
Unread 19-04-2016, 09:52
b1nary's Avatar
b1nary b1nary is offline
wasting my time, one line at a time
AKA: Josie
FRC #4329 (Roboteers)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2014
Location: st. louis
Posts: 22
b1nary is an unknown quantity at this point
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

we had an issue similar with our robot, trogdor. our autonomous wouldn't work one time because it was an issue with our talons. not with the coding itself, which everyone believed it to be, but the hardware.
Reply With Quote
  #14   Spotlight this post!  
Unread 20-04-2016, 08:39
aeastet aeastet is offline
Programming Mentor
AKA: Tim Easterling
FRC #6043 (Allegan Tigers Robotics)
Team Role: Coach
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Holland, MI
Posts: 116
aeastet is an unknown quantity at this point
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

Ok here is my first round. I have done a lot so I am not going to tell you everything should work on the first try. I am still working on autonomous and I will update that as soon as possible. I have a lot of it done already. I am also trying to make the code do what I think you are trying to get it to do. I am available for questions.

https://www.dropbox.com/home/2016CompRobotProject

Good Luck,

Tim
Reply With Quote
  #15   Spotlight this post!  
Unread 20-04-2016, 08:53
Bradley Boxer's Avatar
Bradley Boxer Bradley Boxer is offline
Registered User
AKA: Bradley Boxer
FRC #0303 (TEST Team 303)
Team Role: Programmer
 
Join Date: May 2015
Rookie Year: 2015
Location: United States
Posts: 12
Bradley Boxer is an unknown quantity at this point
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!

Quote:
Originally Posted by aeastet View Post
Ok here is my first round. I have done a lot so I am not going to tell you everything should work on the first try. I am still working on autonomous and I will update that as soon as possible. I have a lot of it done already. I am also trying to make the code do what I think you are trying to get it to do. I am available for questions.

https://www.dropbox.com/home/2016CompRobotProject

Good Luck,

Tim
That link doesn't seem to work for me. Can you make it a sharing link instead of just a copied url? Thanks again.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:07.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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