app4mc-rover / rover-app

roverapp Software (C/C++) for APP4MC Rover project
https://app4mc-rover.github.io/rover-docs
Eclipse Public License 1.0
7 stars 6 forks source link

Manually installing rover-app on AGL #13

Open phil-hei opened 5 years ago

phil-hei commented 5 years ago

I need to change the "rover::RoverMQTTCommand::subscribeToDrivingTopic" in https://github.com/app4mc-rover/rover-app/blob/master/src/roverapi/rover_mqttcommand.cpp that the mqtt client subscribes to "control/+/+/req/#" instead of "rover/1/driving..".

However, building the image currently fails and thus the rover-app has to be altered and manually installed on the Rover. I found the following scripts:

Are they still valid for AGL or are they intended for raspbian? If so we maybe should remove them?

phil-hei commented 5 years ago

Ok, this files seems to be related with Raspbian as I can't use cmake on the Rover. Is there any way to manually update the rover-app on the Rover?

pjcuadra commented 5 years ago

Most of the functionality of the app4mc/rover-app is available through app4mc/rover-services. The second uses the roverapi from app4mc/rover-app as a library to reuse code. However the rover-app executable is deprecated in AGL. If you need to update roverapi libraries then you'll need to;

  1. Cross-compile the roverapi from this repository using the AGL SDK. When running cmake add the -DINSTAL_PREFIX=/opt/rover/<version>/<arm*>/sysroot/usr/.
  2. scp the compiled libraries and headers to rover. This will replace the current version of the library to which the rover-services link dynamically.
  3. Run make install to also update the library and headers in your AGL SDK. This will enable you to cross-compile newer versions of rover-services using the updated version of roverapi.

I recommend to install the AGL SDK again in another path so you don't mess with your current SDK binaries.

