Go to Post It would be interesting to be able to take robots from multiple years and invent new games they can play together (Calvin Ball). - Mark McLeod [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #28   Spotlight this post!  
Unread 15-01-2016, 16:32
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 267
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: We are going to Want a GRIP fourm

Quote:
Originally Posted by H2O Enthusiast View Post
By robotMain() do you mean outside the robotInit() but inside the Robot() class? Also, by operational part of my code do you mean where I publish the data?
Yes to both questions. If you look at SampleRobot.java (the base class your code is using), you'll see there's a number of different functions you can override. robotInit() is one. robotMain() is another (as is operatorControl(), disabled(), autonomous(), etc). The startCompetition() function shows the sequence in which these functions are called. robotInit() is called first, and should contain only initialization code -- code you want to run before the match. Only after robotInit() returns does startCompetition() call the FRCNetworkCommunicationsLibrary to let the driver station know robot code is ready to run (which is what makes "No Robot Code" disappear). Note it's somewhat risky to override robotMain() instead of the individual operatorControl(), disabled(), etc. functions, as you will need to handle the state transitions between these modes yourself (versus having startCompetition() handle it for you).

While SampleRobot is okay for small test programs like this one, for your actual competition robot code, if you don't want to do command-based programming, I recommend you use a different template such as IterativeRobot and override only robotInit and the various autonomous/operatorControl functions. The IterativeRobot class startCompetition() function will take care of calling these functions in the right order and putting in appropriate delays to not swamp the CPU.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
 


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 20:45.

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