GithubHelp home page GithubHelp logo

ros2's Introduction

ros2's People

Contributors

david-wang-2015 avatar lmayencourt avatar sudpau01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ros2's Issues

More complete Cross-compile instructions

I've been meaning to create this post for a while since

  1. I have found a way to cross-compile tests, python packages, and with security ON
  2. But, it seems awfully hacky and I want to get some feedback on how to make it less so

I have added "Notes:" for the steps where I'm definitely doing something questionable.

For completeness, I have copied the existing documentation and made the necessary changes:

  • Throughout the documentation I assume you have created a directory ros2_ws in home (i.e ~/ros2_ws)

Setup the development environment

The normal setup described in the following link is required for the cross-compilation -> https://github.com/ros2/ros2/wiki/Linux-Development-Setup

Get the source

Create a workspace and clone all repos:

mkdir -p ros2_ws/src
cd ros2_ws
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
wget https://raw.githubusercontent.com/ros2-for-arm/ros2/master/ros2-for-arm.repos
wget https://raw.githubusercontent.com/ros2-for-arm/ros2/master/aarch64_toolchainfile.cmake
vcs-import src < ros2.repos
vcs-import src < ros2-for-arm.repos

Get an aarch64 toolchain and export it

sudo apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu

# If you are not using a custom toolchain
export PATH="<path to toolchain>/bin:$PATH"
export CROSS_COMPILE=aarch64-linux-gnu-

Ignore packages that won't build with Python/Security

The following command disables the build of such packages by adding an empty file called COLCON_IGNORE in their base directory:

touch \
  src/ros/resource_retriever/COLCON_IGNORE \
  src/ros-perception/laser_geometry/COLCON_IGNORE \
  src/ros2/demos/image_tools/COLCON_IGNORE \
  src/ros2/demos/intra_process_demo/COLCON_IGNORE \
  src/ros2/demos/pendulum_control/COLCON_IGNORE \
  src/ros2/demos/pendulum_msgs/COLCON_IGNORE \
  src/ros2/geometry2/COLCON_IGNORE \
  src/ros2/kdl_parser/COLCON_IGNORE \
  src/ros2/orocos_kinematics_dynamics/COLCON_IGNORE \
  src/ros/pluginlib/pluginlib/COLCON_IGNORE \
  src/ros2/rmw_connext/COLCON_IGNORE \
  src/ros2/rmw_opensplice/COLCON_IGNORE \
  src/ros2/robot_state_publisher/COLCON_IGNORE \
  src/ros2/ros1_bridge/COLCON_IGNORE \
  src/ros2/rosidl_typesupport_connext/COLCON_IGNORE \
  src/ros2/rosidl_typesupport_opensplice/COLCON_IGNORE \
  src/ros2/realtime_support/rttest/COLCON_IGNORE \
  src/ros2/rviz/COLCON_IGNORE \
  src/ros2/urdf/COLCON_IGNORE \
  src/ros2/urdfdom/COLCON_IGNORE \
  src/ros2/system_tests/COLCON_IGNORE

Create a target filesystem

Note: This is the first hacky step. Maybe someone has a better idea on how to create this target filesystem.

On an aarch64 machine:

  1. Create a Dockerfile to install all dependencies needed to build ros2
  2. docker build the image
  3. Start a container using the image
  4. Use docker export to get a tar-ball with an aarch64 filesystem
  5. Untar this file into a folder names rootfs, delete all non-Python, non-OpenSSL files
    • Note: This may not be necessary. I originally did this because CMAKE_SYSROOT was leading
      CMake to look for executables like make in rootfs which were not executable since they were built
      aarch64 executables
  6. Tar rootfs and copy it to an x86_64 machine
  • Place this file next to ros2_ws (ie. ~/rootfs/)

Trigger a build

$ colcon build \
           --merge-install \
           --cmake-force-configure \
           --cmake-args \
               --no-warn-unused-cli \
               -DCMAKE_BUILD_TYPE=Debug \
               -DCMAKE_TOOLCHAIN_FILE="$(pwd)/aarch64_toolchainfile.cmake" \
               -DTHIRDPARTY=ON \
               -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
               -DPYTHON_INCLUDE_DIR="$(pwd)/../rootfs/usr/include/;$(pwd)/../rootfs/usr/include/python3.5m/" \
               -DPYTHON_LIBRARY="$(pwd)/../rootfs/usr/lib/aarch64-linux-gnu/libpython3.5m.so" \
               -DSECURITY=ON \
               -DOPENSSL_INCLUDE_DIR="$(pwd)/../rootfs/usr/include;$(pwd)/../rootfs/usr/include/aarch64-linux-gnu" \
               -DOPENSSL_SSL_LIBRARY="$(pwd)/../rootfs/usr/lib/aarch64-linux-gnu/libssl.so" \
               -DOPENSSL_CRYPTO_LIBRARY="$(pwd)/../rootfs/usr/lib/aarch64-linux-gnu/libcrypto.so"
  • Note: I tried using CMAKE_SYSROOT instead of specifying all these paths, but didn't have much luck.
  • Note: This only works with --merge-install
    • I couldn't get -DCMAKE_BUILD_RPATH=... to work

