How to build DJI OnBoard SDK samples on RPi? - cmake

I've got a DJI M100 and a Raspberry Pi connected by serial according to the onboard SDK quickstart guide.
However I've not done a lot of C/C++ stuff before and I am not sure how to even build the samples they provide. I did an apt-get install for cmake since it wasn't installed in the Raspbian distribution I am using.
I messed around a bit and ran cmake CMakeLists.txt and it started doing things and this is the output:
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Git: /usr/bin/git (found version "2.1.4")
cat: /etc/lsb-release: No such file or directory
CMake Error at CMakeLists.txt:70 (if):
if given arguments:
"STREQUAL" "16.04"
Unknown arguments specified
-- Configuring incomplete, errors occurred!
See also "/home/pi/Onboard-SDK-3.1/sample/Linux/Blocking/CMakeFiles/CMakeOutput.log".
Any ideas? I can figure out the coding part, but getting the environment set up is holding me up.
Thanks in advance!

The error message isn't in the C++ compiler, it fails when CMake is trying to deduce what needs to be compiled. that's why the error isn't in a .cpp file but in CmakeLists.txt line 70.

The Onboard-SDK isn't meant to work on Raspbian, you can check it on the link here - https://developer.dji.com/onboard-sdk/documentation/github-platform-docs/Linux/README.html
Maybe it was the reason here. I faced a similar thing even after installing CMAKE on Raspbian.

One simple option is to comment out line 70 or simply remove that line, it might work.
Also it is possible to get Onboard SDK working on Raspbian and I've done so myself by another method.
Here are the commands I used:
sudo apt-get install git
Downloaded and unzipped cmake-3.7.1.tar.gz from https://cmake.org/download/ on desktop
cd /home/pi/Desktop/cmake-3.7.1
./bootstrap
make
sudo make install
Copied Onboard-SDK-3.1 on desktop
cd /home/pi/Desktop/Onboard-SDK-3.1
Copied CMakeLists.txt from /home/pi/Desktop/Onboard-SDK-3.1/sample/Linux/Non-Blocking/CMakeLists.txt to /home/pi/Desktop/Onboard-SDK-3.1 replacing original file
Change Execute Permissions of /home/pi/Desktop/Onboard-SDK-3.1/scripts/build to Anyone
Remove lines 57-59 of CMakeLists.txt in /home/pi/Desktop/Onboard-SDK-3.1
./scripts/build --build-type debug --clean true --lidar-logging off

DJI has apparently added support for Raspbian in January 2017 as they created a branch called raspberrypi-support and committed some changes mostly around Makefiles.
Check out the branch and the associated commit.

Related

Which dev packages are needed to build a QtQuick application on Ubuntu 20.04?

I created a template QtQuick project (for CMake) in Qt Creator and it builds fine in the IDE with "official" Qt SDK.
However, when trying to build in CLI against the system Qt in Ubuntu 20.04 I get:
$ mkdir build
$ cd build
$ cmake ..
-- The CXX compiler identification is GNU 9.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package):
Could not find a package configuration file provided by "Qt5Quick" with any
of the following names:
Qt5QuickConfig.cmake
qt5quick-config.cmake
Add the installation prefix of "Qt5Quick" to CMAKE_PREFIX_PATH or set
"Qt5Quick_DIR" to a directory containing one of the above files. If
"Qt5Quick" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:28 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/juzzlin/QmlTest/build/CMakeFiles/CMakeOutput.log".
What is it that I need to install in addition to qt5-default and qtquickcontrols2-5-dev (not sure if this is needed) ?
The missing package was qtdeclarative5-dev.

CMake error while trying to install gr-osmosdr

