|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Over the past few days, I have been working on taking my labview code from this previous year and converting it to java. I have some knowledge of java from taking AP Computer Science this previous school year, and learned some stuff from looking around on here and the API. I believe I wrote the code code somewhat correctly, but I am not with the robot so I cannot run it to see. I was wondering if anyone could look it over. Give some tips, find any problems, help me out.
I have commented most of my code, so it will hopefully be easy to understand. My main concerns are if I did the limit switches correctly, my drive system, relays, autonomous, my tasks that run over time(there is one servo where this is done, and the thrower motor), and how I initialized all my variables. If you have any questions regarding the code or how our robot operated, please ask! I will help you out to the best of my ability. Here is the code: http://code.google.com/p/jared-1751-...ource/checkout Thank you!!! |
|
#2
|
|||
|
|||
|
Re: Code Check Please!
Anyone take a look or find anything...?
|
|
#3
|
||||
|
||||
|
Re: Code Check Please!
I'm no java expert (I like c++) but...
If you don't like any of my suggestions (especially style ones), feel free to ignore them. Hopefully I helped a little. |
|
#4
|
|||
|
|||
|
Re: Code Check Please!
Thanks for the help. I looked at all of your comments, and went through my code again.
Thank you for all your suggestions and help! The new code is available here: http://code.google.com/p/jared-1751-...ource/checkout |
|
#5
|
||||
|
||||
|
Re: Code Check Please!
I think with the timers, you have to define them outside of the loop or else they'll get recreated each time and lose their value.
Like: Code:
Timer timer1 = new Timer();
while (...) {
// use timer1
}
Code:
while(...) {
Timer timer1 = new Timer();
// use timer1
}
Code:
while(...) {
static Timer timer1 = new Timer();
// use timer1
}
same for things like spinThrower. You may want to read up a little on scope. The loss of static is one of the main reasons I like c++ more than java. In java you have to put all of those booleans before the loop and then you have to keep going up and back to see what type they are, while in c++ you can make them static and they'll be right there. Oh, well. Last edited by WizenedEE : 06-26-2012 at 08:52 PM. |
|
#6
|
|||
|
|||
|
Re: Code Check Please!
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|