Go to Post If you want to prove your worth, prove it by creation, not destruction. - DanL [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
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 09-01-2012, 11:22
markgryzwa markgryzwa is offline
Registered User
FRC #3206 (Royal-T-Wrecks)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: MN
Posts: 30
markgryzwa is on a distinguished road
Help with C robot example

As a mentor I'd like to set up to help our team learn the C development platform. I've followed the instructions but have no Default Robot Main Program.

Can you help me with what I might have missed?
  #2   Spotlight this post!  
Unread 09-01-2012, 11:31
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Help with C robot example

My guess would be you are missing the Workbench Update. The "Getting Started with the 2012 FRC Control System" (the instructions I assume you are following) has a link to where to find it on page 3.
  #3   Spotlight this post!  
Unread 09-01-2012, 11:37
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Help with C robot example

As a quick question, why not develop using C++ instead?

For developing the robot programs, there's no main method because... I'm not entirely sure why, but when using C, the WPILibrary enables you to not have to worry about game state, and do things in something akin to the main() method. The system handles all the field management sysem interfacing and checking of all other systems, and so I guess using a main method to start the program would be counter-intuitive as you'd lose all that support if you took direct control of it.

In short, the system starts up on it's own with software provided by FIRST; by including WPILib, all you need to do is provide the initialization code, and the system will automatically call the functions autonomous() and operatorControl() for you when those periods are detected, all that's needed to be done for control is put the control code per period in each code block.

I.E I would initialize two jaguars, jag1 = new CJaguar(port) or something like that, jag2...
CAutonomous(){
jag1.set(power);
jag2.set(power);
Wait(5);
}
The autonomous method is automatically called by the system, and it'll run your commands. In this case, it'll set each jaguar to the power level, and drive for 5 seconds while the user program waits to resume.
__________________
Attending: MN Duluth Regional
  #4   Spotlight this post!  
Unread 09-01-2012, 11:44
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Help with C robot example

Quote:
Originally Posted by theprgramerdude View Post
I.E I would initialize two jaguars, jag1 = new CJaguar(port) or something like that, jag2...
CAutonomous(){
jag1.set(power);
jag2.set(power);
Wait(5);
}
The autonomous method is automatically called by the system, and it'll run your commands. In this case, it'll set each jaguar to the power level, and drive for 5 seconds while the user program waits to resume.
You drive forward for 5 seconds.

When do you stop?
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #5   Spotlight this post!  
Unread 09-01-2012, 11:58
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Help with C robot example

In my experience using the C++ library (C without the wrappers), all outputs completely stop once you're outside the code blocks. The methods are called once in simple robot when it detects it's changed to autonomous or operator control, and control of the robot is enabled during your code blocks.

I'll have to double check this, but either the robot drives forward for 5 seconds, then stops at the end because the autonomous program has ended, or.... if it still detects autonomous, it'll just keep on driving past the end of the block, until it detects a disable command or switching to operator control, at which point you could send new commands to the jaguars. I'll have to recheck this today. The reason they've stopped before is probably a combination of below and the fact that I stop it only by disable commands.

Usually, in order to provide immediate control and switching, I simply enclose everything within the method in a while(IsAutonomous()) or while(IsOperatorControl()) loop with a Wait(.005) at the end, making sure the code runs fast and it'll check every 5 ms to end everything.
__________________
Attending: MN Duluth Regional

Last edited by theprgramerdude : 09-01-2012 at 12:00.
  #6   Spotlight this post!  
Unread 09-01-2012, 12:04
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Help with C robot example

Proper programming practice is to stop at the end of autonomous.

I believe that you will continue to drive forward until autonomous ends.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #7   Spotlight this post!  
Unread 09-01-2012, 12:08
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Help with C robot example

Err, I misread the original post, this isn't asking about why there's no main().

As to the OP, there isn't a default main robot program, and never was, to my knowledge. When the updates are applied, what you'll get instead are quite a few other templates, among them which includes the default factory image. This is the default program that is installed when the cRio is imaged, and you might want to start with that instead.

To apalrd, yes, I know. Laziness gets the best of us, and for a short example, I wrote a few commands to demonstrate where to put what.
__________________
Attending: MN Duluth Regional
  #8   Spotlight this post!  
Unread 09-01-2012, 13:04
markgryzwa markgryzwa is offline
Registered User
FRC #3206 (Royal-T-Wrecks)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: MN
Posts: 30
markgryzwa is on a distinguished road
Re: Help with C robot example

I was simply missing the update that includes the programming framework. Thanks for the other suggestions as well.
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


All times are GMT -5. The time now is 02:04.

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