Cleanup some references to rootfs (i.e. The Hackiest Step)

$ for f in $(find ./install ./build -name "*cpython*.so"); do \
         ln -s $(basename $f) ${f/.cpython*/.so}; \
     done
$ ROOTFS_PATH="$(realpath ../rootfs)"
$ sed -i "s+$ROOTFS_PATH++g" "$(find ./install -name "fastrtpsTargets.cmake")"
  • These steps are needed to make sure that other packages will find the correct libraries when ROS 2 is deployed:
    • The first workaround (for f in ...) is required because cython generates some dynamic libraries
      and names them based on the architecture of the current machine and not the target architecture
      • For example, it generates _rclpy.cpython-x86_64-linux-gnu.so, but if you run file _rclpy.cpython-x86_64-linux-gnu.so, it says ELF 64-bit LSB shared object, ARM aarch64
    • The second workaround (sed -i ...) strips the path to rootfs such that the paths to OpenSSL libraries
      match the paths on the aarch64 machine

Running Tests

  • To run the tests, create an identical path on your target aarch64 machine (e.g. "/home/<your-username>/ros2_ws/) and copy the src, build, and install folders.
cd ~
ln -s / rootfs  # !!!Note:!!! Obvious hack - but I think it's only needed for stuff in colcon_command_prefix scripts
cd ~/ros2_ws
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/install/lib"
colcon test --merge-install

Installation

  • On the target machine, copy the contents of install folder to, for example, /opt/ros2/bouncy/
  • Run /opt/ros2/bouncy/setup.bash to use it
  • It should be possible to use ros2 run to start nodes
  • It should be possible to natively compile a simple application

Update for Bouncy release

The current documentation does not work for the latest release of ROS2 (bouncy). In particular, it needs to be updated to use Colcon as the build system and to provide libyaml dependency.

I'll update this issue once I've got a working version.

Two Issues with the Tutorial

Hy together,

I tried your tutorial for ros2 on arm with bouncy release.

1.) The first thing i noticed is that the build will fail because colcon builds by default with tests. Which wasn't the case with ament. Does a flag exist which disables building with tests when using colcon?

2.) The other thing is the last part of the tutorial. You mention the following

Once the compilation is done you will have to move the generated libraries (install/lib) in your target filesystem.

When I successfully compile the source code I have all ros2 packages under install and not lib. All lib folders are distributed between the packages, e.g. install/a/lib, install/b/lib and so on. Is this intended? It's gonna be pretty exhausting copying all lib folders. Is it because colcon builds per default as isolated now?

3.) The last is thing is not an issue but a question. Is it meant that you don't source the local_setup.bash? It is not mentioned in the tutorial. I'm a little bit confused if it is necessary.

Best regards

Update documentation for cross compilation

The cross compilation fails for internal dependencies of FAST-RTPS if the toolchain requires a sysroot to work, and if that sysroot is specified using CMAKE_TOOLCHAIN_FILE. See PR #216 for details. While this change gets merged upstream, I propose to update the documentation so that the corresponding fix can be applied manually (if needed).

Here's the link to the proposed documentation change:
dgoel/ros2_arm_wiki@2eb8864

Thanks!

Failed <<< fastrtps