Ideally the roverapi changes should be propagated to the AGL image/SDK by updating the roverapi/rover-app recipe in the corresponding layer (meta-kuksa). Do this after testing the roverapi changes. This way your changes will be available for other developers and spearing their time (since they won't need to perform the steps explained above).

phil-hei commented 5 years ago

Thanks Pedro, that sounds like a good workaround. The changes will be published to the git repo, but therefore we'll completely redesign the cloud services (telemetry service etc.), which require some time.

One question I've after having a closer look to the topic is at which point the rover api is pulled from github and integrated in the build? I expected the meta-rover layer to do that but couldn't find it there.

pjcuadra commented 5 years ago

Here's the bitbake recipe that builds and installs the roverapi libraries. https://github.com/app4mc-rover/meta-rover/blob/master/recipes-rover/rover-app/rover-app_0.1.6.bb

phil-hei commented 5 years ago

Ah thanks. The AGL-Kuksa at our gitlab pointed to an old repo (https://github.com/meta-rover/meta-rover).

When running cmake, I get the following error:

"HEAD ist jetzt bei ca63407... chg: dev: Fix rover-app building from scratch -- Using AGL layers agl-demo agl-netboot agl-appfw-smack -- Using raspberrypi3 Architecture -- Using AGL root directory /home/heisig/appstacle/agl-kuksa/build/agl -- Cloning AGL fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle fatal: error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)"

What is this for a repo and do you maybe know what is the reason for failing?

daleonpz commented 5 years ago

Hi,

I got this error:

[ 43%] Building CXX object CMakeFiles/roverapi.dir/src/roverapi/rover_pahomqtt.cpp.o
In file included from /home/dnl/Documents/gitStuff/rover-app/include/roverapi/rover_pahomqtt.hpp:26,
                 from /home/dnl/Documents/gitStuff/rover-app/src/roverapi/rover_pahomqtt.cpp:17:
/home/dnl/Documents/gitStuff/rover-app/src/roverapi/rover_pahomqtt.cpp: In member function ‘int rover::RoverPahoMQTT::unsubscribe()’:
/home/dnl/Documents/gitStuff/rover-app/src/roverapi/rover_pahomqtt.cpp:200:20: error: no match for ‘operator=’ (operand types are ‘MQTTAsync_disconnectOptions’ and ‘<brace-enclosed initializer list>’)
  this->disc_opts = MQTTAsync_disconnectOptions_initializer;
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/MQTTAsync.h:1112:3: note: candidate: ‘MQTTAsync_disconnectOptions& MQTTAsync_disconnectOptions::operator=(const MQTTAsync_disconnectOptions&)’
 } MQTTAsync_disconnectOptions;
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/MQTTAsync.h:1112:3: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const MQTTAsync_disconnectOptions&’
/usr/local/include/MQTTAsync.h:1112:3: note: candidate: ‘MQTTAsync_disconnectOptions& MQTTAsync_disconnectOptions::operator=(MQTTAsync_disconnectOptions&&)’
/usr/local/include/MQTTAsync.h:1112:3: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘MQTTAsync_disconnectOptions&&’
make[2]: *** [CMakeFiles/roverapi.dir/build.make:258: CMakeFiles/roverapi.dir/src/roverapi/rover_pahomqtt.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:529: CMakeFiles/roverapi.dir/all] Error 2

I didn't modify any file. Here's what I executed in the build folder:

$ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/
$ make install 
pjcuadra commented 5 years ago

Since it's looking for the headers at /usr/local/include, it looks like you haven't source the Rover SDK environment.

Try removing the build directory, source the SDK, and then build as in your did.

pjcuadra commented 5 years ago

Any update on this?

phil-hei commented 5 years ago

We still get the error when running 'make install', even with sourced environment. We'll have a closer look at that tomorrow

phil-hei commented 5 years ago

Ok, an update: I get the following error when running 'make install'

[ 46%] Built target roverapi Scanning dependencies of target roverapptasks [ 48%] Building CXX object CMakeFiles/roverapptasks.dir/src/tasks/accelerometer_task.cpp.o In file included from /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/ext/string_conversions.h:41:0, from /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/bits/basic_string.h:5402, from /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/string:52, from /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/bits/locale_classes.h:40, from /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/bits/ios_base.h:41, from /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/ios:42, from /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/ostream:38, from /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/iostream:39, from /home/heisig/appstacle/rover-app/include/libraries/timing/timing.h:26, from /home/heisig/appstacle/rover-app/src/tasks/accelerometer_task.cpp:20: /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/include/c++/6.2.0/cstdlib:75:25: fatal error: stdlib.h: No such file or directory

include_next

^ compilation terminated. CMakeFiles/roverapptasks.dir/build.make:62: die Regel für Ziel „CMakeFiles/roverapptasks.dir/src/tasks/accelerometer_task.cpp.o“ scheiterte make[2]: [CMakeFiles/roverapptasks.dir/src/tasks/accelerometer_task.cpp.o] Fehler 1 CMakeFiles/Makefile2:267: die Regel für Ziel „CMakeFiles/roverapptasks.dir/all“ scheiterte make[1]: [CMakeFiles/roverapptasks.dir/all] Fehler 2 Makefile:127: die Regel für Ziel „all“ scheiterte make: *** [all] Fehler 2

mozcelikors commented 5 years ago

Hi Philipp,

Are you having the same problem still? This problem is something I have encountered while working with Qt in Yocto. Qt version of things is solved by replacing "-isystem" flag "-I" in qtbase package in qtbase/common/mkspecs/gcc-base.conf (i.e. http://code.qt.io/cgit/qt/qtbase.git/tree/mkspecs/common/gcc-base.conf?h=5.6). I did this by creating a patch using devtool. I can help you regarding that once we locate the exact problem in your case, since you don't use Qt, plain C++. So, I think the issue is related to GCC trying to use system libraries (which is indeed a bug in Yocto). I hope this gives you an idea.

Coming to your case, some people here reported having same problem : https://stackoverflow.com/questions/40262928/error-compiling-opencv-fatal-error-stdlib-h-no-such-file-or-directory

So, to try this you could add the following to CMakeLists.txt, set (ENABLE_PRECOMPILED_HEADERS OFF) and recompile with: cd rover-app mkdir build cd build cmake .. make

or simply do the following: cd rover-app mkdir build cd build cmake -DENABLE_PRECOMPILED_HEADERS=OFF ..

Another possible solution (also using CMake); https://bugs.webkit.org/show_bug.cgi?id=161697

Another very possible solution is; https://github.com/opencv/opencv/pull/7390/files In this one, OpenCV is patched because it had the same error as you have with GCC 6.x. This is fixed with a patch that you can also apply. ( I doubt Yocto morty has this patch, it is a patch made in October 2016)

As a general note, this kind of issues usually arise when Yocto layers are not sync. i.e. I think I would set checkout all Yocto layers to point to same version (i.e. morty or sumo) if it's not like that already, and clean build the image and SDK. This will at least allow you to have less Yocto-related compatibility issues. If you haven't changed it though, it should be "morty" version still.

One other general note, Yocto defines SDKTARGETSYSROOT environment variable upon sourcing the environment. In order to make sure that the compilation is not taking place using system libraries, and that it is only using sysroot, you could make sure that your CMakeLists.txt depends on this environment variable (as Pedro did between lines 25-30 in CMakeLists.txt) But I doubt that is related to your issue right now.

@pjcuadra Pedro might have remarks or additions to my thoughts, I also appreciate his help.

Best regards,

phil-hei commented 5 years ago

Hi Mustafa, thanks for your extensive answer, very good input as it's hard for me to reproduce the things you developed and how. I followed your steps described above. Just to be sure: I need to source the SDK anyway, right? otherwise cmake complains about a missing Compiler. And as Pedro mentioned, the DINSTAL_PREFIX has to be added. So I ended with the following commands:

mkdir build cd build source /opt/kuksa/1.0.0/environment-setup-armv7vehf-neon-vfpv4-kuksa-linux-gnueabi cmake .. -DCMAKE_INSTALL_PREFIX=/opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/ make install

Unfortunately, I still get the same error. However, commenting out the following lines from CMakeLists.txt helps to get rid of that:

find_package (OpenCV REQUIRED) find_package (raspicam REQUIRED)

Then, make install runs through till the installation:

Scanning dependencies of target mqtt_subscriber [ 98%] Building CXX object CMakeFiles/mqtt_subscriber.dir/src/examples/mqtt_subscriber.cpp.o [100%] Linking CXX executable bin/mqtt_subscriber [100%] Built target mqtt_subscriber Install the project... -- Install configuration: "" -- Installing: /opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/bin/roverapp CMake Error at cmake_install.cmake:42 (file): file INSTALL cannot copy file "/home/heisig/appstacle/rover-app/build/bin/roverapp" to "/opt/kuksa/1.0.0/sysroots/armv7vehf-neon-vfpv4-kuksa-linux-gnueabi/usr/bin/roverapp". Makefile:61: die Regel für Ziel „install“ scheiterte make: *** [install] Fehler 1

Can I ignore that and copy the generated files to the Rover to get, at least, the driving via Command & Control working? Or what is the installations tep about?

mozcelikors commented 5 years ago

Always source SDK to develop for rover. @phil-hei Yes you can. You can copy the binary and libraries from build/ folder to appropriote destinations in the rover, and it should work. "make install" didn't feel right to me, as it shouldn't do anything on the host PC. make install should only work with Yocto build imo. So, just copy libraries and binaries: You can search where they were previously located: i.e.from target rpi: find / -name <binary-or-library-name> Copy via: i.e.from host pc: rsync -r <copy-this> root@192.168.1.154:<to-this-destination-in-target>

phil-hei commented 5 years ago

Hi Mustafa, thanks for the quick reply.

Do you know which SDK is best to use or worked at last? Because there are different locations with SDKs and I want to make sure that I used the right one. Don't know which you used at the end. Anyway, I used the "dev" one

Just using "make" make sense and helps me to get rid of the error at the end. Then I copied the generated files in build/bin and build/libs to the Rovers /usr/bin and /usr/lib.

Starting the telmetry service shows that telemetry data are still pushed to the cloud and sending an Command leads to a crash of the telmetry service. What sounds bad indicates that the Rover subcribes now to the right topic, which is already a good sign.

However, debugging on the Rover is anyoing as I'm not sure how to properly log and see the log. Can you recommend how to log? I used the AFB_Notice etc. but the according log is messed up with all the logs of the different AGL applications/services, which make it unreadable.

pjcuadra commented 5 years ago

Hi both,

Philipp I believe that removing raspicam and opencv is ok if you're not using them.

Regarding the installation. Did you run install with sudo? It seams like it's complaining about not being able to install. Since you specified the install prefix "make install" WILL install it in the host PC. And is safer than copying the files manually. Since the SDK is installed in a location without writing permission for your user you need to run it with sudo. As Mustafa suggests you should also copy this libraries to the RPI.

The errors you are having are the same if you try to build with opencv which isn't supported in our SDK. So it's actually safe to remove OpenCV from the CMakeLists.txt. You should also remove any #include related to OpenCV.

Best regards