|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
|||||
|
|||||
|
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. |
|
#3
|
||||
|
||||
|
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. |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
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. |
|
#6
|
||||
|
||||
|
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!
Quote:
http://frclabviewtutorials.com/teleop/ |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
||||
|
||||
|
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!
Quote:
|
|
#9
|
||||
|
||||
|
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!
Quote:
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. |
|
#10
|
|||
|
|||
|
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 |
|
#11
|
||||
|
||||
|
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!
Quote:
|
|
#12
|
|||
|
|||
|
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?
|
|
#13
|
||||
|
||||
|
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.
|
|
#14
|
|||
|
|||
|
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 |
|
#15
|
||||
|
||||
|
Re: Robot Drive Not Running Fast Enough - PLEASE HELP!
Quote:
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|