Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 21 and Version 22 of pps/tutorial


Ignore:
Timestamp:
Apr 9, 2011, 8:51:22 PM (13 years ago)
Author:
dafrick
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • pps/tutorial

    v21 v22  
    4141Our goal  is to create a drone in Orxonox that, that does some kind of autonomous flying.
    4242In Orxonox we try our best to separate different kinds of functionality. You will see, that this is also the case here.
    43 In the case of the drone we want to create we separate the drone itself (called AutonomousDrone) from the entity that controls  the drone (called the AutonomousDroneController) and the thing that gives shape and texture to our drone (basically that is the model). Or put more crudely, the AutonomousDrone is the physical entity, the AutonomousDroneController is its intelligence and the model is it's visual representation. This is done for several reasons, the most important being, that with this kind of separation we can have multiple  controllers for just one drone, we could also have one controller for multiple types of flying objects. That makes your code more generic and leads to cleaner code, less dependencies and also less code.
     43In the case of the drone, we want to create, we separate the drone itself (called AutonomousDrone) from the entity that controls  the drone (called the AutonomousDroneController) and the thing that gives shape and texture to our drone (basically that is the model). Or put more crudely, the AutonomousDrone is the physical entity, the AutonomousDroneController is its intelligence and the model is it's visual representation. This is done for several reasons, the most important being, that with this kind of separation we can have multiple  controllers for just one drone, we could also have one controller for multiple types of flying objects. And the behavior of our drone is independent of how it looks like. That makes your code more generic and leads to cleaner code, less dependencies and also less code in general.
    4444
    4545== The AutonomousDrone ==
     
    4848{{{
    4949#!html
    50 <p style="text-align: left; color: red">Note: Do not just copy & paste! Most commands / codelines need to be edited.</p> Otherwise you'll get tons of compiler errors. ;)
     50<p style="text-align: left; color: red">Note: Do not just copy & paste! Most commands / codelines need to be edited. But that doesn't mean you shouldn't copy & paste, but you should stink about whether what you paste should be modified and how.</p>
    5151}}}
    52 We created for you the skeleton of an autonomous drone. You can find the code in the files ''src/orxonox/worldentities/AutonomousDrone.{cc|h}'' and ''src/orxonox/controllers/AutonomousDroneController.{cc|h}''.
     52Otherwise you'll get tons of compiler errors. ;)
     53We created for you the skeleton of an autonomous drone. You can find the code in the files ''src/orxonox/worldentities/AutonomousDrone.{cc|h}'' and ''src/orxonox/controllers/AutonomousDroneController.{cc|h}'' in the trunk folder that you checked out from our repository.
    5354
    5455 1. Open the file ''AutonomousDrone.cc'' and have a look at the code (the file can be found in ''src/orxonox/worldentities/'').
     
    5758CreateFactory(ClassX);
    5859}}}
     60Note: You have to replace ''ClassX'' with the appropriate class.
    5961 3. Make sure that each drone object gets registered to the core by adding a call of ''RegisterObject(Classname)'' inside the constructor.
    6062{{{
    6163RegisterObject(ClassX);
    6264}}}
    63  4. Now go to the function called ''XMLPort'' and add the calls for the two variables ''auxiliaryThrust_'' and ''rotationThrust_''. As you can see, the XMLPort function for the variable ''primaryThurst_'' has already been specified. Now add the calls for the other two variables accordingly, you can compare your function calls to the call for ''primaryThrust_'' to get a feel for, what you have been doing could be correct or not.
     65 4. Now go to the function called ''XMLPort''. ''XMLPort'' allows you to specify how your class can be instantiated (i.e. how an object can be created) purely through XML. This is important when we want to create levels, which in Orxonox are specified in XML files.
     66Add the calls for the two variables ''auxiliaryThrust_'' and ''rotationThrust_''. As you can see, the XMLPort function for the variable ''primaryThurst_'' has already been specified. Now add the calls for the other two variables accordingly, you can compare your function calls to the call for ''primaryThrust_'' to get a feel for, whether what you have been doing could be correct or not.
    6467{{{
    6568XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode)
    6669}}}
    67  '''Note: You need to add set- and get-functions for ''auxiliaryThrust_'' and ''rotationThrust_'' inside the ''AutonomousDrone.h'' file (have a look at {get/set}PrimaryThrust).'''
     70 Note: You need to add set- and get-functions for ''auxiliaryThrust_'' and ''rotationThrust_'' inside the ''AutonomousDrone.h'' file (have a look at {get/set}PrimaryThrust).
    6871 5. Now you need to add the AutonomousDrone to the build system. Open the file ''src/orxonox/worldentities/CMakeLists.txt'' and add ''AutonomousDrone.cc'' to the ORXONOX_SRC_FILES. This makes ''cmake'' consider the ''AutonomousDrone.cc'' file for further builds.
    6972
    7073That's it for the AutonomousDrone class.
    7174
    72 If you have been having problems, consider the following suggestions, that might help you resolve them.
     75If you have been having '''problems''', consider the following suggestions, that might help you resolve them.
    7376 * Is the classname that you specified for ''CreateFactory(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.
    7477 * Have you created 2 set-functions and 2 get-functions for the two variables ''auxiliaryThrust_'' and ''rotationThrust_''?