Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 2 (modified by scheusso, 16 years ago) (diff)

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 download page and make sure you have all dependencies installed.

Preparations

We check out the source and media 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 media repository (you will probably be asked for a username and password once):
    svn co https://svn.orxonox.net/data/media
    
  3. Now get the latest revision of the tutorial:
    svn co https://svn.orxonox.net/orxonox/branches/tutorial
    
  4. Prepare to build:
    mkdir tutorial/build
    cd tutorial/build
    cmake ..
    
  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 KDevelop3? as IDE to develop (if you don't want to use the console ;))

Start the game for the first time

  1. 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
    

The Drone

We 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/controlles/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_.
    XMLPortParamVariable(Classname, "xml-attribute-name", variablename, xmlelement, mode)
    

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)
    

The XML Part

Now that you finished the classes you can recompile the project. Afterwards open the level file:

  1. open media/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:
    <ClassX variable1="2" string1="blabla" coord1="1,0,0">
    </ClassX>
    
  3. now add the appropriate entries for the variables you defined in Drone/4.
  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:
      <attached>
        <Model scale="10" mesh="drone.mesh"/>
      </attached>
    
    this adds a model with the mesh drone.mesh and the defined textures at the position of our drone object.
  1. because the physic engine needs a collision shape to work we will add the following entry (before </ClassX>):
      <collisionShapes>
        <BoxCollisionShape position="0,0,0"      halfExtents="10, 10, 10" />
      </collisionShapes>
    
    this will tell the phyic engine what dimensions our drone has (in this case its just a cube)