1 /*************************************************************************** 2 3 file : robot.h 4 created : Sun Jan 30 22:59:40 CET 2000, 2002 5 copyright : (C) 2000-2014 by Eric Espie, Bernhard Wymann 6 email : torcs@free.fr 7 version : $Id: robot.h,v 1.10.2.3 2014/05/17 04:50:39 berniw Exp $ 8 9 ***************************************************************************/ 10 11 /*************************************************************************** 12 * * 13 * This program is free software; you can redistribute it and/or modify * 14 * it under the terms of the GNU General Public License as published by * 15 * the Free Software Foundation; either version 2 of the License, or * 16 * (at your option) any later version. * 17 * * 18 ***************************************************************************/ 19 20 /** @file 21 Robot Module Interface Definition 22 @author <a href=mailto:eric.espie@torcs.org>Bernhard Wymann, Eric Espie</a> 23 @version $Id: robot.h,v 1.10.2.3 2014/05/17 04:50:39 berniw Exp $ 24 @ingroup robotmodint 25 */ 26 27 /** 28 @defgroup robotmodint Robot Module Interface 29 @brief Interface for robot modules, robot modules are discovered and loaded during runtime. 30 31 Multiple robot modules can be loaded at the same time, one robot module can host up to 10 32 instances of a robot. 33 This is the call flow of the robots callbacks during a race event. 34 <br>The square boxes are for the race manager and the ellipses are for the robot. 35 @image html robot_call.gif 36 37 A detailed robot tutorial is available, visit [www.torcs.org](http://www.torcs.org) for details. 38 39 @ingroup modint 40 */ 41 42 #ifndef _ROBOTV1_H_ 43 #define _ROBOTV1_H_ 44 45 #include <raceman.h> 46 47 #define ROB_IDENT 0 48 49 /** Callback function prototype for robot module, give the robot the track view, called for every track change or new race 50 * @ingroup robotmodint 51 * @param[in] index Index of the robot instance 52 * @param[in] track Track 53 * @param[in] carhandle Original car parameter set, intended for read only by the robot 54 * @param[out] myCarSettings Robot instance specific parameter set 55 * @param[in] s Situation 56 */ 57 typedef void (*tfRbNewTrack)(int index, tTrack *track, void *carHandle, void **myCarSettings, tSituation *s); 58 59 /** Callback function prototype for robot module, initialization for new race 60 * @ingroup robotmodint 61 * @param[in] index Index of the robot instance 62 * @param[in] car Car 63 * @param[in] s Situation 64 */ 65 typedef void (*tfRbNewRace) (int index, tCarElt *car, tSituation *s); 66 67 /** Callback function prototype for robot module, teardown after race, this is currently NOT called by TORCS 68 * @ingroup robotmodint 69 * @param[in] index Index of the robot instance 70 * @param[in] car Car 71 * @param[in] s Situation 72 */ 73 typedef void (*tfRbEndRace) (int index, tCarElt *car, tSituation *s); 74 75 /** Callback function prototype for robot module, driving the car 76 * @ingroup robotmodint 77 * @param[in] index Index of the robot instance 78 * @param[in,out] car Car, the tCarCtrl is modified to return the driving commands 79 * @param[in] s Situation 80 */ 81 typedef void (*tfRbDrive) (int index, tCarElt *car, tSituation *s); 82 83 /** Callback function prototype for robot module, shutdown robot instance for given index 84 * @ingroup robotmodint 85 * @param[in] index Index of the robot instance 86 */ 87 typedef void (*tfRbShutdown)(int index); 88 89 /** Callback function prototype for robot module, handing over pit stop commands 90 * @ingroup robotmodint 91 * @param[in] index Index of the robot instance 92 * @param[in,out] car Car, the tCarPitCmd is modified to return the pitstop commands (refuel, repair, setup changes) 93 * @param[in] s Situation 94 * @return 95 * - #ROB_PIT_IM, immediate return from pit command 96 * - #ROB_PIT_MENU, call the interactive menu for pit command 97 */ 98 typedef int (*tfRbPitCmd) (int index, tCarElt* car, tSituation *s); 99 100 #define ROB_PIT_IM 0 /**< Immediate return from pit command */ 101 #define ROB_PIT_MENU 1 /**< Call the interactive menu for pit command */ 102 103 104 /** Interface Structure for Robots 105 @ingroup robotmodint 106 */ 107 typedef struct RobotItf { 108 tfRbNewTrack rbNewTrack; 109 tfRbNewRace rbNewRace; 110 tfRbEndRace rbEndRace; 111 tfRbDrive rbDrive; 112 tfRbPitCmd rbPitCmd; 113 tfRbShutdown rbShutdown; 114 int index; 115 } tRobotItf; 116 117 118 119 /* 120 * Parameters definitions for driver 121 */ 122 #define ROB_SECT_ROBOTS "Robots" 123 124 #define ROB_LIST_INDEX "index" 125 126 #define ROB_ATTR_NAME "name" 127 #define ROB_ATTR_TEAM "team" 128 #define ROB_ATTR_DESC "desc" 129 #define ROB_ATTR_AUTHOR "author" 130 #define ROB_ATTR_CAR "car name" 131 #define ROB_ATTR_CATEGORY "category" 132 #define ROB_ATTR_RACENUM "race number" 133 #define ROB_ATTR_RED "red" 134 #define ROB_ATTR_GREEN "green" 135 #define ROB_ATTR_BLUE "blue" 136 137 #define ROB_ATTR_TYPE "type" 138 139 #define ROB_VAL_HUMAN "human" 140 #define ROB_VAL_ROBOT "robot" 141 142 #define ROB_ATTR_LEVEL "skill level" 143 144 #define ROB_VAL_ROOKIE "rookie" 145 #define ROB_VAL_AMATEUR "amateur" 146 #define ROB_VAL_SEMI_PRO "semi-pro" 147 #define ROB_VAL_PRO "pro" 148 149 #endif /* _ROBOTV1_H_ */ 150 151 152 153