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. |
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 | |
| 127 | It's a bit boring, as it doesn't move yet. This is the job of the controller. |
| 128 | |
| 129 | |
| 130 | == The AutonomousDroneController == |
| 131 | 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. |
| 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 | {{{ |
| 137 | rnd() // Return a random value between 0 and 1 |
| 138 | sin() // 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 | {{{ |
| 146 | make -j3 |
| 147 | }}} |
| 148 | |
| 149 | Again 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): |