Go to Post I would feel more comfortable if you used rock-paper-scissor-lizard-Spock. - IndySam [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

 
Reply
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 01-28-2012, 10:58 PM
loafdog loafdog is offline
Registered User
AKA: Maciej
FRC #2876 (DevilBotz)
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2009
Location: Burlington, MA
Posts: 33
loafdog is an unknown quantity at this point
System.out.println output jumbled

Hi,
We are trying to print out info to console using System.out.println and see the output look jumbled. We are using command based template and want to have the robot run image funcs and output particle reports when a button on joystick is pressed. I found a post that mentioned outputting too fast will cause problems so we added some delays(maybe not enough?) but still see issues. The thread is this one, posts 10 & 11:
http://www.chiefdelphi.com/forums/showthread.php?t=89740&highlight=crio+console+outp ut

Anyone have suggestions/ideas about what to do to make printing debug info work?

The code that prints stuff while running in a command looks like this:
Code:
   private void printParticleReports(String str, BinaryImage img) {
        try {
            System.out.println("* " + str + "*********************************************");
            ParticleAnalysisReport[] reports =
                    img.getOrderedParticleAnalysisReports();
            for (int i = 0; i < reports.length; i++) {
                ParticleAnalysisReport r = reports[i];
                System.out.println("Particle(" + (i + 1) + "/" + reports.length
                        + ")\n" + r.toString());
                System.out.println("");
                Timer.delay(.2);
            }
            System.out.println(img.getNumberParticles()
                    + "  " + Timer.getFPGATimestamp());
            System.out.println("**********************************************");
            Timer.delay(.2);
        } catch (NIVisionException ex) {
            ex.printStackTrace();
        }
    }
One example of jumbled output looks like this:

Quote:
-> arg 1
[cRIO]
[cRIO] * bigobj******************************************** *
[cRIO] 031250000000000444 , 0.0 )
[cRIO] Area : 301746.0
[cRIO] percent : 98.224609375
[cRIO] Bounding Rect : ( 0 , 0 ) 640*480
[cRIO] Quality : 98.33023755987878
[cRIO]
[cRIO]
[cRIO] Particle(1/2)
[cRIO] Particle Report:
[cRIO] Image Height : 480
[cRIO] Image Width : 640
[cRIO] Center of mass : ( 319 , 240 )
[cRIO] normalized : ( -0.0Particle(2/2)
[cRIO] Particle Report:
[cRIO] Image Height : 480
[cRIO] Image Width : 640
[cRIO] Center of mass : ( 323 , 31 )
[cRIO] normalized : ( 0.009374999999999911 , -0.8708333333333333 )
[cRIO] Area : 272.0
[cRIO] percent : 0.08854166666666666
[cRIO] Bounding Rect : ( 294 , 29 ) 55*7
[cRIO] Quality : 95.77464788732394
[cRIO]
[cRIO]
[cRIO] 2 146.245212
[cRIO] **********************************************
[cRIO]
[cRIO] 652 )
[cRIO] Area : 307200.0
[cRIO] percent : 100.0
[cRIO] Bounding Rect : ( 0 , 0 ) 640*480
[cRIO] Quality : 100.0
[cRIO]
[cRIO]
[cRIO] Particle(1/1)
[cRIO] Particle Report:
[cRIO] Image Height : 480
[cRIO] Image Width : 640
[cRIO] Center of mass : ( 319 , 239 )
[cRIO] normalized : ( -0.0031250000000000444 , -0.004166666666666vexhull************************** *******************
[cRIO]
[cRIO] * con1 146.837495
[cRIO] **********************************************
[cRIO]
[cRIO]
[cRIO] * filtered****************************************** ***
[cRIO] 0 147.054589
[cRIO] **********************************************
[cRIO]
Thanks.
Reply With Quote
  #2   Spotlight this post!  
Unread 01-29-2012, 04:39 PM
Unoquadium Unoquadium is offline
The Parlor Generals
AKA: Ilya Rubnich
FRC #0334 (Tech Knights)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Brooklyn, NY
Posts: 8
Unoquadium is an unknown quantity at this point
Re: System.out.println output jumbled

System.out.println is never advisable to use on the cRIO as the method gets called ridiculously fast and that's why the output gets jumbled.

I suggest you use the new smart dashboard for any output.
Check out WPILIBJ docs for more info:
http://www.wbrobotics.com/javadoc/ed...Dashboard.html

Basically import edu.wpi.first.wpilibj.smartdashboard.SmartDashboar d in whatever file you're outputting from and then instead of System.out.println, run SmartDashboard.putString("key", "value") and replace String with whatever datatype you're outputting.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-30-2012, 10:43 AM
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: System.out.println output jumbled

We found last year that the newer router has a habit of reversing the order of packets. When it receives several packets "at once", it sends the most recent one first. It may be assuming that all UDP traffic is audio/video, and the right thing to do is to always send to most recent data.

That was really fun when another part of the system managed to send break up all system output into 1 character packets - all output came out in reversed order!

In any case, now that output is buffered into larger chunks, it's still possible that if several packets hit the router at the same time it may reverse their order.

If you have time, look into the difference between TCP and UDP. System output (e.g. the "netconsole") uses UDP to broadcast to all interested clients on the local network.
Reply With Quote
  #4   Spotlight this post!  
Unread 01-31-2012, 08:36 AM
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: System.out.println output jumbled

Oh, and hi Maciej!

I didn't even look to see who posted the question
Reply With Quote
  #5   Spotlight this post!  
Unread 01-31-2012, 11:26 AM
loafdog loafdog is offline
Registered User
AKA: Maciej
FRC #2876 (DevilBotz)
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2009
Location: Burlington, MA
Posts: 33
loafdog is an unknown quantity at this point
Re: System.out.println output jumbled

Thanks for the suggestions and 'Hi Derek' .

Printing to stdout is a well known debug technique that works in any language and doesn't require any extra tools. I'd like to stick with it because it is simple. I found if I added more delays and printed smaller messages I could cut down on the jumbling. We will just have to be a bit more careful how we print debug data.

Using SmartDash (or any other dashboard) can be a little cumbersome. I cannot get text to break/wrap into multiple lines. So you lose newlines and get one really long line. Is there a way to make text wrap in text boxes?

Maybe you could write a custom widget to display text but its not something anyone on my team has time (or interest?) in doing right now. We might look into the tcp/udp thing too after build season but it's not one of those glamorous things that the students on my team want to work on. Everyone wants to program the shiny new sensor/thingy .

-Maciej
Reply With Quote
Reply


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 08:30 AM.

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