View Single Post
  #2   Spotlight this post!  
Unread 29-01-2009, 22:17
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: Understanding the Source code

Quote:
This makes no sense to me. Where is the main() function that would presumably instantiate the robot class? Also, what is this START_ROBOT_CLASS doing exactly?
I can try to explain this, to the best of my knowledge. Here's how it works as far as I can tell:

The program's entry point is FRC_UserProgram_StartupLibraryInit. This is what the LabVIEW Run-Time calls when it loads the user program.

The START_ROBOT_CLASS macro sets up a "user class factory", which is a function that returns a pointer new instance of your robot class. Additionally, it creates the entry point function, FRC_UserProgram_StartupLibraryInit.

This entry point calls RobotBase::startRobotTask() with a pointer to the "factory" function. From here, a new task is spawned to run the user program. This task creates an instance of your Robot class and calls its StartCompetition() function. I'm not sure I quite understand the reason behind spawning off this new task, but I believe it somehow makes it easier to debug.

Quote:
The next major macro confusion is with the "wpi_assert"s and "wpi_fatal"s that are sprinkled across the code.
The code for these functions is in Utility.cpp. It seems like they handle some output to stdout, breaking, and stack tracing. I'm pretty curious about these too. I haven't really played around with it yet so I'll leave it up to someone more knowledgeable than myself to explain.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote