Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of pps/tutorial


Ignore:
Timestamp:
Sep 11, 2009, 10:58:46 AM (15 years ago)
Author:
scheusso
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • pps/tutorial

    v1 v1  
     1= Basic PPS Tutorial =
     2This 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.
     3
     4== Preparations ==
     5'''We check out the source and media repository and build for the first time'''
     6 1. Create your orxonox directory (if not already existing):
     7{{{
     8mkdir ~/orxonox
     9cd ~/orxonox
     10}}}
     11 2. Now check out the latest revision of the media repository (you will probably be asked for a username and password once):
     12{{{
     13svn co https://svn.orxonox.net/game/data/trunk data_extern
     14}}}
     15 3. Now get the latest revision of the tutorial:
     16{{{
     17svn co https://svn.orxonox.net/game/code/branches/tutorial
     18}}}
     19 4. Prepare to build:
     20{{{
     21mkdir tutorial/build
     22cd tutorial/build
     23cmake-2.6.2 ..
     24}}}
     25 5. Now build for the first time (may take some time, further builds will be faster):
     26{{{
     27make -j4  #-j4 means to create 4 parallel compile processes
     28}}}
     29 6. Additionally you can use [wiki:KDevelop3] as IDE to develop (if you don't want to use the console ;))
     30'''Start the game for the first time'''
     31 7. Enter to the appropriate folder and start the game. You will see a menu popping up, just press the ''Standalone'' button.
     32{{{
     33cd ~/orxonox/tutorial/build
     34./run
     35}}}
     36
     37== The Drone ==
     38We created for you the skeleton of an autonomous drone. You can find the code in the files 'src/orxonox/objects/worldentities/Drone.{cc|h}' and 'src/orxonox/objects/controllers/DroneController.{cc|h}'.
     39
     40 1. open the file Drone.cc and have a look at the code
     41 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)
     42{{{
     43CreateFactory(ClassX)
     44}}}
     45 3. make sure the each drone object gets registered to the core by adding a call of RegisterObject(Classname) inside the constructor
     46{{{
     47RegisterObject(ClassXY)
     48}}}
     49 4. now go to the XMLPort function and add the calls for the three variables primaryThrust_, auxilaryThrust_ and rotationThrust_.
     50{{{
     51XMLPortParamVariable(Classname, "xml-attribute-name", variablename, xmlelement, mode)
     52}}}
     53
     54That's it for the Drone class
     55
     56== The DroneController ==
     57Now you will finish the DroneController which gets called each tick and steers the drone.
     58 1. open the file DroneController.cc and look at it
     59 2. have a look at the constructor and make sure nothing is missing (think of the core)
     60 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:
     61{{{
     62rnd() // return a random value between 0 and 1
     63sin() // should be clear (also cos)
     64// many other functions (have a look at src/util/Math.h for details)
     65}}}
     66
     67== The XML Part ==
     68Now that you finished the classes you can recompile the project. Afterwards open the level file:
     69 1. open media/levels/tutorial.oxw
     70 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:
     71{{{
     72<ClassX variable1="2" string1="blabla" coord1="1,0,0">
     73</ClassX>
     74}}}
     75 3. now add the appropriate entries for the variables you defined in Drone/4. (Have a look at media/levels/spaceshiptemplates_physics.oxw for example values)
     76 4. as we want our drone to be visible we have to attach a model to it. add the following code between the above 2 lines:
     77{{{
     78  <attached>
     79    <Model scale="10" mesh="drone.mesh"/>
     80  </attached>
     81}}}
     82 this adds a model with the mesh drone.mesh and the defined textures at the position of our drone object.
     83
     84 5. because the physics engine needs a collision shape to work with, we will add the following entry (before </ClassX>):
     85{{{
     86  <collisionShapes>
     87    <BoxCollisionShape position="0,0,0"      halfExtents="10, 10, 10" />
     88  </collisionShapes>
     89}}}
     90 this will tell the physics engine what dimensions our drone has (in this case its just a cube)
     91 6. now we define the mass and two damping parameters of our drone. Append definitions for the following variables as attributes to your drone (as in 3.)
     92{{{
     93mass = 50
     94linearDamping = 0.9
     95angularDamping = 0.7
     96}}}
     97
     98== Have a look at your Drone ==
     99 - Now recompile the code, start the game again and have a look at how your drone behaves.
     100 - Don't worry if it does not react to your steering commands as expected. Try to modify some things.
     101 - If you want to do some more things you can to try let the drone fly in circles or helixes
     102 - Play around a little bit with the linear/angular-Damping parameters
     103
     104== Commit your code to the repository ==
     105We may want to use your steering function later on, so commit it now:
     106 1. make sure you have a recent version of the branch
     107{{{
     108~/orxonox/tutorial$ svn up
     109}}}
     110 2. in order to avoid conflicts copy your file (DroneController.cc)
     111{{{
     112~/orxonox/tutorial$ svn cp src/orxonox/objects/controllers/DroneController.cc src/orxonox/objects/controllers/DroneController.cc_myUserName
     113}}}
     114 3. make sure you dont commit any changes of the original file, so revert your local changes on it:
     115{{{
     116~/orxonox/tutorial$ svn revert src/orxonox/objects/controllers/DroneController.cc
     117}}}
     118 4. now commit
     119{{{
     120~/orxonox/tutorial$ svn ci -m"this is my version of the Drone steering function" src/orxonox/controllers/DroneController.cc_myUserName
     121}}}