Go to Post Oh and don't mind the lightening holes. Thats just how I waste time when I get bored :P - SerpentEagle [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-01-2015, 21:38
N00bfirst N00bfirst is offline
Registered User
FRC #4992
 
Join Date: Dec 2013
Location: Milton
Posts: 8
N00bfirst is an unknown quantity at this point
Dashboard not displaying messages

Our dashboard does not seem to display any message whatsoever when we try to run the robot code.

Can anybody please explain why such a thing is happening and how we can write to the dashboard?

This is just sample code to get the hang of the encoder average encoder value. Apologies for the terrible variable names.

However, it does not display a message even if I do something simple like trying to print a value onto the dashboard.

public void autonomousInit() {
autoLoopCounter = 0;
Encoder sampleEncoder = new Encoder(8, 9, false, Encoder.EncodingType.k2X);
sampleEncoder.setMaxPeriod(0.1);
sampleEncoder.setMinRate(10);
sampleEncoder.setDistancePerPulse(5);
sampleEncoder.setSamplesToAverage(7);
sampleEncoder.reset();

SmartDashboard.putNumber("hmm", 2);

double k = sampleEncoder.getRate();
boolean what = sampleEncoder.getStopped();
String huh = sampleEncoder.getSmartDashboardType();
while (k>10){
String k2 = Double.toString(k);
double distance = sampleEncoder.getDistance();
String distance1 = Double.toString(distance);
SmartDashboard.putNumber(k2, k);
SmartDashboard.putNumber(distance1, distance);
SmartDashboard.putBoolean(huh, what);
}
Reply With Quote
  #2   Spotlight this post!  
Unread 23-01-2015, 18:05
Quantum Byte's Avatar
Quantum Byte Quantum Byte is offline
Lead Programmer
AKA: Domenic
FRC #4776 (S.C.O.T.S. Bots)
Team Role: Programmer
 
Join Date: May 2012
Rookie Year: 2011
Location: Hartland, Michigan
Posts: 16
Quantum Byte is an unknown quantity at this point
Re: Dashboard not displaying messages

Try putting all of the smartdashboard code you want to display:
Code:
SmartDashboard.putNumber("hmm", 2);

double k = sampleEncoder.getRate();
boolean what = sampleEncoder.getStopped();
String huh = sampleEncoder.getSmartDashboardType();
while (k>10){
String k2 = Double.toString(k);
double distance = sampleEncoder.getDistance();
String distance1 = Double.toString(distance);
SmartDashboard.putNumber(k2, k);
SmartDashboard.putNumber(distance1, distance);
SmartDashboard.putBoolean(huh, what);
Into the autonomousPeriodic() method.
Reply With Quote
  #3   Spotlight this post!  
Unread 23-01-2015, 18:33
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Dashboard not displaying messages

because your while loop's condition is k > 10.

You never set k to anything. Therefore, it will just runaway with the thread printing the same numbers to the dashboard (which will be 0 since the encoder was just reset)

you should move everything inside the "while" (plus the "double k = ...") to autonomousPeriodic. (don't use the person above mine's code, as it still suffers from the lack of setting 'k')

Code:
Encoder sampleEncoder = new Encoder(8, 9, false, Encoder.EncodingType.k2X);
public void autonomousInit() {
autoLoopCounter = 0;
sampleEncoder.setMaxPeriod(0.1);
sampleEncoder.setMinRate(10);
sampleEncoder.setDistancePerPulse(5);
sampleEncoder.setSamplesToAverage(7);
sampleEncoder.reset();

SmartDashboard.putNumber("hmm", 2);
}

public void autonomousPeriodic(){
double k = sampleEncoder.getRate();
boolean what = sampleEncoder.getStopped();
String huh = sampleEncoder.getSmartDashboardType();
String k2 = Double.toString(k);
double distance = sampleEncoder.getDistance();
String distance1 = Double.toString(distance);
SmartDashboard.putNumber(k2, k);
SmartDashboard.putNumber(distance1, distance);
SmartDashboard.putBoolean(huh, what);
}
also

1) use more descriptive variable names (huh, what, k2, k are all very, very bad names) (I understand you used these to test, but these for testing isn't even acceptable. You're going to try to fix ur broken test code and u'll end up spending more time re-learning what the variables do than actually fixing the code)
2) don't instantiate ANYTHING (encoder... hint hint) in a function that can be run more than once as your code will error out

Last edited by Arhowk : 23-01-2015 at 18:36.
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 13:33.

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