Go to Post As my daughter said, you used to shut up your robot and send it away from home. Now you just suffocate it. - GaryVoshol [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
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 02-02-2009, 17:52
gdo's Avatar
gdo gdo is offline
Never too much duct-tape ;)
AKA: Patrick
FTC #0001 (Team Unlimited)
Team Role: Engineer
 
Join Date: Dec 2005
Rookie Year: 2001
Location: MA
Posts: 131
gdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to behold
Send a message via AIM to gdo Send a message via MSN to gdo
[FTC]: NXT Display Code

I was working on an autonomous program chooser to work locally on the NXT. the problem lies when you use the #included "JoystickDrive.c" command (which we have to use...) there is a included file in this drive to display information about battery voltage and important information like that. The problem is that it covers the screen when I want to display information over it for my program selecter.

Here's the code: (BTW, I removed user specific code to make the post not too long, all it did was use the strings and user functions to compile the wanted autonomous).

Quote:


#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.

int nAlliance = 0;
int nStart = 0;
int nScore = 0;
string sAlliance = "Red";
string sStart = "Floor";
string sScore = "12' Goal";


int nLeftButton = 0;
int nRightButton = 0;
int nEnterButton = 0;


void AutonomousChooser()
{
// Place code here to sinitialize servos to starting positions.
// Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.


//////////////////////////////////////////////////////////////////////////////////////////////////////
//
// "Hi-jack" buttons for user program control.
//
nNxtButtonTask = -2; // Grab control of the buttons. '-3' is invalid for task, so no task will be
// executed when a button is pressed.

//
// Note: program cannot be terminated if we hijack the 'exit' button. So there has to be an escape sequence
// that will return buttons to system control! We'll use a triple click
//
nNxtExitClicks = 2; // Double clicking EXIT button will terminate program
//
// Do nothing. Just keep waiting
//

while (nEnterButton != 4)
{

TButtons nBtn;
while (true) // wait for button press
{
nBtn = nNxtButtonPressed;
if (nBtn != -1)
break;
}

switch (nBtn)
{
case kLeftButton: ++nLeftButton; break;
case kRightButton: ++nRightButton; break;
case kEnterButton: ++nEnterButton; break;
}

PlaySoundFile("! Click.rso");
nxtDisplayTextLine(0, "Alliance:" );

nxtDisplayTextLine(2, "Starting:" );

nxtDisplayTextLine(4, "Score:" );

nxtDisplayTextLine(6, "Double Click EXIT");
nxtDisplayTextLine(7, " to end program ");

if(nEnterButton == 0)
{
nRightButton = 0;
nLeftButton = 0;
nEnterButton = 0;
}
if(nEnterButton == 1)
{
nAlliance = abs(nLeftButton - nRightButton);
if((nAlliance == 0) || (nAlliance == 2))
{
sAlliance = "Red";
nxtDisplayTextLine(1, "%s", sAlliance); //
nRightButton = 0;
nLeftButton = 0;
}
if(nAlliance == 1)
{
sAlliance = "Blue";
nxtDisplayTextLine(1, "%s", sAlliance); //
}
}
if (nEnterButton == 2)
{
nStart = abs(nLeftButton - nRightButton);
if((nStart == 0) || (nStart == 2))
{
sStart = "Floor";
nxtDisplayTextLine(3, "%s", sStart); //
nRightButton = 0;
nLeftButton = 0;
}
if(nStart == 1)
{
sStart = "Ramp";
nxtDisplayTextLine(3, "%s", sStart); //
}
}
if (nEnterButton == 3)
{
nScore = abs(nLeftButton - nRightButton);
if((nScore == 0) || (nScore == 2))
{
sScore = "12' Goal";
nxtDisplayTextLine(5, "%s", sScore); //
nRightButton = 0;
nLeftButton = 0;
}
if(nScore == 1)
{
sScore = "20' Goal";
nxtDisplayTextLine(5, "%s", sScore); //
}
}
while (true) // wait for button release
{
nBtn = nNxtButtonPressed;
if (nBtn == -1)
break;
}
}
return;
}
I was just wonder if it would be legal to edit the JoystickDrive.c file to remove the dianogstic code or is there some way to clear the screen of this data for as long as I am using this routine. I tried using the EraseDisplay routine, but it doesn't erase all lines, any ideas or suggestions?

