Go to Post Moral of the story: Crashes happen, things break... SHIFT HAPPENS. - Qbranch [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 04-01-2009, 12:07
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
detecting your own alliance(C++)

This is something I was wondering about the other day--is there a way for robots to determine what alliance they are on from the field control? This seems like it would be rather necessary if you wanted to hunt down opposing robots during the autonomous period.
__________________
Get yer robot source code here!
Reply With Quote
  #2   Spotlight this post!  
Unread 04-01-2009, 12:09
Daniel_LaFleur's Avatar
Daniel_LaFleur Daniel_LaFleur is offline
Mad Scientist
AKA: Me
FRC #2040 (DERT)
Team Role: Engineer
 
Join Date: Apr 2005
Rookie Year: 2003
Location: Peoria, IL
Posts: 1,959
Daniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond reputeDaniel_LaFleur has a reputation beyond repute
Send a message via MSN to Daniel_LaFleur
Re: detecting your own alliance(C++)

Quote:
Originally Posted by nathanww View Post
This is something I was wondering about the other day--is there a way for robots to determine what alliance they are on from the field control? This seems like it would be rather necessary if you wanted to hunt down opposing robots during the autonomous period.
Orientation of the target on the trailer will tell you alliance. The animation also shows different color trailers, but I didn't see that in the rules anywhere.
__________________
___________________
"We are not now that strength which in old days moved earth and heaven; that which we are, we are;
One equal temper of heroic hearts, Made weak by time and fate, but strong in will
To strive, to seek, to find, and not to yield. "
- Tennyson, Ulysses
Reply With Quote
  #3   Spotlight this post!  
Unread 04-01-2009, 12:15
rogerlsmith's Avatar
rogerlsmith rogerlsmith is offline
Software Engineer
AKA: Roger Smith
FRC #3357 (COMETS)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Grand Rapids, MI
Posts: 214
rogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to beholdrogerlsmith is a splendid one to behold
Re: detecting your own alliance(C++)

I was wondering that too, and since you asked the question, I thought I'd look. If you're using WPILib, the DriverStation class will tell you your alliance, at least it looks that way at first glance.
__________________
Roger Smith
Mentor - FRC Team 3357
COMETS - Creating Outstanding Minds, Embracing Technology & Science
---------------------------------------------------------------------------------------

Share FIRST videos, photos and experiences at FIRSTObjective.org
Reply With Quote
  #4   Spotlight this post!  
Unread 04-01-2009, 12:16
paulcd2000's Avatar
paulcd2000 paulcd2000 is offline
Accidentally speaks in C
AKA: Paul Dagnelie
FRC #1719 (The Umbrella Corp.)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore
Posts: 368
paulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the roughpaulcd2000 is a jewel in the rough
Send a message via AIM to paulcd2000
Re: detecting your own alliance(C++)

Quote:
Originally Posted by Daniel_LaFleur View Post
Orientation of the target on the trailer will tell you alliance. The animation also shows different color trailers, but I didn't see that in the rules anywhere.
he's wondering whether there's a way to tell what alliance YOU are.
That's <R18> F.
I think you could put a switch on your robot which indicates alliance, and there may be something in code as well.
__________________
"People don't say 'It's just a game' when their team is winning!" -- Scott Adams

5.5 students (on average)* $7/h *210 hours/student= $8085 of labor, all volunteered (not counting mentors', who are each that much)

We have blades on our robot?! ***sweeeeeet***

There are 11 types of people in the world. Those who can read binary, those who can't, and those who say this joke is supposed to be, "There are 10 types of people in the world. Those who can read binary and those who have a life."
Reply With Quote
  #5   Spotlight this post!  
Unread 04-01-2009, 12:17
dpeterson3 dpeterson3 is offline
Registered User
FRC #1178 (DURT)
Team Role: Alumni
 
Join Date: Aug 2008
Rookie Year: 2008
Location: St. Louis
Posts: 158
dpeterson3 is a jewel in the roughdpeterson3 is a jewel in the roughdpeterson3 is a jewel in the roughdpeterson3 is a jewel in the rough
Re: detecting your own alliance(C++)

The easy way is to put a switch on your bot. Program it in so that it tells what alliance you are on at startup. Example. You have a single position switch on the side of the bot. The people putting the bot in the crater set the switch for the blue alliance (switch closes the circuit on a digital I/O) the initialization code reads the state of that I/O and stores it in a variable called bool alliance (1 for blue, 0 for red). I hope this helps.
Reply With Quote
  #6   Spotlight this post!  
Unread 04-01-2009, 12:38
jtdowney jtdowney is offline
Boiler Up
AKA: John Downey
FRC #4302 (Robophins)
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2006
Location: Chicago
Posts: 300
jtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant future
Re: detecting your own alliance(C++)

Quote:
Originally Posted by nathanww View Post
This is something I was wondering about the other day--is there a way for robots to determine what alliance they are on from the field control? This seems like it would be rather necessary if you wanted to hunt down opposing robots during the autonomous period.
This is written from memory but you should get the idea.
Code:
switch (DriverStation::GetInstance()->GetAlliance()) {
    case DriverStation::kRed:
        // red
        break;
    case DriverStation::kBlue:
        // blue
        break;
    case DriverStation::kInvalid:
    default:
        // unknown
        break;
}
__________________
John Downey
Lead Robot Inspector - Purdue IndianaFIRST District
Whitney Young Magnet High School/Robophins (FRC 4302) - Mentor (2013-current)
Midwest Regional Planning Committee - Member (2012-current)
Boilermaker Regional Planning Committee - Member (2011-2014)
Robot Inspector (2008-current)
Purdue FIRST Programs - Staff Advisor (2008-2011)
Lafayette-Jefferson High School/Precision Guessworks (FRC 1646) - Mentor (2006-2011)
Reply With Quote
  #7   Spotlight this post!  
Unread 04-01-2009, 14:12
Red Mage's Avatar
Red Mage Red Mage is offline
Owner of Holistic Omniscience
FRC #1546 (Chaos Inc)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 35
Red Mage is on a distinguished road
Send a message via AIM to Red Mage
Re: detecting your own alliance(C++)

Weren't the '::' used for defining a function, not calling it? Like 'DriverStation::kRed' should be 'DriverStation.kRed'.
__________________
Don't Blink. Blink and you're dead. Don't turn your back. Don't look away. And don't Blink. Good Luck.
Reply With Quote
  #8   Spotlight this post!  
Unread 04-01-2009, 14:31
aaeamdar's Avatar
aaeamdar aaeamdar is offline
Post-A-Holic
AKA: Paul Dennis
FRC #1719 (The Umbrella Corp)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baltimore, MD
Posts: 231
aaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant future
Re: detecting your own alliance(C++)

The double colon ("::") is a namespace operator. For example, one of the namespaces in C++ is the standard namespace, "std". So you could say,

"std::cout" etc

since cout is in the std namespace.

You could also say at the beginning of your program:

"using namespace std;"

This would allow you to implicitly refer to the std namespace.

The dot operator is different. It allows you direct (non-pointer) access to data members of a class. For example, if you had some class Apple, you might have a call such as...

"myApple.color" which could be red, yellow, greeen, etc. I don't fully understand jtdowney's code, since I am not at all familiar with the new interface, but this is the meaning of the dot operator versus double colon.
Reply With Quote
  #9   Spotlight this post!  
Unread 04-01-2009, 14:38
Red Mage's Avatar
Red Mage Red Mage is offline
Owner of Holistic Omniscience
FRC #1546 (Chaos Inc)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 35
Red Mage is on a distinguished road
Send a message via AIM to Red Mage
Re: detecting your own alliance(C++)

Okay, thanks. Also, how do you distinguish between the light of each alliance. I always thought they were identical. If that's true, make sure your camera is pointed forward at the beginning of the match and lock onto the first thing you see. It'll undoubtedly be an enemy robot. Then, never let it out of your sight. Autonomous is only 15s, so this should be fine.
__________________
Don't Blink. Blink and you're dead. Don't turn your back. Don't look away. And don't Blink. Good Luck.
Reply With Quote
  #10   Spotlight this post!  
Unread 04-01-2009, 14:53
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: detecting your own alliance(C++)

Quote:
Originally Posted by Red Mage View Post
Okay, thanks. Also, how do you distinguish between the light of each alliance. I always thought they were identical. If that's true, make sure your camera is pointed forward at the beginning of the match and lock onto the first thing you see. It'll undoubtedly be an enemy robot. Then, never let it out of your sight. Autonomous is only 15s, so this should be fine.
You would be able to tell what alliancea robot you see is on based on the orientation of the color targets at the top of the trailer. Pink over green would be red alliance, green over pink would be blue alliance.
__________________
Reply With Quote
  #11   Spotlight this post!  
Unread 04-01-2009, 14:59
XXShadowXX's Avatar
XXShadowXX XXShadowXX is offline
They call me Cody.
no team (None currently :\)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Pontiac; MI
Posts: 408
XXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud ofXXShadowXX has much to be proud of
Re: detecting your own alliance(C++)

Couldn't you dect the other robot by the fact you you recieve there instructions but just ignore them since they arn't coded for IP
(that should work right, or it will let you know who is on the field with you)
__________________
Is now an engineer thanks to FIRST.
Reply With Quote
  #12   Spotlight this post!  
Unread 05-01-2009, 02:58
jtdowney jtdowney is offline
Boiler Up
AKA: John Downey
FRC #4302 (Robophins)
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2006
Location: Chicago
Posts: 300
jtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant futurejtdowney has a brilliant future
Re: detecting your own alliance(C++)

Quote:
Originally Posted by Red Mage View Post
Weren't the '::' used for defining a function, not calling it? Like 'DriverStation::kRed' should be 'DriverStation.kRed'.
As aaeamdar pointed out the :: is looking into the DriverStation namespace. kRed, kBlue, and kInvalid are constants in the class that are part of an enumeration.
__________________
John Downey
Lead Robot Inspector - Purdue IndianaFIRST District
Whitney Young Magnet High School/Robophins (FRC 4302) - Mentor (2013-current)
Midwest Regional Planning Committee - Member (2012-current)
Boilermaker Regional Planning Committee - Member (2011-2014)
Robot Inspector (2008-current)
Purdue FIRST Programs - Staff Advisor (2008-2011)
Lafayette-Jefferson High School/Precision Guessworks (FRC 1646) - Mentor (2006-2011)
Reply With Quote
  #13   Spotlight this post!  
Unread 05-01-2009, 23:44
Red Mage's Avatar
Red Mage Red Mage is offline
Owner of Holistic Omniscience
FRC #1546 (Chaos Inc)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: New York
Posts: 35
Red Mage is on a distinguished road
Send a message via AIM to Red Mage
Re: detecting your own alliance(C++)

Yeah, I initially missed that because it's not in the Reference Manual. At all. That's right folks, you can only find it in the Users Guide. Check page 78 for useful functions for autonomous. You can also check the battery voltage! That's useful...I guess...They really need to finish those manuals.
__________________
Don't Blink. Blink and you're dead. Don't turn your back. Don't look away. And don't Blink. Good Luck.
Reply With Quote
  #14   Spotlight this post!  
Unread 06-01-2009, 00:25
keehun's Avatar
keehun keehun is offline
Team Captain
AKA: Keehun Nam
FRC #2502 (EP Robotics)
Team Role: Leadership
 
Join Date: May 2008
Rookie Year: 2008
Location: Eden Priaire
Posts: 474
keehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond repute
Send a message via AIM to keehun
Re: detecting your own alliance(C++)

Quote:
Originally Posted by Red Mage View Post
They really need to finish those manuals.
They also need to make manuals that are accurate. Their FRC Control System pdf #5 on their FRC Control System page has so many errors it wasted a lot of my winter break
__________________
For by grace you have been saved through faith, and that not of yourselves; it is the gift of God, not of works, lest anyone should boast. -- Ephesians 2:8-9
2010: Quarter Finalist (MN 10,000 Lakes)
2010: Website Award (MN 10,000 Lakes)
2009: Quarter Finalist (MN 10,000 Lakes)
2009: GM Industrial Award (MN 10,000 Lakes)
Reply With Quote
  #15   Spotlight this post!  
Unread 06-01-2009, 00:54
daltore's Avatar
daltore daltore is offline
Electronics/programming/design
AKA: Aaron Osmer
FRC #3529 (ausTIN CANs)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2007
Location: San Antonio, TX
Posts: 272
daltore has a spectacular aura aboutdaltore has a spectacular aura aboutdaltore has a spectacular aura about
Send a message via AIM to daltore Send a message via MSN to daltore Send a message via Yahoo to daltore
Re: detecting your own alliance(C++)

Before the match, you have what's called a "constructor" period in the SimpleRobot.cpp template which MIGHT be able to be used to run code in disabled, but my sources haven't tried it yet. If you use the BuiltinDefaultCode.cpp template (iterative template), there's a class for disabled mode. Basically, constructor is the equivalent of Initialize() or IO_Initialization() of the PIC version of WPILib, except I think it runs more than once. Using the disabled mode period, you can run code whenever the robot is disabled, the controller is just introverted; you can read inputs and run code, but you cannot run motors or set outputs until you're enabled.

That being said, that period is the perfect time to figure out where you are and what you're doing with the camera right after the cRIO boots up. With the complexity of the control system this year, there is no reason for your processor to have downtime. You can always be reading a sensor or analyzing visual data to find out where your opponents are and where your alliance members are. That way you know where those robots are already, and can track them when they dart off at the beginning of autonomous and plot a projected course for their trailers to meet very nicely with your moon rocks flying through the air But seriously, do use the camera.
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
Make your own CNC whytheheckme Technical Discussion 8 25-07-2007 02:13
Your Own Team Siggies Cujo General Forum 8 26-02-2005 16:01
any of your regional "buddies" with your in your alliance? Alex Cormier Championship Event 12 08-04-2004 04:20
How do you tell whether your sensor is detecting a crate or the diamond plate? Greg Ross Technical Discussion 4 13-01-2003 19:02
Making your own gearbox? ChaosMonkey Motors 15 25-05-2002 11:07


All times are GMT -5. The time now is 13:43.

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