Main Method won't run
The main method is completely skipped when it hits the first for statement. I have tried to debug it and it just skips to the end. I get bizarre Error and debug messages like: Error IDE-0010 Error Communicating over the serial port (corrupt packet $00);
[noparse][[/noparse]Debug] Discarding packet (<-- I get this one multiple times.); [noparse][[/noparse]Debug] Unknown message from Javelin.
This is the main method. The whole thing compiles fine. I need to figure this out ASAP. So please don't hesitate to help. I am running the latest IDE from parallax and I'm using a Serial port on my windows XP PC.
Post Edited (Gibith) : 2/5/2008 5:30:32 AM GMT
[noparse][[/noparse]Debug] Discarding packet (<-- I get this one multiple times.); [noparse][[/noparse]Debug] Unknown message from Javelin.
public static void main(){ Rover a = new Rover(2); ChromoAmount = DNA.length; Timer min = new Timer(); min.mark(); System.out.println("Program RUnning"); for(int i = 0; i > 10; i ++){ a.DNA = new String[noparse][[/noparse]15]; for( i = 0; i < DNA.length; i ++){ if (DNA[i] == null){ continue; } if (DNA[i] == StartServosEx){ a.StartServos(); if (CheckTime(min)){ break; } else continue; } if (DNA[i] == StopLeftEx){ a.StopLeft(); if (CheckTime(min)){ break; } else continue; } if (DNA[i] == StopRightEx){ a.StopRight(); if (CheckTime(min)){ break; } else continue; } if (DNA[i] == ChangeRightEx){ a.ChangeRight(); if (CheckTime(min)){ break; } else continue; } if (DNA[i] == ChangeLeftEx){ a.ChangeLeft(); if (CheckTime(min)){ break; } else continue; } if (DNA[i] == DelayEx){ a.Delay(); if (CheckTime(min)){ break; } else continue; } if (DNA[i] == RandomizeRightEx){ a.RandomizeRight(); if (CheckTime(min)){ break; } else continue; } if (DNA[i] == RandomizeLeftEx){ a.RandomizeLeft(); if (CheckTime(min)){ break; } else continue; } } /* End of for loop */ if (RightUsed == true){ RightUsed = false; PWM11 = InPWM11; } else if (LeftUsed == true){ LeftUsed = false; PWM22 = InPWM22; } else{ System.out.println("Else!"); } System.out.println("Pre Mutation"); a.MutationMarker(a); a.Mutate(a); lstDNA = a.DNA; GenerationPop.add(lstDNA); System.out.println("Post Mutation"); while(true) { switch(Terminal.getChar()){ case 'c': System.out.println(begin); for(int k = 0; k < GenerationPop.size(); k ++){ for(int j = 0; j < ((String [noparse][[/noparse]])GenerationPop.get(k)).length; j++){ System.out.println(((String [noparse][[/noparse]])GenerationPop.get(k))[noparse][[/noparse]j]);[/i][/i][/i][/i][/i][/i][/i][/i][/i]
This is the main method. The whole thing compiles fine. I need to figure this out ASAP. So please don't hesitate to help. I am running the latest IDE from parallax and I'm using a Serial port on my windows XP PC.
Post Edited (Gibith) : 2/5/2008 5:30:32 AM GMT
Comments
can load it into the IDE to figure out what happens.
regards peter
There are also some inside jokes pretaining to some of the System.out.println lines. These are just to test if a piece of code has executed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
From what I see, you declare a class RetardRover, that has a constructor,
and it has a static void main() method, and from main() you create
RetardRover instances. Maybe that works on the PC (and the compiler allows
it because it is a PC compiler), but it is bad programming.
Put the method main() into its own class, say RetardRover_test,
and import the RetardRover class. That also has the benefit
that you can reuse the RetardRover class in other projects.
regards peter
C:\Program Files\Parallax Inc\Javelin Stamp IDE\lib;C:\Program Files\Parallax Inc\Javelin Stamp IDE\Projects
import gene.*;
If that doesn't work, move your gene folder to
...\lib\stamp
and use
import stamp.gene.*;
regards peter
I thought all you had to do was delcare something public and when you imported it you could manipulate it directly.
Post Edited (Gibith) : 2/5/2008 5:01:25 PM GMT
//file RetardRover.java
package stamp.gene;
import stamp.core.*;
public class RetardRover {
· //your class code
}
Save the file RetardRover.java in folder ...\lib\stamp\gene
//file RetardRover_test.java
import stamp.core.*;
import stamp.gene.*
public class RetardRover_test {
· //your class code here (remember to use static for variables)
· static void main() {
··· //your main method
· }
}
Save the file RetardRover_test.java either in folder Projects or folder ...\lib\stamp\gene
When you program the javelin, make sure you have this file active (on top)
regards peter
I wrote it like this:
But I have more issues pertaining to this program. I will post them soon.
Thanks,
Gibith
Nevermind I fixed that problem however I have a new one. I keep getting index out of bounds error but i don't understand why it's out of bounds. I appears to be in bounds.
Post Edited (Gibith) : 2/6/2008 3:50:36 AM GMT
and both files compile now without error.
You need to check them for possible logical errors.
I also think you need to think about how to setup this particular project,
as it seems to me that RetardRover could be split in several more logical units.
regards peter
I keep getting index out of bounds error but i don't understand why it's out of bounds. It appears to be in bounds.
Post Edited (Gibith) : 2/6/2008 4:06:23 AM GMT
If you take it from there you will have less issues.
An index out of bounds exception·means you are indexing an array
beyond its limits, for example if you declare
· int[noparse]/noparse p = new int[noparse][[/noparse]5];
you can only use p[noparse][[/noparse]0] to p[noparse][[/noparse]4]
Using p[noparse][[/noparse]5] will generate an index out of bounds exception.
regards peter
How can I randomize the seed values? I thought that maybe I could use some external stimulus. At this point I want something that works and something I can quickly incorporate into my code.
Thanks,
Gibith
Then the blocks will get different random values.
regards peter