I've been trying to install gr-osmosdr for quite some time but I never get to end the installation process. I've followed the steps on https://github.com/osmocom/gr-osmosdr
which show how to install gr-osmosdr via cmake. After cloning and building the "build" directory, it's time for cmake to do its job. It is at this step that things begin to fail. I get the following error:
CMake Warning (dev) at /home/victor/.local/lib/python2.7/site-packages/cmake/data/share/cmake-3.18/Modules/GNUInstallDirs.cmake:225 (message):
Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
target architecture is known. Please enable at least one language before
including GNUInstallDirs.
Call Stack (most recent call first):
CMakeLists.txt:24 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- The CXX compiler identification is GNU 5.4.0
-- The C compiler identification is GNU 5.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Build type not specified: defaulting to release.
CMake Error at CMakeLists.txt:44 (find_package):
Could not find a configuration file for package "Gnuradio" that is
compatible with requested version "3.8".
The following configuration files were considered but not accepted:
/usr/lib/x86_64-linux-gnu/cmake/gnuradio/GnuradioConfig.cmake, version: 3.7.9.1
-- Configuring incomplete, errors occurred!
See also "/home/victor/gr-osmosdr/build/CMakeFiles/CMakeOutput.log".
At this point I'm unable to continue the installation process. I'm running Ubuntu 16.04.7 LTS and GNU Radio 3.7.9.
Thanks
The error message is quite descriptive: You're trying to build a modern GNU Radio 3.8-compatible gr-osmosdr with an ancient GNU Radio 3.7.9.1. Won't work. You could try building an outdated version of gr-osmosdr, but really, instead you should just upgrade to Ubuntu 20.04.
There, you can just
sudo apt install gnuradio gr-osmosdr
and don't have to build anything yourself (it will just work!).

How to configure ev3dev CMake to use cross compiler