Thanks in advance guys!
~GDO, Team Unlimited (FTC #1)

This routine does work 100% without the template right now, so if any one has any questions about it or wants to use it, I will explain it and show you the complete code.

Inside the "JoystickDriver.c" file, the problem source is here:

Quote:
task displayDiagnostics()
{
string sFileName;

getUserControlProgram(sFileName);
nxtDisplayTextLine(6, "Teleop FileName:");
nxtDisplayTextLine(7, sFileName);
bNxtLCDStatusDisplay = true;
while (true)
{
if (bDisplayDiagnostics)
{
getJoystickSettings(joystick); //Update variables with current joystick values

if (joystick.StopPgm)
nxtDisplayCenteredTextLine(1, "Wait for Start");
else if (joystick.UserMode)
nxtDisplayCenteredTextLine(1, "TeleOp Running");
else
nxtDisplayCenteredTextLine(1, "Auton Running");

if ( externalBatteryAvg < 0)
nxtDisplayTextLine(3, "Ext Batt: OFF"); //External battery is off or not connected
else
nxtDisplayTextLine(3, "Ext Batt:%4.1f V", externalBatteryAvg / (float) 1000);

nxtDisplayTextLine(4, "NXT Batt:%4.1f V", nAvgBatteryLevel / (float) 1000); // Display NXT Battery Voltage

nxtDisplayTextLine(5, "FMS Msgs: %d", nMessageCount); // Display Count of FMS messages
}

wait1Msec(200);
}
}
From what I see, its purely cosmetic and shouldn't interfer w/ anything if removed.
__________________



FTC #1: http://unlimited.syraweb.org

Got any question for me; AIM, MSN or PM me

Last edited by gdo : 02-02-2009 at 18:15.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2009, 19:14
gdo's Avatar
gdo gdo is offline
Never too much duct-tape ;)
AKA: Patrick
FTC #0001 (Team Unlimited)
Team Role: Engineer
 
Join Date: Dec 2005
Rookie Year: 2001
Location: MA
Posts: 131
gdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to behold
Send a message via AIM to gdo Send a message via MSN to gdo
Re: [FTC]: NXT Display Code

I just figured it out...

I case anyone is interested in using this code in competition add this to your code:

Quote:
task main()
{
initializeRobot();

eraseDisplay();
bDisplayDiagnostics = false;
AutonomousChooser();
bDisplayDiagnostics = true;

waitForStart(); // Wait for the beginning of autonomous phase.

//YOUR CODE HERE

e.g.

if(sAlliance == "Blue")
{
//Blue ALLIANCE
if((sStart == "Floor") & (sScore == "12' Goal"))
{
// SCORE in the 12"
// GATHER from the Near Dispenser
// START from the Floor
}
}
}
just an example. Also, the AutonomousChooser was updated to this:

Quote:

int nAlliance = 0;
int nStart = 0;
int nScore = 0;
string sAlliance = "Red";
string sStart = "Floor";
string sScore = "12' Goal";

