Cross Compiling Driveworks on the PX2 with ROS

What is the normal setup for cross compiling ros nodes that use the Driveworks platform for the Drive PX2?
I am currently trying to cross compile ros-kinetic from source using the cmake toolchain file provided in the Driveworks samples and working through boost dependency issues.
Earlier responses to posts about ros hinted that Nvidia was working on a guide for using ros with the PX2. What is its status? Are you waiting for the cross compiling setup to be migrated to 16.04? If a draft of this was available I would be willing to test it and give feedback.

I ended up getting all the way past cross compiling python and boost. However once ros started linking against python libraries there is an error ā€œfinal link failed: Nonrepresentable section on outputā€

I am hoping there will be a guide for this soon as cross compiling each individual dependency seems to be very error prone and time consuming. There has to be a better wayā€¦

Is there a general strategy for how to compile ros binaries that link in some driveworks binaries? I donā€™t need a guide just a better strategy for how to do this.

Hello llorenzds,

Please refer to below to install ROS-Kinetic on DPX2.

  1. Install the PDK and flash the target build onto the board as described in the PDK Developerā€™s Guide

  2. Boot to Ubuntu Unity Desktop
    Note: Do not perform ā€œapt-get upgradeā€ on the target, at any stage

  3. Via Ubuntu GUI, configure Ubuntu to allow package installation from main, restricted, universe and multiverse repositories

  4. Setting locale:
    (This is optional. Setting locales explicitly to either of the options mentioned may cause some issues with launching the terminal after a system reboot. So, this step may be skipped in the first try)
    sudo update-locale LANG=C LANGUAGE=C LC_ALL=C LC_MESSAGE=POSIX
    (or)
    export LANGUAGE=en_US.UTF-8
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    sudo locale-gen en_US.UTF-8
    sudo dpkg-reconfigure locales

  5. Setup the keys to authenticate package downloads
    sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

  6. Open the ā€˜Software & Updatesā€™ applet and add
    deb http://packages.ros.org/ros/ubuntu xenial main

  7. Update the libssl1.0.0 package to the latest version [1.0.2g-1ubuntu4.6]and install libssl-dev
    sudo apt-get install libssl1.0.0/xenial libssl-doc/xenial libssl-dev/xenial

  8. Install the ā€˜Desktopā€™ bundle of ROS (contains the ROS Core Framework, plus a set of popular algorithms and sample apps)
    sudo apt-get install ros-kinetic-desktop

  9. After successful installation of ROS, set up the environment so that the terminal recognizes ROS.
    echo ā€œsource /opt/ros/kinetic/setup.bashā€ >> ~/.bashrc
    source ~/.bashrc

  10. Set the library search path for the current shell
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib/aarch64-linux-gnu

  11. Run some ROS sample apps to verify install success. For example:
    VISUALIZING THE ROS TURTLESIM APP WITH RVIZ

    1. From a terminal, run
      roslaunch turtle_tf turtle_tf_demo.launch
    2. In a new terminal, run
      rviz &
    3. After launching the rviz GUI, change the Fixed frame (found under ā€˜Global Optionsā€™ in the ā€˜Displaysā€™ section) to ā€˜worldā€™.
    4. From the display section, Add > By display type > TF
    5. To verify successful connectivity between the turtlesim application and rviz,
      move the turtle on the terminal used to run roslaunch (Step1 above) and observe the movement of the turtle frames with respect to the world frame in the rviz GUI
1 Like

hi llorenzds,

i believe its not necessary to cross compile all along ros and driveworks.
It should be enough to cross compile nvidia libs and later link them accordingly to ROS pkgs.

So in the final process you just run catkin_make on the target and link the required libs against.

Please correct me if i am wrong here.

FYI, I am also interessted in a proper setup here, especially for getting the gmsl cameras within ROS.

@SteveNV

Thanks for the info. I have a ros Kinetic setup on the Drive PX2 that works. I am just trying to figure out a good solution for linking in the Driveworks libraries with custom ros code.

@tinokl

I have been thinking along similar lines, especially since the Driveworks cross compiling setup is pretty complex. One test that I am working on today is seeing if I can compile a ros node natively on the Drive PX2 that links in one of the Driveworks libraries. As far as I can tell the Driveworks libraries already exist in the Drive PX2ā€™s file system. I will try to keep this thread up to date with my setup, it would be nice to come up with a good solution to this.

@tinokl @SteveNV

I have managed to get a working wrapper around the driveworks lane detection binaries by developing on the drive px2. I will try to replicate this tomorrow on the second tegra of the px2, so that I can make a simple guide for this. Thanks for the help!

I was hoping to document this well but havenā€™t taken the time. Most of the configuration needed is in the CMakeLists. Here is a link to the changes I made, CMakeList configuration for compiling ROS and Driveworks on a Tegra (Drive PX2) Ā· GitHub I hope this helps.

I have a bit of problems using your CMake fileā€¦

The folder /usr/share/visionworks/sources/3rdparty/nvmedia/ doesnā€™t exist on my system!?
I only found nvmedia headers and libs in VibranteSDK/vibrante-t186ref-linux, but system tells me they are incompatible.

