Beginner's Guide to Manipulating Bebop 2 with Unix


#1

Howdy all!

Firstly I’d like to express my excitement and ambition with Parrot’s products; they’re simply wonderful!

As a complete neophyte to the world of drones, I seek guidance in understanding the process of programming for the Bebop drone. I’ve perused the forums and read various resources, however I am still unsure precisely where to begin. Also, I would like to state that my level of skill with Linux is still in development, so the implementation of the requisite libraries and other resources has been quite a challenge.

Nonetheless, my initial goal is to receive data from the Bebop, namely its GPS coordinates and altitude, from a laptop running Ubuntu 14.04. I am aware that this information is available using the FreeFlight Pro app (among many other applications), however for learning purposes I would like to be able to start somewhere relatively simple and retrieve the data myself.

Would it be best to use an ROS to interact with the drone? (Which I believe can be found here.)

Otherwise I have also delved deeply into the ARDroneSDK3, and believe that I have successfully built the SDK, however it is from here where I am having conceptual difficulties.

Once I have the SDK built, the aforementioned guide claims that one is ready to start coding and pairs the instruction with various lines of code, however I am finding this incredibly confusing. Where am I to execute / manipulate this code to achieve my goals?

A summary of my concern is as follows:
What would be the best way to receive (and eventually send) data between a connected Bebop 2 drone and a laptop running Unix?

Your help will be tremendously appreciated as I am currently at my wit’s end. While pointing me in the right direction would be quite helpful, I implore you to more comprehensively explain the beginning steps of this seemingly complex interaction between computer and drone.

Thank you very much!


A standardized method for linking together a unix box for control and recording with a Bebop 2
#2

Hi,

I think the best way is to start from the sample we provide and make them evolve to your needs.
The sample BebopPilotingNewAPI is the one you should use.

In the commandReceive function, add the extract of code LocationChanged.

Best regards,
Djavan


#3

Thank you for your response Djavan! It claims to compile I need to run make, however the make file in the directory does not run - how could I accomplish this?


#4

Hi,

It is explained here.

Regards,
Djavan


#5

Hello Djavan,

I greatly appreciate your patience and assistance. I have successfully built the SDK (I am certain of this as I have checked that the LD_LIBRARY_PATH environment variable contains the proper path) for my Unix machine however there exists an issue when actually running the specific sample.

The folder for the sample BebopPilotingNewAPI contains the makefile atom.mk, however after executing $make atom.mk it states that “Nothing can be done”. Additionally, when running just $make it claims no command is to be found; what could potentially be causing this?

Thank you again for your help.


#6

Hi,

You don’t need the make atom.mk.
Simply do:

./build.sh -p arsdk-native -t build-sample -j
./out/arsdk-native/staging/native-wrapper.sh ./out/arsdk-native/staging/usr/bin/BebopPilotingNewAPI

Best regards,
Djavan


#7

Great, this works perfectly Djavan! However another issue persists - when I edit the code for the file it does not seem to be successfully updating. I am editing the files under ./Samples/Unix/BebopPilotingNewAPI, however I have a hunch that this is not from where the sdk is reading in the files.

My question is: where would I find the explicit files to edit the code for the samples, if not in the aforementioned path?

Thank you.


#8

Hi,

Do you mean under ./packages/Samples/Unix/BebopPilotingNewAPI ? If yes, this is where you should edit the sample.
After that, be sure to rebuild the sample again with:

./build.sh -p arsdk-native -t build-sample -j

And then run it with:

./out/arsdk-native/staging/native-wrapper.sh ./out/arsdk-native/staging/usr/bin/BebopPilotingNewAPI

Regards,
Djavan


#9

Terrific, it works beautifully! I will be back with more questions as I progress, thanks again!


#10

Hi, I’m sorry for coming back on this topic but I have two more questions about Bebop2 and Unix.
I have successfully followed the guide as well as the tips Djavan gave us and everything worked perfectly. Now, I would like to create a new project (from scratch) instead of keeping editing the examples.
I have seen that running the build script as “./build.sh -p arsdk-native -t” I get the following list of possible options:

alchemy : Directly pass commands to alchemy
build-sample : Build all native samples
build-sample-BebopDroneDecodeStream : Build unix sdk sample for BebopDroneDecodeStream
build-sample-BebopDroneReceiveStream : Build unix sdk sample for BebopDroneReceiveStream
build-sample-BebopPilotingNewAPI : Build unix sdk sample for BebopPilotingNewAPI
build-sample-JumpingSumoChangePosture : Build unix sdk sample for JumpingSumoChangePosture
build-sample-JumpingSumoPiloting : Build unix sdk sample for JumpingSumoPiloting
build-sample-JumpingSumoPilotingNewAPI : Build unix sdk sample for JumpingSumoPilotingNewAPI
build-sample-JumpingSumoReceiveStream : Build unix sdk sample for JumpingSumoReceiveStream
build-sdk : Build native sdk
geneclipse : Generate Eclipse CDT project
gensources : Generate all sdk sources

I was wandering how can I run the script on a new project and build it. Moreover, how can I use the parrot sdk in a project of mine? I tried including the libraries in my g++ makefile based project but it can’t link the libraries/functions.

Thank you so much for your guidance and your useful advice.
Best regards,
e.


#11

Hi,
I think I did it… (!!! :grin:)
Please, ignore my previous message.

Thanks,
e.


#12

That’s great! By nature of the forums could you describe what you did to fix your problem to potentially aid others in the future?


#13

Sure… I am attaching the makefiles

subdir.mk.pdf (16.2 KB)
makefile.pdf (19.0 KB)
objects.mk.pdf (9.6 KB)
sources.mk.pdf (9.8 KB)


#14

Hello everyone (this is my first post, the community here looks very healthly)!

I was unable to build the native samples on macOS.

tmba:bebop thill $ ./build.sh -p arsdk-native -t build-sample -j

[..snip..]

Done building all
[I] In '/Users/thill/projects/play/bebop': ln -fs arsdk-native /Users/thill/projects/play/bebop/out/arsdk-native/../Unix-base
[I] Finished task 'build-sdk'

tmba:bebop thill $ ./build.sh -p arsdk-native -t build-sample -j
[I] Starting task 'build-sample'
[I] Starting task 'build-sample-BebopDroneDecodeStream'
[I] In '/Users/thill/projects/play/bebop': ALCHEMY_TARGET_CONFIG_DIR="/Users/thill/projects/play/bebop/products/arsdk/native/config" ALCHEMY_TARGET_OUT="/Users/thill/projects/play/bebop/out/arsdk-native" ALCHEMY_TARGET_PRODUCT="arsdk" ALCHEMY_TARGET_PRODUCT_VARIANT="native" ALCHEMY_TARGET_SCAN_ADD_DIRS=" /Users/thill/projects/play/bebop/packages" ALCHEMY_TARGET_SCAN_PRUNE_DIRS=" /Users/thill/projects/play/bebop" ALCHEMY_USE_COLORS="1" ALCHEMY_WORKSPACE_DIR="/Users/thill/projects/play/bebop" PARROT_BUILD_PROP_GROUP="drones" PARROT_BUILD_PROP_PRODUCT="arsdk" PARROT_BUILD_PROP_PROJECT="arsdk" PARROT_BUILD_PROP_UID="arsdk-native-0.0.0-20161202-2150" PARROT_BUILD_PROP_VARIANT="native" PARROT_BUILD_PROP_VERSION="0.0.0" /Users/thill/projects/play/bebop/build/alchemy/scripts/alchemake -j4 BebopDroneDecodeStream
----------------------------------------------------------------------
+ ALCHEMY_WORKSPACE_DIR = /Users/thill/projects/play/bebop
+ TARGET_PRODUCT = arsdk
+ TARGET_PRODUCT_VARIANT = native
+ TARGET_OS = darwin
+ TARGET_OS_FLAVOUR = native
+ TARGET_LIBC = darwin
+ TARGET_ARCH = x64
+ TARGET_CPU =
+ TARGET_OUT = /Users/thill/projects/play/bebop/out/arsdk-native
+ TARGET_CONFIG_DIR = /Users/thill/projects/play/bebop/products/arsdk/native/config
+ TARGET_CC_PATH = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
+ TARGET_CC_VERSION = 4.2.1
----------------------------------------------------------------------
Scanning /Users/thill/projects/play/bebop/packages for makefiles...
Found       34 makefiles
Prebuilt module ncurses marked as overriden
Prebuilt module json marked as overriden
Package libavcodec was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavcodec.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavcodec' found
Package libavformat was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavformat.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavformat' found
Package libswscale was not found in the pkg-config search path.
Perhaps you should add the directory containing `libswscale.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libswscale' found
Package libavutil was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavutil.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavutil' found
Package libavcodec was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavcodec.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavcodec' found
Package libavformat was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavformat.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavformat' found
Package libswscale was not found in the pkg-config search path.
Perhaps you should add the directory containing `libswscale.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libswscale' found
Package libavutil was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavutil.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavutil' found
Found 41 modules
Computing modules dependencies...
Checking modules dependencies...
BebopDroneDecodeStream is not enabled in the config
Generating rules...
Processing rules...
libARCommands: Generating arsdk files
x64 C: BebopDroneDecodeStream <= packages/Samples/Unix/BebopDroneDecodeStream/BebopDroneDecodeStream.c
x64 C: BebopDroneDecodeStream <= packages/Samples/Unix/BebopDroneDecodeStream/DecoderManager.c
x64 C: BebopDroneDecodeStream <= packages/Samples/Unix/BebopDroneDecodeStream/ihm.c
packages/Samples/Unix/BebopDroneDecodeStream/DecoderManager.c:11:10: fatal error: 'libavcodec/avcodec.h' file not found
#include <libavcodec/avcodec.h>
         ^