void AutonomousChooser ()
{
//////////////////////////////////////////////////////////////////////////////////////////////////////
//
// "Hi-jack" buttons for user program control.
//
nNxtButtonTask = -2; // Grab control of the buttons. '-3' is invalid for task, so no task will be
// executed when a button is pressed.

//
// Note: program cannot be terminated if we hijack the 'exit' button. So there has to be an escape sequence
// that will return buttons to system control! We'll use a triple click
//
nNxtExitClicks = 2; // Double clicking EXIT button will terminate program
//
// Do nothing. Just keep waiting
//

while (nEnterButton != 4)
{
TButtons nBtn;
while (true) // wait for button press
{
nBtn = nNxtButtonPressed;
if (nBtn != -1)
break;
}

switch (nBtn)
{
case kLeftButton: ++nLeftButton; break;
case kRightButton: ++nRightButton; break;
case kEnterButton: ++nEnterButton; break;
}

PlaySoundFile("! Click.rso");
nxtDisplayTextLine(0, "Alliance:" );
nxtDisplayTextLine(2, "Starting:" );
nxtDisplayTextLine(4, "Score:" );
nxtDisplayTextLine(6, "Double Click EXIT");
nxtDisplayTextLine(7, " to end program ");

if(nEnterButton == 0)
{
nRightButton = 0;
nLeftButton = 0;
nEnterButton = 0;
}
if(nEnterButton == 1)
{
nAlliance = abs(nLeftButton - nRightButton);
nxtDisplayTextLine(3, " ");
nxtDisplayTextLine(5, " ");
if((nAlliance == 0) || (nAlliance == 2))
{
sAlliance = "Red";
nxtDisplayTextLine(1, "%s", sAlliance); //
nRightButton = 0;
nLeftButton = 0;
}
if(nAlliance == 1)
{
sAlliance = "Blue";
nxtDisplayTextLine(1, "%s", sAlliance); //
}
}
if (nEnterButton == 2)
{
nStart = abs(nLeftButton - nRightButton);
if((nStart == 0) || (nStart == 2))
{
sStart = "Floor";
nxtDisplayTextLine(3, "%s", sStart); //
nRightButton = 0;
nLeftButton = 0;
}
if(nStart == 1)
{
sStart = "Ramp";
nxtDisplayTextLine(3, "%s", sStart); //
}
}
if (nEnterButton == 3)
{
nScore = abs(nLeftButton - nRightButton);
if((nScore == 0) || (nScore == 2))
{
sScore = "12' Goal";
nxtDisplayTextLine(5, "%s", sScore); //
nRightButton = 0;
nLeftButton = 0;
}
if(nScore == 1)
{
sScore = "20' Goal";
nxtDisplayTextLine(5, "%s", sScore); //
}
}
while (true) // wait for button release
{
nBtn = nNxtButtonPressed;
if (nBtn == -1)
break;
}
}
}
I will try to get this all comment out ASAP and i'll answer any questions on it in the mean time.
__________________



FTC #1: http://unlimited.syraweb.org

Got any question for me; AIM, MSN or PM me
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2009, 23:39
Michael Coleman's Avatar
Michael Coleman Michael Coleman is offline
Registered User
no team
 
Join Date: Nov 2006
Rookie Year: 2001
Location: Orlando, Florida
Posts: 82
Michael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of light
Re: [FTC]: NXT Display Code

Issue #1
The software templates are mandatory for FTC competitions. Robots that don't display the diagnostics may fail software inspection.

Issue #2
The Field Technical Advisor (FTA) at a competition is responsible for diagnosing problems when robots behave unexpectedly during competitions. Unexpected behavior can be caused by the robot or the Field Control System. The diagnostic information written to the NXT enables the FTA to quickly eliminate many of the common robot problems. Robots that don't display the diagnostics could be at a disadvantage when there is unexpected robot behavior during a match.

For example, a robot doesn't start Autonomous or doesn't move in the Tele-op portion of a match. The robot is still in the starting position near the field wall and the FTA can see the NXT display. [This is a very common situation.] If the robot is using the ROBOTC template the FTA can check for the following on the NXT display:

- Is the NXT enabled or disabled?
- Does the NXT's internal battery have sufficient voltage?
- Is the external battery pack powering the HiTechnic controllers turned on and have sufficient voltage?
- Is the NXT receiving Bluetooth packets?
- What is the name of the Tele-op program?

If the NXT doesn't display the expected diagnostic information, the door is open for the FTA to declare that the unexpected robot behavior is likely a robot failure since it isn't programmed using the mandatory template. Or worse, the robot should not be allowed to participate in a match since it shouldn't have passed software inspection.

Suggestion:
Teams could write their own information to the NXT display during software development and testing. Once the software is competition ready, it is in the team's best interest to use the mandatory template. The template minimizes the risk of failing software inspection and provides the FTA with valuable information when diagnosing unexpected robot behavior during a match.