Starting >>> fastrtps
--- stderr: fastrtps
Submodule 'thirdparty/asio' (https://github.com/chriskohlhoff/asio.git) registered for path 'thirdparty/asio'
Cloning into '/ros2_ws/src/eProsima/Fast-RTPS/thirdparty/asio'...
Submodule 'thirdparty/tinyxml2' (https://github.com/leethomason/tinyxml2.git) registered for path 'thirdparty/tinyxml2'
Cloning into '/ros2_ws/src/eProsima/Fast-RTPS/thirdparty/tinyxml2'...
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.16/Modules/FindOpenSSL.cmake:447 (find_package_handle_standard_args)
CMakeLists.txt:219 (find_package)


Failed <<< fastrtps [8.79s, exited with code 1]
Aborted <<< poco_vendor [1min 38s]

Summary: 31 packages finished [2min 0s]
1 package failed: fastrtps
1 package aborted: poco_vendor
4 packages had stderr output: fastcdr fastrtps poco_vendor uncrustify_vendor
101 packages not processed

undefined reference to `Poco::SharedLibrary

Hi, I trying to cross compile ros2 for raspberry pi3 on Docker.

I got these error messages:

/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: warning: libyaml.so, needed by /home/developer/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so, not found (try using -rpath or -rpath-link)
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: warning: libPocoFoundation.so.50, needed by /home/developer/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so, not found (try using -rpath or -rpath-link)
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/developer/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::hasSymbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/developer/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_delete'
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/developer/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_set_input_file'
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/developer/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_event_delete'
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/developer/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_parse'
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/developer/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::getSymbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/developer/ros2_ws/install/rcl_yaml_param_parser/lib/librcl_yaml_param_parser.so: undefined reference to `yaml_parser_initialize'
/home/developer/buildroot-2020.02.1/output/host/lib/gcc/arm-buildroot-linux-gnueabihf/8.4.0/../../../../arm-buildroot-linux-gnueabihf/bin/ld: /home/developer/ros2_ws/install/rosidl_typesupport_cpp/lib/librosidl_typesupport_cpp.so: undefined reference to `Poco::SharedLibrary::SharedLibrary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [tlsf_allocator_example] Error 1
make[1]: *** [CMakeFiles/tlsf_allocator_example.dir/all] Error 2
make: *** [all] Error 2
---
Failed   <<< tlsf_cpp	[ Exited with code 2 ]
Aborted  <<< map_msgs

Summary: 120 packages finished [16min 0s]
  1 package failed: tlsf_cpp
  1 package aborted: map_msgs
  15 packages had stderr output: fastcdr fastrtps geometry_msgs map_msgs nav_msgs poco_vendor rcl_interfaces rclcpp rmw_fastrtps_cpp sensor_msgs shape_msgs tlsf_cpp trajectory_msgs uncrustify_vendor visualization_msgs

My toolchain file is shown as below:

# Copyright (c) 2018, ARM Limited.
# SPDX-License-Identifier: Apache-2.0

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR armhf)
# specify the cross compiler
set(CMAKE_C_COMPILER arm-linux-gcc)
set(CMAKE_CXX_COMPILER arm-linux-g++)
# where is the target environment
set(CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/install)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# This assumes that pthread will be available on the target system
# (this emulates that the return of the TRY_RUN is a return code "0"
set(THREADS_PTHREAD_ARG "0"
  CACHE STRING "Result from TRY_RUN" FORCE)
set(PATH_POCO_LIB "${CMAKE_CURRENT_LIST_DIR}/build/poco_vendor/poco_external_project_install/lib/")
set(PATH_YAML_LIB "${CMAKE_CURRENT_LIST_DIR}/build/libyaml_vendor/libyaml_install/lib/")
set(CMAKE_BUILD_RPATH "${PATH_POCO_LIB};${PATH_YAML_LIB}")

Thank you for your watching.

Problems installing gcc/g++

I am trying to follow your instructions in the wiki. At the moment I am stuck at the "Get an aarch64 toolchain and export it" step.

When I try to run sudo apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu I get this error message:

Package gcc-aarch64-linux-gnu is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

Package g++-aarch64-linux-gnu is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'g++-aarch64-linux-gnu' has no installation candidate E: Package 'gcc-aarch64-linux-gnu' has no installation candidate

My /etc/apt/sources.list contains

deb http://ports.ubuntu.com/ubuntu-ports bionic main universe
deb http://ports.ubuntu.com/ubuntu-ports bionic-updates main universe
deb http://ports.ubuntu.com/ubuntu-ports bionic-security main universe

I am running Ubuntu 18.04 on a raspberry pi 3.
I would be glad if you could help me with this (:

NVIDIA Jetson Nano - Could not find a package configuration file provided by "test_msgs"

I'm attempting to following this example with a NVIDIA Jetson Nano and have run into an error that I can not clear. It looks like it is looking for a .cmake file for test_msgs but it can not find one an I was not able to locate it either.

This is from running "colcon build --symlink-install"


Starting >>> rcl_interfaces
Finished <<< unique_identifier_msgs [13.4s]   
Starting >>> std_msgs
Finished <<< rcl_interfaces [17.6s]                                            
Starting >>> rcl                                           
--- stderr: rcl                                                              
CMake Error at test/CMakeLists.txt:4 (find_package):
  By not providing "Findtest_msgs.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "test_msgs", but CMake did not find one.

  Could not find a package configuration file provided by "test_msgs" with
  any of the following names:

    test_msgsConfig.cmake
    test_msgs-config.cmake

  Add the installation prefix of "test_msgs" to CMAKE_PREFIX_PATH or set
  "test_msgs_DIR" to a directory containing one of the above files.  If
  "test_msgs" provides a separate development package or SDK, be sure it has
  been installed.


---
Failed   <<< rcl	[ Exited with code 1 ]
Aborted  <<< std_msgs                                                    

Summary: 94 packages finished [4min 39s]
  1 package failed: rcl
  1 package aborted: std_msgs
  1 package had stderr output: rcl
  79 packages not processed

Also, the install of the g++ and gcc libraries fail when trying to install them


 sudo apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
[sudo] password for jetbot: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package gcc-aarch64-linux-gnu is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package g++-aarch64-linux-gnu is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'g++-aarch64-linux-gnu' has no installation candidate
E: Package 'gcc-aarch64-linux-gnu' has no installation candidate

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.