Go to Post [on practice robots:] Twice the work and twice the practice building seem to equal twice the experience so far. - MrBasse [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-02-2007, 12:03
Ultima Ultima is offline
Registered User
FRC #0369
 
Join Date: Oct 2005
Location: Brooklyn, NY
Posts: 26
Ultima will become famous soon enough
OI Input Autonomous

What our team is trying to do this year is to select our Autonomous mode by using the joystick buttons or some other type of button mounted on our control box. While searching Chief Delphi forums for possible solutions we have stumbled upon this code:

Quote:
It's written by Kevin Watson. We used a slightly modified version of it.

Quote:
void auton_selector(void)
{
static char last_sw1;
static char last_sw2;

if(AUTON_UP == 1 && AUTON_UP != last_sw1)
{
if(auton_select < MAXAUTONROUTINES)
auton_select++;
else
auton_select=99;
}
if(AUTON_DN == 1 && AUTON_DN != last_sw2 && auton_select > 0)
{
if (auton_select == 94)
auton_select=MAXAUTONROUTINES;
else
auton_select--;
}
last_sw1 = AUTON_UP; //oneshot the trigger and top buttons
last_sw2 = AUTON_DN;

User_Mode_Byte = auton_select;

}
User_Mode_Byte is the user display on the OI. Use that little button to change to it.

AUTON_UP/DOWN are the defines to which a joystick button or something similar.
Now we are stumped as we are unable to make this code work for us. First of all we are unsure in which of the program files should we put this function into. Second of all when we tried simply pasting this code into our user_routines.c or user_routines_fast.c functions the compiler came out with a bunch of errors. Can anyone take a look and maybe guide us to a solution if possible. Thanks in advance!
  #2   Spotlight this post!  
Unread 04-02-2007, 12:27
esquared's Avatar
esquared esquared is offline
Keeps saying 3-2-1-Rush...
AKA: Angry Eric
no team (Volunteer!)
Team Role: Mascot
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Boston, MA
Posts: 192
esquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond repute
Re: OI Input Autonomous

Hmm, why would anyone want to select autonomous modes from the OI...

A better question is, will the drivers need to step back from the OI BEFORE the refs move the rack?
  #3   Spotlight this post!  
Unread 04-02-2007, 12:32
Ricky Q.'s Avatar Unsung FIRST Hero
Ricky Q. Ricky Q. is offline
yee haw!
FRC #0148 (Robowranglers)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2002
Location: Dallas, TX
Posts: 1,651
Ricky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond reputeRicky Q. has a reputation beyond repute
Send a message via AIM to Ricky Q.
Re: OI Input Autonomous

Quote:
Originally Posted by esquared View Post
Hmm, why would anyone want to select autonomous modes from the OI...

A better question is, will the drivers need to step back from the OI BEFORE the refs move the rack?
I'd guess not, but I'm sure it can be asked on the Q&A, this is the closest I've found.

Quote:
Originally Posted by FRC Manual

<G45>
TEAM members over the PLAYER'S LINE during AUTONOMOUS PERIOD - No TEAM member may pass the PLAYER'S LINE in the ALLIANCE ZONE until the conclusion of the AUTONOMOUS PERIOD. Each violation will result in a 10-point penalty to the offending ALLIANCE. Exceptions will be made in cases involving personal or robot control safety.

Many teams have selected auton on the OI for years, seeing it as better than putting switches on the robot.
__________________
Ricky Quinones
Director of Sales - VEX Robotics
  #4   Spotlight this post!  
Unread 04-02-2007, 12:36
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: OI Input Autonomous

Put that snippet of code in user_routines.c and call it from the same place you're reading the joysticks for other purposes. Default_Routine(), perhaps.

Your compiler errors are probably because you didn't get the hint to replace AUTON_UP and AUTON_DN with the actual OI controls you will be using to step the number up and down. p1_sw_trig and p1_sw_top, for example. You will also have to declare auton_select as a global variable so you can use it in your actual autonomous routine.
  #5   Spotlight this post!  
Unread 06-02-2007, 14:27
Ultima Ultima is offline
Registered User
FRC #0369
 
Join Date: Oct 2005
Location: Brooklyn, NY
Posts: 26
Ultima will become famous soon enough
Re: OI Input Autonomous

I have a few questions. Well first of all I edited the code and this is what it looks like now as I try to compile:

Quote:
void auton_select(void)
{
static char last_sw1;
static char last_sw2;

if(p1_sw_trig == 1 && p1_sw_trig != last_sw1)
{
if(auton_select < 2)
{
auton_select++;
}
else
{
auton_select=99;
}
}
if(p1_sw_top == 1 && p1_sw_top != last_sw2 && auton_select > 0)
{
if (auton_select == 94)
{
auton_select= 2 ;
}
else
{
auton_select--;
}
}
last_sw1 = p1_sw_trig; //oneshot the trigger and top buttons
last_sw2 = p1_sw_top;

User_Mode_Byte = auton_select;
}
Second of all, how would I got about declaring auton_select as a global variable, and third I would need to get around the following errors:

Quote:
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:661:Error [1128] compatible scalar operands required for comparison
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:663:Error [1147] scalar type expected for increment operator
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:667:Error [1131] type mismatch in assignment
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:670:Error [1128] compatible scalar operands required for comparison
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:672:Error [1128] compatible scalar operands required for comparison
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:674:Error [1131] type mismatch in assignment
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:678:Error [1148] scalar type expected for decrement operator
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:684:Error [1105] symbol 'User_Mode_Byte' has not been defined
C:\2007 arm code\FrcCode2005v2.4\user_routines.c:684:Error [1101] lvalue required
The code is from 2005 since we are just testing our prototype arm with the 2005 controller.
  #6   Spotlight this post!  
Unread 06-02-2007, 15:51
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: OI Input Autonomous

Quote:
Originally Posted by Ultima View Post
Well first of all I edited the code...
You made the name of the function the same as the name of the variable it's trying to set. That's what most of your compiler errors are about. You should probably change it back to auton_selector the way it was in the example. You also misspelled User_Mode_byte with a capital B.

To declare a global variable, do it at the top of user_routines.c where it says DEFINE USER VARIABLES AND INITIALIZE THEM HERE.

Oh, and I believe there was a typo in the example code. It looks like the 94 ought to be 99 instead.
  #7   Spotlight this post!  
Unread 08-02-2007, 14:25
Ultima Ultima is offline
Registered User
FRC #0369
 
Join Date: Oct 2005
Location: Brooklyn, NY
Posts: 26
Ultima will become famous soon enough
Re: OI Input Autonomous

Thanks so much for your help so far. We have managed to get the code up and running displaying the numbers on the OI, however anytime I try to get a value from auton_select in my Autonomous Mode I keep getting
Quote:
C:\2007 arm code\FrcCode2005v2.4\user_routines_fast.c:154:Erro r [1105] symbol 'auton_select' has not been defined
C:\2007 arm code\FrcCode2005v2.4\user_routines_fast.c:154:Warn ing [2058] call of function without prototype
even though I have defined auton_select in user_routines.c as so

Quote:
/*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/
#if _USE_CMU_CAMERA
#include "user_camera.h"

int auton_select;
Any solution for this problem? Thanks in advance!
  #8   Spotlight this post!  
Unread 08-02-2007, 14:36
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,856
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: OI Input Autonomous

Add this at the top of user_routines_fast.c to tell the compiler that auton_select is created in another file.
Code:
extern int auton_select;
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #9   Spotlight this post!  
Unread 08-02-2007, 14:47
Ultima Ultima is offline
Registered User
FRC #0369
 
Join Date: Oct 2005
Location: Brooklyn, NY
Posts: 26
Ultima will become famous soon enough
Re: OI Input Autonomous

Quote:
C:\2007 arm code\FrcCode2005v2.4\user_routines_fast.c:137:Warn ing [2058] call of function without prototype
Keep getting this warning, is it important or not really?

P.S. - Got it working HOWEVER I still have one more question. When the robot is disabled through the competition port it refuses to change the autonomous mode. Will our team have to change autonomous modes before we come to the player stations.

Last edited by Ultima : 08-02-2007 at 15:00.
  #10   Spotlight this post!  
Unread 08-02-2007, 16:57
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: OI Input Autonomous

Quote:
Originally Posted by Ultima View Post
P.S. - Got it working HOWEVER I still have one more question. When the robot is disabled through the competition port it refuses to change the autonomous mode. Will our team have to change autonomous modes before we come to the player stations.
If the competition switch is set to manual (non-autonomous) and disabled, you should still be able to read the OI settings.
  #11   Spotlight this post!  
Unread 08-02-2007, 18:51
Michael DiRamio Michael DiRamio is offline
Registered User
FRC #1114 (Simbotics)
Team Role: Teacher
 
Join Date: Jan 2006
Rookie Year: 2006
Location: St. Catharines, Ontario, Canada
Posts: 39
Michael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond repute
Re: OI Input Autonomous

Quote:
Originally Posted by Ultima View Post
Keep getting this warning, is it important or not really?

P.S. - Got it working HOWEVER I still have one more question. When the robot is disabled through the competition port it refuses to change the autonomous mode. Will our team have to change autonomous modes before we come to the player stations.
It's important. It means you're calling a method that doesn't exist. Check your spelling on that line. Remember that method names are case sensitive.
  #12   Spotlight this post!  
Unread 08-02-2007, 19:02
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: OI Input Autonomous

Quote:
Originally Posted by Michael DiRamio View Post
It's important. It means you're calling a method that doesn't exist. Check your spelling on that line. Remember that method names are case sensitive.
Either that or you're calling a function before it is declared. This code will generate the warning
Code:
void void main()
{
  func();
}

void func()
{
}
From the compiler's point of view, it doesn't know that func exists when it parses through main and thus throws the warning.

Here are two ways to get rid of the warning. I prefer the first method.

1. Create a function prototype either at the top of the C file or in a header included by that C file. This will tell the compiler that a function named func that takes no inputs and returns nothing is defined somewhere in the code.
Code:
void func(void);  /* Here is the prototype */

void main()
{
  func();
}

void func()
{
}
2. Write your function before you call it. In this case, the compiler will parse through the function and know about it by the time it gets to the call.
Code:
void func()
{
}

void main()
{
  func();
}
I highly suggest that you get in the habit of dealing with warnings as they pop up so that they don't get lost in the shuffle and manifest themselves into a problem.
  #13   Spotlight this post!  
Unread 08-02-2007, 19:28
pheadxdll pheadxdll is offline
Registered User
AKA: Alex
FRC #1225 (Amperage Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: North Carolina
Posts: 168
pheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud of
Re: OI Input Autonomous

I thought the Master code didn't allow any data transfer between the OI and the RC during autno mode.
__________________
Amperage Robotics Team 1225
Site under-going revamp. :/
  #14   Spotlight this post!  
Unread 08-02-2007, 19:38
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: OI Input Autonomous

Quote:
Originally Posted by pheadxdll View Post
I thought the Master code didn't allow any data transfer between the OI and the RC during autno mode.
It doesn't. But when the robot is on the field before the match, it isn't in autonomous mode, but it is disabled.

In this state, you can do just about anything except set any outputs on the RC (you can read inputs on the RC and the OI, and save these for when you start autonomous mode).
  #15   Spotlight this post!  
Unread 08-02-2007, 23:35
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: OI Input Autonomous

Quote:
Originally Posted by kaszeta View Post
In this state, you can do just about anything except set any outputs on the RC (you can read inputs on the RC and the OI, and save these for when you start autonomous mode).
Close - You can set outputs, but they don't actually make it to the pins.

This is an important distinction when debugging. The dashboard displays the PWM values, even when you're disabled. This is useful if you don't want your arm to swing wildly.

[/nit pick]
Closed Thread


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
User Input railerobotics Programming 4 29-08-2006 00:54
Powered OI input EricS-Team180 Programming 7 28-09-2003 21:23
Graphic Input Raven_Writer Computer Graphics 7 08-08-2003 15:43
Autonomous user-input loophole? Jeff McCune Programming 20 14-02-2003 22:44
2.5 is alive !!!! (input ! .. more input ! ) Lloyd Burns Programming 2 14-01-2003 19:15


All times are GMT -5. The time now is 23:54.

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