1 error generated.
packages/Samples/Unix/BebopDroneDecodeStream/BebopDroneDecodeStream.c:49:10: fatal error: 'libavformat/avformat.h' file not found
#include <libavformat/avformat.h>
         ^
make: *** [/Users/thill/projects/play/bebop/out/arsdk-native/build/BebopDroneDecodeStream/obj/DecoderManager.c.o] Error 1
make: *** Waiting for unfinished jobs....
1 error generated.
make: *** [/Users/thill/projects/play/bebop/out/arsdk-native/build/BebopDroneDecodeStream/obj/BebopDroneDecodeStream.c.o] Error 1

MAKE ERROR DETECTED
[E] Task 'build-sample-BebopDroneDecodeStream' failed (Command failed (returncode=2))

I was able to fix this by installing ffmpeg:

tmba:bebop thill $ brew install ffmpeg
==> Installing dependencies for ffmpeg: lame, x264, xvid
==> Installing ffmpeg dependency: lame
==> Downloading https://homebrew.bintray.com/bottles/lame-3.99.5.sierra.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring lame-3.99.5.sierra.bottle.1.tar.gz
🍺  /usr/local/Cellar/lame/3.99.5: 26 files, 2M
==> Installing ffmpeg dependency: x264
==> Downloading https://homebrew.bintray.com/bottles/x264-r2708.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring x264-r2708.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/x264/r2708: 11 files, 3.3M
==> Installing ffmpeg dependency: xvid
==> Downloading https://homebrew.bintray.com/bottles/xvid-1.3.4.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring xvid-1.3.4.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/xvid/1.3.4: 9 files, 1.2M
==> Installing ffmpeg
==> Downloading https://homebrew.bintray.com/bottles/ffmpeg-3.2.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ffmpeg-3.2.1.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/ffmpeg/3.2.1: 239 files, 50.4M

After that rerunning this command built the samples successfully.

tmba:bebop thill $ ./build.sh -p arsdk-native -t build-sample -j

To run the BebopPilotingNewAPI sample I then had to run:

./out/arsdk-native/staging/native-darwin-wrapper.sh ./out/arsdk-native/staging/usr/bin/BebopPilotingNewAPI

This resulted in XQuartz launching mplayer in xterm and:

[INF] SDKExample | 22:11:52:097 | main:151 - Select your Bebop : Bebop (1) ; Bebop2 (2)
2
[INF] SDKExample | 22:11:53:618 | main:161 - -- Bebop 2 Piloting --
tmba:bebop thill $ echo $?
0

