MGC Base Component

The base component class all components should derive from; provides several key tools necessary for our component model design. All I/O logic is wrapped, as well as configuration, resource management, performance management, data dependency, and logging. This class is within the "Shared" source directory, under the name "BaseComponent". All software components of the Mini Grand Challenge Architecture should derive from this class. Since each software component is it's own executable, each class should also instantiate itself in a special methodology. (This is mentioned in the below-linked tutorial)

To write your own component, you must derive from the "BaseComponent" class and overload the pure-virtual function "Update". Each cycle of "Update" should be a full cycle of your algorithm. "Update" is wrapped in such a way that the performance is fully measured and handled appropriately.

 Find more about how to write your own component.

The internal communication system is a method of standardizing, managing, and buffering inter-process communication. These functions are based on the CMU IPC library. Each component will need to have input and output communication, by definition of our component model design. To help increase performance, all I/O is buffered, meaning that input and output data is kept within a component until an update/get/set is seen. All communication strings are based on certain properties:

The communication standard for inner component communication is based on several rules:
 * Not encrypted / compressed: In plain-text ASCII (For now!)
 * Works on port 1381 by default, though that can be changed
 * Message overheads are case insensitive (Such as component name and data types)

Each communication call has three elements: The name of the component of origin, the data type (as a string), and the data (with an associated byte length_. Component names are the names of components we are retrieving data from. We do not have to explicitly write where we are sending data to; the internal communication system arranges for correct dependency forwarding. The data type name is simply a standardized name of the data structure you are trying to send (such as "LaserPoints", "Position", etc.) The data is simply a buffer of data you are trying to post/receive. You can see this format in the send/get functions for communications. The general use functions are as follows:


 * int GetData(const char* ComponentName, const char* DataType, void* DataBuffer)
 * Obtains data, of the given data type name, from the given component name, and places it into the given data buffer.
 * Data buffer must be pre-allocated! The return value is the number of bytes written into data buffer, or a negative value upon failure


 * int SendData(const char* DataType, const void* DataBuffer, int BufferByteSize)
 * Posts the given data structure, of the given data buffer, to output to be picked up
 * The internal implementation copies over this data, so you can release it as soon as you are done calling this function
 * Returns the number of bytes sent, or -1 on failure

= List of Component Names and Data Types = Informal list under revision.

Since we are using strings and not formal structures to pass data, we must remain consistent with our I/O data type names. The following is a list of all I/O type names: (Component name, followed by the data type name, and enumerated data types)
 * VehicleController
 * SetSpeed [Integer 0 to 100] - Sets the vehicle speed
 * GetSpeed [Integer 0 to 100] - Returns the real world vehicle speed
 * LaserInterface
 * GetLaserCount [Integer] - Returns the number of laser point elements
 * GetLaserData [(Float,Float, ...)] - Returns the elements of laser collision points (Polar coordinates, as angle and distance pairs), in an array of tuples
 * GetLaserAngle [Float, Float] - Returns the laser range finder's angle range
 * WaypointInterface
 * GetCurrentWaypoint [Float, Float] - Returns the position of the current waypoint
 * GetCurrentPosition [Float, Float] - Returns the current vehicle position
 * GetWaypointCount [Integer] - Returns the number of waypoints left
 * CollisionInterface
 * GetLineCount [Integer] - Returns the number of lines we currently see
 * GetLine [(Float, Float), ...] - Returns the road line pairs as an array of tuples
 * CamVisionInterface
 * GetImage - Returns an imageimage
 * RoadSelectInterface
 * GetImage - Returns an image
 * ProjectionInterface
 * GetImage - Returns an image
 * VehicleProjectionInterface
 * GetAngle - Returns the angle that the system should move the vehicle with