Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 69 and Version 70 of pps/tutorial


Ignore:
Timestamp:
Oct 3, 2016, 4:34:06 PM (8 years ago)
Author:
zifloria
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • pps/tutorial

    v69 v70  
    1212
    1313== Before you start coding ==
    14 Before you start coding there's one [wiki:howto/XMLPort page] which is extremely useful for the following tasks. You might want to have a look at it.
     14Before you start coding there's one [wiki:howto/XMLPort page] which is extremely useful for the following tasks. You might want to have it open in the background.
    1515
    1616== The task ==
     
    2121The implementation of our drone will happen in three steps:
    2222 * '''The AutonomousDrone:''' Core C++ code for the AutonomousDrone class, contains the C++ ↔  XML interface
     23 * '''The XML part:''' An instantiation in the level file
    2324 * '''The AutonomousDroneController:''' Controller C++ code to steer the drone
    24  * '''The XML part:''' An instantiation in the level file
    2525
    2626== The AutonomousDrone ==
     
    6565to add some code to the XMLPort function. There is already an example for the ''primaryThrust_'' variable.
    6666
    67 4. Inside XMLPort, add similar calls for ''auxiliaryThrust_'' and ''rotationThrust_'' using the following scheme:
     67 4. Inside XMLPort, add similar calls for ''auxiliaryThrust_'' and ''rotationThrust_'' using the following scheme:
    6868
    6969{{{
     
    8282 * Is the classname that you specified for ''RegisterClass(Classname)'' and ''RegisterObject(Classname)'' correct? If it is either ''Classname'', ''ClassX'' or ''ClassXY'', then it is incorrect, try to think about what it should be. If you can't find the solution ask one of the assistants.
    8383 * Have you created 2 set-functions and 2 get-functions for the two variables ''auxiliaryThrust_'' and ''rotationThrust_''?
     84 * Did you edit the ''CMakeList.txt'' file?
    8485
    85 == The AutonomousDroneController ==
    86 Now you will finish the AutonomousDroneController which gets called each tick and steers the drone using the functionality of movement in the game world that the drone provides. i.e. the drone's intelligence.
    87 
    88  1. Open the file ''AutonomousDroneController.cc'' and look at it (''src/orxonox/controllers/'').
    89  2. Have a look at the constructor and make sure nothing is missing (think of the what we did for the AutonomousDrone).
    90  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:
    91 {{{
    92 rnd() // Return a random value between 0 and 1
    93 sin() // Should be clear (also cos)
    94 // Many other functions (have a look at src/util/Math.h for details)
    95 }}}
    96  4. Repeat step 5 (CMakeLists) of the AutonomousDrone for the AutonomousDroneController.
    97 
    98 Again if you have been having '''problems''' consider the following suggestions:
    99  * Did you register the object and create a factory for it? If not or you don't know what this means, have a look at steps 2 and 3 of the AutonomousDrone and think about how this applies to the AutonomousDroneController.
    10086
    10187== The XML Part ==
    102 As a last step we will include the drone in our level and add the visual part of the drone, the model (and some other stuff, too).
     88Next we will include the drone in our level and add the visual part of the drone, the model.
    10389
    104 Now that you finished the classes you can recompile the project. This is again done by typing in the console:
    105 {{{
    106 make -j3
    107 }}}
    108 
    109 Afterwards open the level file:
    110  1. Open ''tutorial/data/levels/tutorial.oxw''.
     90Open the level file:
     91 1. Open ''trunk/data/levels/tutorial.oxw''.
    11192 2. We want to add a drone to the level now, so put in an entry for it (below the comment that tells you to do so). Look at this example:
    11293{{{
     
    142123 }}}
    143124
    144  7. The controller would normally be added to the AutonomousDrone in XML, but as we're currently updating
    145  the framework, we need to add this outside the AutonomousDrone. Add these two lines below the AutonomousDrone
    146  entry above:
     125 7. Test it! E.g. start the game, open the level ''Coding tutorial'' and you should be able to see the drone.
     126
     127It's a bit boring, as it doesn't move yet. This is the job of the controller.
     128
     129
     130== The AutonomousDroneController ==
     131Now you will finish the AutonomousDroneController which gets called each tick and steers the drone using the functionality of movement in the game world that the drone provides. i.e. the drone's intelligence.
     132
     133 1. Open the file ''AutonomousDroneController.cc'' and look at it (''src/orxonox/controllers/'').
     134 2. Have a look at the constructor and make sure nothing is missing (think of the what we did for the AutonomousDrone).
     135 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 (for instance by using the moveFrontBack function). If you want you can use some functions provided by Math.h:
     136{{{
     137rnd() // Return a random value between 0 and 1
     138sin() // Should be clear (also cos)
     139// Many other functions (have a look at src/util/Math.h for details)
     140}}}
     141 4. Repeat step 5 (CMakeLists) of the AutonomousDrone for the AutonomousDroneController.
     142
     143 5. Compile it.
     144
     145{{{
     146make -j3
     147}}}
     148
     149Again if you have been having '''problems''' consider the following suggestions:
     150 * Did you edit the correct CMakeList.txt?
     151 * Did you register the object and create a factory for it? If not or you don't know what this means, have a look at steps 2 and 3 of the AutonomousDrone and think about how this applies to the AutonomousDroneController.
     152
     153
     154  6. To see any change, you need to edit the level file again.
     155  To do that, add these two lines below the AutonomousDrone (or anywhere in between the scene tags):
    147156 {{{
    148157 <AutonomousDroneController>
     
    150159 }}}
    151160
     161
    152162== Have a look at your AutonomousDrone ==
    153  - Now recompile the code, start the game again and have a look at how your drone behaves.
     163 - Now start the game again and have a look at how your drone behaves.
    154164 - Don't worry if it does not react to your steering commands as expected. Try to modify some things.
    155165 - If you want to do some more things you can try to let the drone fly in circles or helixes.