But as you can see the program exited and never presented me with flight controls and I do not know why.
Any explanation would be much appreciated.

Hopefully this helps someone, somehow!

Edit

I reran the sample and got the video as expected and was able to pilot the UAV from my laptop, awesome!


#15

Hello @elBarto,

I’m attempting to do a similar task, simply compile a particular sample instead of all the ones shown in the file, however simply deleting these files does not work as Alchemy seems to be searching for the makefile regardless. How would you recommend doing this?

Thank you


#16

Hello @mmmeh,
actually you don’t have to delete any file. Just copy the files BebopPiloting.c and BebopPiloting.h to a new folder and put the makefile[s] in the same folder.
Then, you have to run the “make” command… this way, you will compile using just gcc instead of Alchemy.


#17

Thanks for your response @elBarto, however I am struggling to successfully craft a make file to execute the c files that will also import the appropriate header files e.g. libARCommands, libARController, etc.

What would the makefile look like to accomplish this?


#18

Hi,

Basically, you have two ways of doing this.

Using Alchemy (the SDK build system)

  • Put your application in a subfolder of the <SDK>/packages folder (this is where Alchemy scans for packages)
  • Create an atom.mk file in your application folder. you can use the <SDK>/packages/Samples/Unix/BebopSample/atom.mk file as an example, or look the complete documentation online.
  • You can then build you application with the following command: build.sh -p native -A your_app (with ‘your_app’ being the name put in the LOCAL_MODULE variable of the atom.mk)
  • And run it like the samples.

Without Alchemy, using a Makefile or any other mean:

  • Add the <SDK>/out/arsdk-native/staging/usr/include folder to your include path
  • Add the <SDK>/out/arsdk-native/staging/usr/lib to your library path
  • Add any required library as ldflags (e.g. -larsal -lardiscovery -larnetworkal -larnetwork -larcommands -larcontroller [...]). You will probably have to add all the SDK libraries in the good order.
  • When running your application, add the <SDK>/out/arsdk-native/staging/usr/lib path to the LD_LIBRARY_PATH environment variable (e.g. LD_LIBRARY_PATH=<SDK>/out/arsdk-native/staging/usr/lib ./your_app)

Regards,
Nicolas


Read all the sensor of bebop Drone 2
How write our samples
How to create project in ubuntu
Help for beginners Unix - mac OS X
#19

Nicolas,

Thank you so very much for your reply, this successfully resolved my issue!


#20

Hi!
@Nicolas Thanks a lot!!
I made great progress … but I find new obstacles.
Possible could you help me to understand the error report below.
Best
Mariana

Undefined symbols for architecture x86_64:
  "_delwin", referenced from:
  _IHM_Delete in ihm.o
  "_endwin", referenced from:
  _IHM_Delete in ihm.o
  "_initscr", referenced from:
  _IHM_New in ihm.o
  "_keypad", referenced from:
  _IHM_New in ihm.o
  "_mvprintw", referenced from:
  _IHM_PrintHeader in ihm.o
  _IHM_PrintInfo in ihm.o
  _IHM_PrintBattery in ihm.o
  "_noecho", referenced from:
  _IHM_New in ihm.o
  "_raw", referenced from:
  _IHM_New in ihm.o
  "_stdscr", referenced from:
  _IHM_New in ihm.o
  _IHM_InputProcessing in ihm.o
  _IHM_Delete in ihm.o
  _IHM_PrintHeader in ihm.o
  _IHM_PrintInfo in ihm.o
  _IHM_PrintBattery in ihm.o
  "_wclrtoeol", referenced from:
  _IHM_PrintHeader in ihm.o
  _IHM_PrintInfo in ihm.o
  _IHM_PrintBattery in ihm.o
  "_wgetch", referenced from:
  _IHM_InputProcessing in ihm.o
  "_wmove", referenced from:
  _IHM_PrintHeader in ihm.o
  _IHM_PrintInfo in ihm.o
  _IHM_PrintBattery in ihm.o
  "_wrefresh", referenced from:
  _IHM_New in ihm.o
  _IHM_Delete in ihm.o
  "_wtimeout", referenced from:
  _IHM_New in ihm.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)