I am attempting to build the ev3dev C++ bindings (see https://github.com/ddemidov/ev3dev-lang-cpp) for my EV3. But CMake isn't using my cross-compiler toolchain. I've successfully installed the code sourcery toolchain, built a simple hello world app, and run it on my brick. That works just fine. The trouble is that CMake uses my host's g++ compiler instead of the toolchain. I'm familiar with linux and cross-compilers, but I'm a total CMake noob. So I suspect CMake is where I'm going wrong.
I've added the following lines into CMakeLists.txt:
set(CMAKE_C_COMPILER "/cygdrive/c/Users/me/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-gcc.exe")
set(CMAKE_CXX_COMPILER "/cygdrive/c/Users/me/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-g++.exe")
Here's the host gcc compiler:
$ gcc --version
gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
And the target toolchain gcc compiler:
$ /cygdrive/c/Users/me/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-gcc.exe --version
arm-none-linux-gnueabi-gcc.exe (Sourcery CodeBench Lite 2014.05-29) 4.8.3 20140320 (prerelease)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The compilers are different versions, so they are really easy to distinguish.
Now here's the terminal session for the cmake build:
$ mkdir build
$ cd build
$ cmake ../ -DEV3DEV_PLATFORM=EV3
-- No build type selected, default to RelWithDebInfo
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
CMake Warning at /usr/share/cmake-3.6.2/Modules/Platform/CYGWIN.cmake:15 (message):
CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this warning or
quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
the CMake cache. If later configuration or build errors occur then this
project may have been written under the assumption that Cygwin is WIN32.
In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum
required version of CMake to 2.8.4 or higher. Then teach your project to
build on Cygwin without WIN32.
Call Stack (most recent call first):
/usr/share/cmake-3.6.2/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:7 (project)
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /cygdrive/c/Users/me/Documents/AppProjects/ev3dev-lang-cpp/build
$
CMake is clearly using the cygwin host gcc/g++ compiler even though I've attempted to configure it to use the toolchain. Where am I going wrong?
EDIT: This is not a duplicate of cmake: problems specifying the compiler (2). I did actually use google, and the cross-compiling instructions on the CMake wiki (https://cmake.org/Wiki/CMake_Cross_Compiling) explicitly dictate using SET(). The problem turned out to be that CMake requires the compiler to be set before PROJECT(). I just moved the SET() lines up above PROJECT() and then CMake found the compiler.

Error setting up catkin workspace

I am following these tutorials:
ROS installation in Ubuntu
Create your ROS workspace.
In step catkin_make i'm getting error:
-- The C compiler identification is unknown
CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:186 (configure_file):
configure_file Problem configuring file
-- The CXX compiler identification is unknown
CMake Error at /usr/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:185 (configure_file):
configure_file Problem configuring file
-- Check for working C compiler: /usr/bin/cc
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:47 (try_compile):
Unknown extension ".c" for file
/home/manoj/catkin_ws/build/CMakeFiles/CMakeTmp/testCCompiler.c
try_compile() works only for enabled languages. Currently these are:
C CXX
See project() command to enable other languages.
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
I tried setting environment variables CC and CXX to /usr/bin/gcc and /usr/bin/g++, but to no use.
Also tried a fresh install of cmake, still no use. I am using Ubuntu on Windows Subsystem for Linux.
Help! Thanks in Advance.
try adding the following lines to your CMakeLists.txt before the catkin_package() :
set(CMAKE_C_COMPILER "/usr/bin/gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/g++")
Sometimes, it's also better to clean up your build (usually by deleting the /devel and /build folders in your catkin_ws) and do a fresh catkin_make.
For the record, this approach is not recommended (see here, method 3), but it may help !
The error is with the cmake on WSL. Fix is inbound. Report, discussion & repro's over here: Bash on Windows: Bugs

Compiling code with Qt5 using CMake on Ubuntu 12.04

I have a fairly special setup here and I have not enough knowledge about CMake to find out what is wrong.
I am on Ubuntu 12.04.
I installed Qt5 from apt-add-repository ppa:ubuntu-sdk-team/ppa and CMake 2.8.11.2 from apt-add-repository ppa:kalakris/cmake (https://launchpad.net/~kalakris/+archive/ubuntu/cmake).
Here is the complete, minimal test-case:
daniel#omni-travis-test:~/projects/qtcmaketest$ ls
blubb.cpp CMakeLists.txt
daniel#omni-travis-test:~/projects/qtcmaketest$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
project (qtcmaketest)
find_package (Qt5Widgets REQUIRED)
add_executable(qtcmaketest blubb.cpp)
target_link_libraries (qtcmaketest Qt5::Widgets)
daniel#omni-travis-test:~/projects/qtcmaketest$ cat blubb.cpp
#include <QWidget>
#include <QApplication>
int main (int argc, char * argv[])
{
QApplication app (argc, argv);
QWidget foo;
foo.show ();
}
daniel#omni-travis-test:~/projects/qtcmaketest$ cmake . && make
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/daniel/projects/qtcmaketest
Scanning dependencies of target qtcmaketest
[100%] Building CXX object CMakeFiles/qtcmaketest.dir/blubb.cpp.o
/home/daniel/projects/qtcmaketest/blubb.cpp:1:19: fatal error: QWidget: No such file or directory
#include <QWidget>
^
compilation terminated.
make[2]: *** [CMakeFiles/qtcmaketest.dir/blubb.cpp.o] Error 1
make[1]: *** [CMakeFiles/qtcmaketest.dir/all] Error 2
make: *** [all] Error 2
Why is the include directory missing when find_package was successful?
I was using this guide:
http://qt-project.org/doc/qt-5/cmake-manual.html
I just noticed that, when following the instructions from the chapter "Using Qt 5 with CMake older than 2.8.9", compilation works. I added the following lines:
include_directories(${Qt5Widgets_INCLUDE_DIRS})
add_definitions(${Qt5Widgets_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
I know that this should work without those lines, since it runs on an Ubuntu 14.04 box (which includes the appropriate Qt and CMake versions by default). I don't expected to get a solution to this problem, but I could need some pointers on where to look for the problem.
I'm pretty sure that the problem lies in the version of Qt. I think that this early Qt 5 version does not include the CMake scripts to properly work with find_package alone.
On newer distros with newer Qt 5, it works as expected. Looks like you have to add special version checks to include or exclude the lines I mentioned as a workaround.
Additional info: Since Ubuntu 12.04 is really old, I decided not to support it as a target build platform for my project.
My initial reason was that Travis CI uses 12.04, but since it is so much trouble, I will hold my travis builds until they upgrade to 14.04, which seems to be quite a problem.
Travis tweeted to me, on December, 12th 2014:
Travis CI: We are working on it. Most pieces are there, but there is a critical issue with infrastructure. Thanks for your patience.
Here I recently had the same problem and found the following solution to install newer Qt5 versions which enables cmake to proceed properly:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty universe"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main"
sudo add-apt-repository --yes ppa:kalakris/cmake
sudo apt-get update -qq
sudo apt-get install cmake
sudo apt-get install qdbus qmlscene qt5-default qt5-qmake qtbase5-dev-tools qtchooser qtdeclarative5-dev xbitmaps xterm libqt5svg5-dev qttools5-dev qtscript5-dev qtdeclarative5-folderlistmodel-plugin qtdeclarative5-controls-plugin -y
In the end I ended up using the following .travis.yml file to get things going:
https://github.com/hzdr/qutselect/blob/master/.travis.yml
Hope that also solves your problems.