![]() |
Code Inefficient?
Hello,
We are currently at the FIRST Robotics Regional @ Richmond/VCU. We have been getting massive lag during tele op. However, this doesn't seem to be happening during autonomous. What we were told is that our code is "bloated/inefficient/RAM hog,etc". Can some one double check this code? Here is our code(s): RobotTemplate: Code:
a/*----------------------------------------------------------------------------*/Code:
/*/* |
Re: Code Inefficient?
Try making your own driver class as such:
Code:
package com.shadowh511.tomo.camera.moving; |
Re: Code Inefficient?
There is nothing that I can see in the code you posted that strikes me as particularly inefficient (I could nitpick things like the overuse of static variables, or the use of a delay inside a function call, but those are style points that shouldn't significantly affect responsiveness).
|
Re: Code Inefficient?
We had a similar problem at FLR. The solution for us was to add a delay/wait (5 or 50 mS) in our camera code. The system was repeatedly calling the camera routine and without the delay it hogged the processing resources to the point that our teleop controls were not getting attention quickly enough, resulting in troublesome delay in robot response for the drive team. A mentor from Team 1511 was instrumental in helping us solve the problem (Thanks Larry). We are Labview based. Hope this is it !
|
Re: Code Inefficient?
Although you have some camera-related files in your directory, it looks like you are never using them. You might want to (temporarily) delete all of the unneeded files and see if that fixes things.
|
Re: Code Inefficient?
I would think that your code is the opposite of bloated, it is quite lightweight as a matter of fact.
We use the iterative robot template which I strongly recommend you do. This allows you to do away with the while loop because teleopperiodic is called automatically each robot cycle. In very simple terms, the periodic robot methods are called, then data packets are sent/received, then the periodic method is called again. I am guessing that your while loop is whipping around too often before a packet is sent and the code is getting confused. I do see a delay in your DualShock class that gets called once an iteration, but I think even that is too quick. You aren't seeing these issues in auto, since each command is called a single time and the system is able to process them within cycle times. If that makes any sense. I am in the middle of a conference right now, so I can't give any more details. |
Re: Code Inefficient?
Does the delay only happen on the field, or does it happen when testing too?
Field-only lag can be due to that issue with the old routers that just got posted on Bill's Blog, or with USB current issues with USB hubs and the classmate - if you are using a breakout board on the classmate it has to be connected directly, not through an unpowered USB hub. |
| All times are GMT -5. The time now is 09:43. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi