Search code examples
rosubuntu-18.04armv8nvidia-jetson-nano

How to make ardrone autonomy package work on Jetson Nano?


I'm working on a Jetson Nano board and I need to connect it with a parrot ar drone 2.0, so in order to do that I would like to use the ardrone_autonomy package, but I can't do that because jetson has Ubuntu 18, which only supports ROS Melodic, which doesn't have this package.

Here is what I tried:

  1. I built the package from this repository: https://github.com/dsapandora/ardrone_autonomy

But I obtained this error:

/tmp/ccIoQjBo.s: Assembler messages:
/tmp/ccIoQjBo.s:128: Error: unknown mnemonic `bswap' -- `bswap x3'
generic.makefile:231: recipe for target '../../Soft/Build/targets_versions/vlib_PROD_MODE_Linux_4.9.140-tegra_GNU_Linux_usrbingcc_5.4.0/video_mem32.o' failed
make[8]: *** [../../Soft/Build/targets_versions/vlib_PROD_MODE_Linux_4.9.140-tegra_GNU_Linux_usrbingcc_5.4.0/video_mem32.o] Error 1
vlib.makefile:104: recipe for target 'all' failed
make[7]: *** [all] Error 2
Makefile:167: recipe for target 'build_vlib' failed
make[6]: *** [build_vlib] Error 2
Makefile:170: recipe for target 'all' failed
make[5]: *** [all] Error 2
Makefile:84: recipe for target 'build_libs' failed
make[4]: *** [build_libs] Error 2
Makefile:20: recipe for target 'all' failed
make[3]: *** [all] Error 2
ardrone_autonomy/CMakeFiles/ardronelib.dir/build.make:110: recipe for target '/catkin_ws/devel/src/ardronelib-stamp/ardronelib-build' failed
make[2]: *** [/catkin_ws/devel/src/ardronelib-stamp/ardronelib-build] Error 2
CMakeFiles/Makefile2:578: recipe for target 'ardrone_autonomy/CMakeFiles/ardronelib.dir/all' failed
make[1]: *** [ardrone_autonomy/CMakeFiles/ardronelib.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

After I resolved that using almost any solution from here: https://github.com/AutonomyLab/ardrone_autonomy/issues/71

I can compile the package without problems but when I try to run the node, it says that the ardrone_driver has died, without any other information.

2.Then I tried to build the package in a docker under ROS Kinetic, but after getting the same bswap error as above, after applying the above solution I get this:

/tmp/ccFs5LFZ.s: Assembler messages:
/tmp/ccFs5LFZ.s:130: Error: unexpected characters following instruction at operand 2 -- `mov x4,x4,ror#8'
generic.makefile:231: recipe for target '../../Soft/Build/targets_versions/vlib_PROD_MODE_Linux_4.9.140-   tegra_GNU_Linux_usrbingcc_5.4.0/video_mem32.o' failed
make[8]: *** [../../Soft/Build/targets_versions   /vlib_PROD_MODE_Linux_4.9.140-tegra_GNU_Linux_usrbingcc_5.4.0   /video_mem32.o] Error 1
vlib.makefile:110: recipe for target 'all' failed
make[7]: *** [all] Error 2
Makefile:167: recipe for target 'build_vlib' failed
make[6]: *** [build_vlib] Error 2
Makefile:170: recipe for target 'all' failed
make[5]: *** [all] Error 2
Makefile:84: recipe for target 'build_libs' failed
make[4]: *** [build_libs] Error 2
Makefile:24: recipe for target 'all' failed
make[3]: *** [all] Error 2
ardrone_autonomy/CMakeFiles/ardronelib.dir/build.make:110: recipe for target '/ardrone_ws/devel/src/ardronelib-stamp/ardronelib-build' failed
make[2]: *** [/ardrone_ws/devel/src/ardronelib-stamp/ardronelib-build]     Error 2
CMakeFiles/Makefile2:578: recipe for target 'ardrone_autonomy/CMakeFiles/ardronelib.dir/all' failed
make[1]: *** [ardrone_autonomy/CMakeFiles/ardronelib.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[  2%] Built target    _ardrone_autonomy_generate_messages_check_deps_matrix33
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j2" failed

And here is where I'm stuck, because as much as I know it is a problem of processor architecture (Jetson uses armv8), and all the above solutions are for armv7, but I don't know how to solve this. Please let me know if anyone else found a solution to this problem. Any help would be highly appreciated!


Solution

  • I finally solved the problem, here are the complete steps, if there is someone else who is struggling with the same problems:

    1. I downloaded the docker image using: sudo docker pull ros:kinetic-robot-xenial And then followed this steps to run the image: http://wiki.ros.org/docker/Tutorials/Docker

    2. The I cloned the ardrone_autonomy package in a worksapce, from the above link:

    mkdir -p catkin_ws/src cd catkin_ws/src git clone https://github.com/dsapandora/ardrone_autonomy.git apt-get update cd ../ rosdep install --from-paths src --ignore-src -r -y catkin_make

    1. After the error with bswap appears, edit this file: devel/src/ardronelib/ARDroneLib/VP_SDK/VP_Os/linux/intrin.h and replace:

    static INLINE uint32_t _byteswap_ulong(uint32_t value) { __asm("bswap %0": "=r" (value): "0" (value));

    return value; }

    with this:

    static INLINE uint32_t _byteswap_ulong(uint32_t value) { int32_t tmp;

    __asm __volatile( "eor %1, %2, %2, ror #16\n" "bic %1, %1, #0x00ff0000\n" "mov %0, %2, ror #8\n" "eor %0, %0, %1, lsr #8" : "=r" (value), "=r" (tmp) : "r" (value) );

    return value; }

    and comment this line: _BitScanReverse(&index, code);

    1. After you do this if you try to give it a catkin_make it should appear the last error which can be resolved "simply" (after you understand what is happening there :) ) just by replacing this line (from the same file as above):

    "mov %0, %2, ror #8\n"

    with:

    "mov %0, %2\n"

    and now should work just fine.

    PS: Don't forget to source your workspace.