= Basic PPS Tutorial = This is a basic tutorial for new PPS students to get familiar with our framework and build environment. The process is described for tardis here. If you use another system first go to the [wiki:download] page and make sure you have all dependencies installed. == Preparations == '''We check out the source and data repository and build for the first time''' 1. Create your orxonox directory (if not already existing): {{{ mkdir ~/orxonox cd ~/orxonox }}} 2. Now check out the latest revision of the data repository (you will probably be asked for a username and password once): {{{ svn co https://svn.orxonox.net/game/data/trunk data_extern }}} 3. Now get the latest revision of the tutorial: {{{ svn co https://svn.orxonox.net/game/code/branches/tutorial }}} 4. Prepare to build: {{{ mkdir tutorial/build cd tutorial/build cmake-2.6.2 .. }}} 5. Now build for the first time (may take some time, further builds will be faster): {{{ make -j4 #-j4 means to create 4 parallel compile processes }}} 6. Additionally you can use [wiki:KDevelop3] as IDE to develop (if you don't want to use the console ;)) '''Start the game for the first time''' 7. Enter to the appropriate folder and start the game. You will see a menu popping up, just press the ''Standalone'' button. {{{ cd ~/orxonox/tutorial/build ./run }}} == Before you start coding == Before you start coding there's one [wiki:howto/XMLPort page] which is extremely usefull for the following tasks. You might want to have a look at it. == The Drone == {{{ #!html
Note: Do not just copy & paste! Most commands / codelines need to be edited.
Otherwise you'll get tons of compiler errors ;) }}} We created for you the skeleton of an autonomous drone. You can find the code in the files 'src/orxonox/worldentities/Drone.{cc|h}' and 'src/orxonox/controllers/DroneController.{cc|h}'. 1. open the file Drone.cc and have a look at the code 2. in order to be able to create a Drone object from the xml file or somewhere else just by the class name you need to add a call of CreateFactory(Classname) somewhere inside the cc file (global, inside the namespace) {{{ CreateFactory(ClassX) }}} 3. make sure the each drone object gets registered to the core by adding a call of RegisterObject(Classname) inside the constructor {{{ RegisterObject(ClassXY) }}} 4. now go to the XMLPort function and add the calls for the three variables primaryThrust_, auxilaryThrust_ and rotationThrust_. {{{ XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode) }}} '''Note: You need to add set- and get-functions for auxilaryThrust_ and rotationThrust_ inside the Drone.h file (have a look at {get/set}PrimaryThrust).''' 5. now you need to add the Drone to the build system. Open the file src/orxonox/worldentities/CMakeLists.txt and add Drone.cc to the ORXONOX_SRC_FILES. This makes cmake consider the Drone.cc file for further builds. That's it for the Drone class == The DroneController == Now you will finish the DroneController which gets called each tick and steers the drone. 1. open the file DroneController.cc and look at it 2. have a look at the constructor and make sure nothing is missing (think of the core) 3. now look at the tick function. it gets called each time before a new frame is drawn. you can put in some steering code here. if you want you can use some functions provided by Math.h: {{{ rnd() // return a random value between 0 and 1 sin() // should be clear (also cos) // many other functions (have a look at src/util/Math.h for details) }}} 4. repeat step 5 (CMakeLists) of the Drone for the DroneController. == The XML Part == Now that you finished the classes you can recompile the project. Afterwards open the level file: 1. open tutorial/data/levels/tutorial.oxw 2. we want to add a drone to the level now, so put in an entry for it (below the Light definition). look at this example: {{{