wiki:clone_demo

Version 1 (modified by Sanahuja Guillaume, 4 years ago) ( diff )

--

How to properly clone a demo

Intro

This page will help you to copy sources of an existing demo and prepare them for your new application.

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.

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.

Cloning a demo

A good practice is to put your sources in a separate folder (assumed to be my_src in this section) from other flair sources. To clone the CircleFollower demo to a new application called MyApp in my_src folder:

cd $FLMAIR_ROOT/my_src
$FLAIR_ROOT/flair-src/scripts/clone_demo.sh $FLAIR_ROOT/flair-src/demos/CircleFollower/ MyApp

Output should be something like that:

cloning CircleFollower/ to MyApp
old project name is CircleFollower

parsing ./CMakeLists.txt
changed reference of CircleFollower to MyApp

parsing ./simulator/CMakeLists.txt
changed reference of CircleFollower to MyApp

parsing ./uav/CMakeLists.txt
renamed src/CircleFollower.cpp to src/MyApp.cpp
renamed src/CircleFollower.h to src/MyApp.h
changed reference of CircleFollower to MyApp

parsing ./uav/src/main.cpp
changed reference of CircleFollower to MyApp

parsing ./uav/src/MyApp.cpp
changed reference of CircleFollower to MyApp

parsing ./simulator/src/main.cpp
changed reference of CircleFollower to MyApp

parsing ./uav/src/MyApp.h
changed reference of CircleFollower to MyApp

parsing ./uav/resources/core2-64/x4.sh
changed reference of CircleFollower to MyApp

parsing ./uav/resources/core2-64/x8.sh
changed reference of CircleFollower to MyApp

parsing ./uav/resources/armv5te/CircleFollower_minidrones.sh
changed reference of CircleFollower to MyApp

parsing ./uav/resources/armv7a-neon/CircleFollower_hdsx8.sh
changed reference of CircleFollower to MyApp

parsing ./uav/resources/armv7a-neon/CircleFollower_bebop.sh
changed reference of CircleFollower to MyApp

parsing ./uav/resources/armv7a-neon/CircleFollower_ardrone2.sh
changed reference of CircleFollower to MyApp

parsing ./simulator/resources/core2-64/simulator_x8.sh
changed reference of CircleFollower to MyApp

parsing ./simulator/resources/core2-64/simulator_x4.sh
changed reference of CircleFollower to MyApp

Showing you the changes made.

You can then build the project with the documentation from this page.

Notes

This script has been successfully tested on the following demos:

  • CircleFollower
  • TwoWheelRobotCircleFollower
  • DemoGps
  • MixedReality
  • DemoOpticalFlow
  • PidStandalone
  • SimpleFleet
  • TwoWheelRobotSimpleFleet
  • Sinus

It also should work to clone your own applications!

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!

Note: See TracWiki for help on using the wiki.