Michael
Reply With Quote
  #4   Spotlight this post!  
Unread 03-02-2009, 07:35
jbbjjbt jbbjjbt is offline
VRC Coach
AKA: Jon T
VRC #0177 (Twisted Botz)
Team Role: Coach
 
Join Date: Feb 2006
Rookie Year: 2004
Location: Gloucester, VA
Posts: 110
jbbjjbt is an unknown quantity at this point
Re: [FTC]: NXT Display Code

Currently we are using LabView rathar than RobotC.

But we write on the NXT screen to allow us to choose between red and blue and ramp and floor. We also write the Voltage form the battery using Phil's great program. All of this easily fits under the information that the template writes on the screen. We just use the two lines on the bottom of the screen.
__________________
Jon Thompson
Coach
VRC 177 Twisted Botz
Sponsored by FRC 122
NASA Knights
Reply With Quote
  #5   Spotlight this post!  
Unread 03-02-2009, 09:36
Michael Coleman's Avatar
Michael Coleman Michael Coleman is offline
Registered User
no team
 
Join Date: Nov 2006
Rookie Year: 2001
Location: Orlando, Florida
Posts: 82
Michael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of lightMichael Coleman is a glorious beacon of light
Re: [FTC]: NXT Display Code

Jon is correct. The NXT-G and LabVIEW templates display less diagnostic information than the ROBOTC template. This leaves space at the bottom of the NXT display for team diagnostics.

Michael
Reply With Quote
  #6   Spotlight this post!  
Unread 03-02-2009, 16:51
gdo's Avatar
gdo gdo is offline
Never too much duct-tape ;)
AKA: Patrick
FTC #0001 (Team Unlimited)
Team Role: Engineer
 
Join Date: Dec 2005
Rookie Year: 2001
Location: MA
Posts: 131
gdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to beholdgdo is a splendid one to behold
Send a message via AIM to gdo Send a message via MSN to gdo
Re: [FTC]: NXT Display Code

it disables the display for about 10 seconds before the match begins (before it should recieve a message from the FMS). then right after that it re-enables the diagnostic software. so for a total of 10 seconds before the round even begins the diagnostic software is running but not displaying.
__________________



FTC #1: http://unlimited.syraweb.org

Got any question for me; AIM, MSN or PM me
Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2009, 10:16
dickswan dickswan is offline
Registered User
no team
 
Join Date: Feb 2006
Location: dallas, TX
Posts: 13
dickswan is an unknown quantity at this point
Re: [FTC]: NXT Display Code

Personally I think what you've done is fine. [I wrote the "joystickDriver.c" code so I have some knowledge of this.]

But as Michael Coleman has commented, it's up to the local competititon "Field Adminstrator" to make the call.

If your chooser code only displays to the screen before you get to the field, then I think you'd probably be OK.

Another alternative that you might want to consider is having a separate program to select which of the four choices. It could write this to a file on the NXT -- perhaps only containing a single character. Then your autonomous program could read this file and make the appropriate decision. If you want help with this, email me directly (dickswan@sbcglobal.net) and I'll send you more details.

NOTE: the diagnostic information on the NXT screen for the Field Management system is somewhat of a pain. This is information that the Field Management System could interrogate from the NXT (via Bluetooth) and display on the FMS. However, this was too big a change to make late in the season and instead this information was added to the LCD display.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FTC]: How to play sound from NXT gregsanCHEVY121 FIRST Tech Challenge 5 07-04-2009 10:10
[FTC]: RobotC and NXT-G (The two programming languages) craig_yates FIRST Tech Challenge 1 30-01-2009 21:47
[FTC]: Help requested, the NXT is not showing the battery as being connected. crazilyrandom1 FIRST Tech Challenge 2 17-01-2009 11:24
[FTC]: Bluetooth/NXT issues jbbjjbt FIRST Tech Challenge 5 23-10-2008 16:56
[FTC]: [FTC]: Ontario Provincial FTC Start/End Times cbhl FIRST Tech Challenge 8 16-12-2007 13:37


All times are GMT -5. The time now is 12:36.

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