Any suggestions?

My system is Ubuntu 16.04.3 LTS

Update:
Think I am wrong trying to compile it on my host machine?
Only possible on PX2 itself?

That setup is for compiling on the PX2 itself. It would have been much harder for me to get a cross compiling setup working.

Ok, thats annoyingā€¦ ;)
So you write your code on your notebook without compiling?
Or do you just compile for x64 to see if any errors are present and then push the source to the PX2?

I just ssh into the px2 and compile. I use x forwarding to use my favorite ide after installing it on the px2.

I am trying to get the wrapper working to compile ROS with the Driveworks libraries included on the PX2 and changed the cmakelist according to CMakeList configuration for compiling ROS and Driveworks on a Tegra (Drive PX2) Ā· GitHub
But I can not figure out this error message. Has anyone encountered a similar problem or has any suggestions?

/usr/bin/ld: /home/nvidia/catkin_ws/src/pkg_test/3rdparty/linux-aarch64/glfw-3.1.1/lib/libglfw3.a(x11_window.c.o): undefined reference to symbol ā€˜XConvertSelectionā€™
/usr/lib/gcc/aarch64-linux-gnu/5/ā€¦/ā€¦/ā€¦/aarch64-linux-gnu/libX11.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
pkg_test/CMakeFiles/pkg_test.dir/build.make:146: recipe for target ā€˜/home/nvidia/catkin_ws/devel/lib/pkg_test/pkg_testā€™ failed
make[2]: *** [/home/nvidia/catkin_ws/devel/lib/pkg_test/pkg_test] Error 1
CMakeFiles/Makefile2:825: recipe for target ā€˜pkg_test/CMakeFiles/pkg_test.dir/allā€™ failed
make[1]: *** [pkg_test/CMakeFiles/pkg_test.dir/all] Error 2
Makefile:138: recipe for target ā€˜allā€™ failed
make: *** [all] Error 2
Invoking ā€œmake -j6 -l6ā€ failed

Have you tried building a simple project? This was used to create a wrapper around the lane detector that piped the lane detection results into ros. I didnā€™t ever use this to create anything that required a gui.

yes building simple projects is working but I can not figure out how to build one that includes a gui. Currently I am trying to get the cross compilation to work but I have not gotten too far with it yet. Has anyone a suggestion how it could work?

@SteveNV

I tried your procedure to install ROS Kinectic on my freshly flashed Drive PX2 and I get the following message at step 8 (sudo apt-get install ros-kinetic-desktop).

Reading package listsā€¦ Done
Building dependency tree
Reading state informationā€¦ Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
ros-kinetic-desktop : Depends: ros-kinetic-common-tutorials but it is not going to be installed
Depends: ros-kinetic-geometry-tutorials but it is not going to be installed
Depends: ros-kinetic-robot but it is not going to be installed
Depends: ros-kinetic-ros-tutorials but it is not going to be installed
Depends: ros-kinetic-visualization-tutorials but it is not going to be installed
Depends: ros-kinetic-viz but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Do you have any idea? I swear I did not perform ā€œapt-get upgradeā€ on the target, at any stageā€¦ But I did perform a ā€œapt-get updateā€.

@mlandry
I would recommend removing ros-kinetic-desktop-full and installing ros-kinetic-base, along with the packages you actually need to run on the PX2. This will avoid your problems with the missing packages. Remember you want to use the PX2 as a compute platform not a normal laptop/desktop computerā€¦
Visualization tools like rviz can be run on a second computer on the same network as the PX2 with the roscore running on the PX2.

@llorenzds

Yeah I know I was just following the posted official procedureā€¦ I also tried ROS bare bone which gives me these dependencies problems insteadā€¦ I have a Drive PX2 Autochauffeur with the Beta 1.0 PDK installed. I will try my luck by downloading and flashing the Alpha 2.0 PDK insteadā€¦

nvidia@tegra-ubuntu:~$ sudo apt-get install ros-kinetic-ros-base
Reading package listsā€¦ Done
Building dependency tree
Reading state informationā€¦ Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
ros-kinetic-ros-base : Depends: ros-kinetic-actionlib but it is not going to be installed
Depends: ros-kinetic-bond-core but it is not going to be installed
Depends: ros-kinetic-class-loader but it is not going to be installed
Depends: ros-kinetic-dynamic-reconfigure but it is not going to be installed
Depends: ros-kinetic-nodelet-core but it is not going to be installed
Depends: ros-kinetic-pluginlib but it is not going to be installed
Depends: ros-kinetic-ros-core but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Hi,

I was following SteveNV instruction on how to install ROS on the Drive PX2, and I get error message below after step 8.

sudo apt-get install ros-kinetic-desktop
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ros-kinetic-desktop : Depends: ros-kinetic-viz but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

By the way, I added the deb repo using the command line:

sudo add-apt-repository 'deb http://packages.ros.org/ros/ubuntu xenial main'

as the ā€˜Software & Updateā€™ GUI is giving me an error as well.

Any help.