| 1 | [[PageOutline]] |
| 2 | |
| 3 | = How to properly clone a demo = |
| 4 | |
| 5 | == Intro == |
| 6 | |
| 7 | This page will help you to copy sources of an existing demo and prepare them for your new application. |
| 8 | |
| 9 | A script is provided to do that, it will change any references from the old demo to the new one. If needed, it will rename source files, change the name of the classes, adapt the CMakeLists.txt and adapt the launch scripts for both uav and simulator. |
| 10 | |
| 11 | This is very useful if you want to base your work on an existing demo. **Just copying source files from the demos is not a good practice.** |
| 12 | |
| 13 | == Cloning a demo == |
| 14 | |
| 15 | A good practice is to put your sources in a separate folder (assumed to be ''my_src'' in this section) from other flair sources. |
| 16 | To clone the !CircleFollower demo to a new application called !MyApp in ''my_src'' folder: |
| 17 | {{{ |
| 18 | cd $FLMAIR_ROOT/my_src |
| 19 | $FLAIR_ROOT/flair-src/scripts/clone_demo.sh $FLAIR_ROOT/flair-src/demos/CircleFollower/ MyApp |
| 20 | }}} |
| 21 | Output should be something like that: |
| 22 | {{{ |
| 23 | cloning CircleFollower/ to MyApp |
| 24 | old project name is CircleFollower |
| 25 | |
| 26 | parsing ./CMakeLists.txt |
| 27 | changed reference of CircleFollower to MyApp |
| 28 | |
| 29 | parsing ./simulator/CMakeLists.txt |
| 30 | changed reference of CircleFollower to MyApp |
| 31 | |
| 32 | parsing ./uav/CMakeLists.txt |
| 33 | renamed src/CircleFollower.cpp to src/MyApp.cpp |
| 34 | renamed src/CircleFollower.h to src/MyApp.h |
| 35 | changed reference of CircleFollower to MyApp |
| 36 | |
| 37 | parsing ./uav/src/main.cpp |
| 38 | changed reference of CircleFollower to MyApp |
| 39 | |
| 40 | parsing ./uav/src/MyApp.cpp |
| 41 | changed reference of CircleFollower to MyApp |
| 42 | |
| 43 | parsing ./simulator/src/main.cpp |
| 44 | changed reference of CircleFollower to MyApp |
| 45 | |
| 46 | parsing ./uav/src/MyApp.h |
| 47 | changed reference of CircleFollower to MyApp |
| 48 | |
| 49 | parsing ./uav/resources/core2-64/x4.sh |
| 50 | changed reference of CircleFollower to MyApp |
| 51 | |
| 52 | parsing ./uav/resources/core2-64/x8.sh |
| 53 | changed reference of CircleFollower to MyApp |
| 54 | |
| 55 | parsing ./uav/resources/armv5te/CircleFollower_minidrones.sh |
| 56 | changed reference of CircleFollower to MyApp |
| 57 | |
| 58 | parsing ./uav/resources/armv7a-neon/CircleFollower_hdsx8.sh |
| 59 | changed reference of CircleFollower to MyApp |
| 60 | |
| 61 | parsing ./uav/resources/armv7a-neon/CircleFollower_bebop.sh |
| 62 | changed reference of CircleFollower to MyApp |
| 63 | |
| 64 | parsing ./uav/resources/armv7a-neon/CircleFollower_ardrone2.sh |
| 65 | changed reference of CircleFollower to MyApp |
| 66 | |
| 67 | parsing ./simulator/resources/core2-64/simulator_x8.sh |
| 68 | changed reference of CircleFollower to MyApp |
| 69 | |
| 70 | parsing ./simulator/resources/core2-64/simulator_x4.sh |
| 71 | changed reference of CircleFollower to MyApp |
| 72 | }}} |
| 73 | Showing you the changes made. |
| 74 | |
| 75 | You can then build the project with the documentation from [wiki:compile_all#Compileyourownproject this page]. |
| 76 | |
| 77 | == Notes == |
| 78 | |
| 79 | This script has been successfully tested on the following demos: |
| 80 | |
| 81 | * !CircleFollower |
| 82 | * !TwoWheelRobotCircleFollower |
| 83 | * !DemoGps |
| 84 | * !MixedReality |
| 85 | * !DemoOpticalFlow |
| 86 | * !PidStandalone |
| 87 | * !SimpleFleet |
| 88 | * !TwoWheelRobotSimpleFleet |
| 89 | * Sinus |
| 90 | |
| 91 | It also should work to clone your own applications! |
| 92 | |
| 93 | **NB**: the script heavily relies on ''sed'' to replace strings. It can make mistakes if the source or the destination project name is contained in an existing class or method of flair! |
| 94 | |