Go to Post I believe it is in the spirit of the game is to score more points than your opponent within the rules. That means offense AND defense. - Gary Dillard [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 17-02-2012, 21:38
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Robot Nightmare!

The main issue I see with your IterativeRobot code is that you're using it as though it were a SimpleRobot. The startCompetition() method of iterative robot works like this:
Code:
while(robot is alive) {
    check for new driver station packet;
    if(new driver station packet has been received)
        periodic();
    continuous();
}
Obviously, there's more to it, but that's the basic setup. Your periodic() functions for both autonomous and teleop have loops inside them that never end. If periodic() never finishes, how is the robot going to update its driver station data (which includes, among other things, joystick values)? The best way to avoid a situation like this (commonly referred to as a "hang") is to have the robot's data, or "state", separate from its functionality.
However, doing something like this requires having your program work repeatedly on state data, which in turn requires a fairly different thought process from "typical" programming. Instead of asking "What series of steps gets me from point A to point B?", you must ask "If I start at A, how can I determine the next step toward B from the data generated from the previous step(s)?".

Long story short, IterativeRobot doesn't like your input because you never give it a chance to receive it.

Also, on the topic of the DriverStationLCD: when you start up the driver station, there's a light-gray section on the right. This is actually a text display area, and you can use DriverStationLCD to write to it, by doing
Code:
DriverStationLCD.getInstance().println(<line>,<column>,<text>);
DriverStationLCD.getInstance().updateLCD()
<line> is an enum (or as close as you can get with Java ME), with the first line being kMain6, and the rest being kUser2 to kUser6. Yeah, I know, weird naming system.
<column> is an int from 1 to 21, defining the start of where you want the text to be displayed.
<text> is the string you want to display.

On the LCD, 2 things happen that you might not be expecting. First, your text is truncated to fit into the 21 character limit. So, for example, if you tell it to write "Hello, World!" starting from the 10th column, it will become "Hello, Worl", because the last 2 characters don't fit within the limits. Secondly, things overwrite each other. So if you first print out "Hello", then print out "hi" to the same line, you will end up with "hillo".

Best of luck in the upcoming crunch-time!
Reply With Quote
 


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 12:47.

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