/** * moduleTerminate * * Module exit point * * @return 0 */ extern "C" int moduleTerminate() { robot.terminate(); return 0; }//moduleTerminate
/** * * moduleWelcome * * First function of the module called at load time : * - the caller gives the module some information about its run-time environment * - the module gives the caller some information about what he needs * MUST be called before moduleInitialize() * * @param welcomeIn Run-time info given by the module loader at load time * @param welcomeOut Module run-time information returned to the called * @return 0 if no error occured, not 0 otherwise */ extern "C" int moduleWelcome(const tModWelcomeIn* welcomeIn, tModWelcomeOut* welcomeOut) { welcomeOut->maxNbItf = robot.count_drivers(); return 0; }//moduleWelcome
/* * Function * * * Description * * * Parameters * * * Return * * * Remarks * */ static void drive_at(int index, tCarElt* car, tSituation *s) { gps.update(car); vec2 myPos = gps.getPosition(); printf("Players's position according to GPS is (%f, %f)\n", myPos.x, myPos.y); robot.drive_at(index, car, s); }//drive_at
/** * * InitFuncPt * * Robot functions initialisation. * * @param pt pointer on functions structure * @return 0 */ static int InitFuncPt(int index, void *pt) { tRobotItf *itf = (tRobotItf *)pt; robot.init_context(index); itf->rbNewTrack = initTrack; /* give the robot the track view called */ /* for every track change or new race */ itf->rbNewRace = newrace; itf->rbResumeRace = resumerace; /* drive during race */ itf->rbDrive = robot.uses_at(index) ? drive_at : drive_mt; itf->rbShutdown = shutdown; itf->rbPitCmd = pitcmd; itf->index = index; return 0; }//InitFuncPt
static void shutdown(const int index) { robot.shutdown(index); }//shutdown
static int pitcmd(int index, tCarElt* car, tSituation *s) { return robot.pit_cmd(index, car, s); }//pitcmd
/* * Function * * * Description * * * Parameters * * * Return * * * Remarks * */ static void drive_at(int index, tCarElt* car, tSituation *s) { robot.drive_at(index, car, s); }//drive_at
void resumerace(int index, tCarElt* car, tSituation *s) { robot.resume_race(index, car, s); }
/** * * newrace * * @param index * @param car * @param s situation provided by the sim * */ void newrace(int index, tCarElt* car, tSituation *s) { robot.new_race(index, car, s); }//newrace
/** * initTrack * * Search under robots/human/cars/<carname>/<trackname>.xml * * @param index * @param track * @param carHandle * @param carParmHandle * @param s situation provided by the sim * */ static void initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSituation *s) { robot.init_track(index, track, carHandle, carParmHandle, s); }//initTrack
/** * * moduleInitialize * * Module entry point * * @param modInfo administrative info on module * @return 0 if no error occured, -1 if any error occured */ extern "C" int moduleInitialize(tModInfo *modInfo) { return robot.initialize(modInfo, InitFuncPt); }//moduleInitialize