Coder Social home page Coder Social logo

jetson_ros's Introduction

Install ROS2 Foxy on Jetson Nano

Base Image

Follow the guide here and flash an SD card Jetson Nano Developer Kit SD Card Image. Tested on JetPack 4.6.1 (L4T 32.7.1) and JetPack 4.5 (L4T 32.5)

Predependencies

Update system

Doing an upgrade on Nvidia packages seems to break the bootloader. So avoid upgrading them for the moment.

sudo apt-mark hold 'nvidia-l4t-*'
sudo apt update
sudo apt upgrade -y

Other necessary packages

Install the following packages.

sudo apt install software-properties-common
sudo add-apt-repository universe

sudo apt install -y \
    build-essential \
    checkinstall \
    libssl-dev

sudo apt install -y --no-install-recommends \
    curl \
    wget \
    gnupg2 \
    lsb-release

sudo rm -rf /var/lib/apt/lists/*

The existing CMake version is 3.10 and is too old for building certain ROS2 Foxy packages. So we need to get a newer version. The recommended way is to get the precompiled binaries.

cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-Linux-aarch64.tar.gz
tar -zxvf cmake-3.20.0-Linux-aarch64.tar.gz
cd cmake-3.20.0-Linux-aarch64/
sudo cp -rf bin/ doc/ share/ /usr/local/
sudo cp -rf man/* /usr/local/man
sync
# check if version is now 3.20
cmake --version

Or if you want to build from source,

cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0.tar.gz
tar -zvxf cmake-3.20.0.tar.gz
cd ~/cmake-3.20.0
./bootstrap
make -j2
sudo checkinstall --pkgname=cmake --pkgversion="3.20-custom" --default
hash -r
cd ~

We also need yaml-cpp-0.6 for some ROS2 Foxy packages. But it is not in the apt repositories so we need to build it from source.

cd ~
git clone --branch yaml-cpp-0.6.0 https://github.com/jbeder/yaml-cpp yaml-cpp-0.6
cd yaml-cpp-0.6
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make -j2
# Copy built binaries
sudo cp libyaml-cpp.so.0.6.0 /usr/lib/aarch64-linux-gnu/
# Make a soft link
sudo ln -s /usr/lib/aarch64-linux-gnu/libyaml-cpp.so.0.6.0 /usr/lib/aarch64-linux-gnu/libyaml-cpp.so.0.6

ROS2

We are now ready to built ROS2 Foxy.

Set locale

sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

Add the ROS 2 apt repository

cd ~
wget --no-check-certificate https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc
sudo apt-key add ros.asc
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'

Install development tools and ROS tools

sudo apt update
# install development packages
sudo apt install -y --no-install-recommends \
        build-essential \
        git \
        libbullet-dev \
        libpython3-dev \
        python3-colcon-common-extensions \
        python3-flake8 \
        python3-pip \
        python3-pytest-cov \
        python3-rosdep \
        python3-setuptools \
        python3-vcstool \
        python3-rosinstall-generator

# install Fast-RTPS dependencies
sudo apt install --no-install-recommends -y \
  libasio-dev \
  libtinyxml2-dev
# install Cyclone DDS dependencies
sudo apt install --no-install-recommends -y \
  libcunit1-dev
# install vision_opencv dependencies
sudo apt install libboost-python-dev -y

sudo rm -rf /var/lib/apt/lists/*
# install some pip packages needed for testing
python3 -m pip install -U \
    argcomplete \
    flake8-blind-except \
    flake8-builtins \
    flake8-class-newline \
    flake8-comprehensions \
    flake8-deprecated \
    flake8-docstrings \
    flake8-import-order \
    flake8-quotes \
    pytest-repeat \
    pytest-rerunfailures \
    pytest

# (Run this command if 'flake8-*' is not been install properly:
#   installs the 'wheel' package for the current user only,
#   which might resolve any permission-related issues.)
pip3 install wheel
pip3 install --user wheel
python3 --version
pip3 --version

pip install 'https://github.com/jetson-nano-wheels/python3.6-numpy-1.19.4/releases/download/v0.0.1/numpy-1.19.4-cp36-cp36m-linux_aarch64.whl'

Get ROS2 Code

mkdir -p ~/ros2_build_root/src
cd ~/ros2_build_root

# Download all the necessary repositories
sudo sh -c "rosinstall_generator --deps --rosdistro foxy ros_base launch_xml launch_yaml example_interfaces > ros2.foxy.ros_base.rosinstall && \
cat ros2.foxy.ros_base.rosinstall && \
    vcs import src < ros2.foxy.ros_base.rosinstall"
# download unreleased packages
cd ~/ros2_build_root
# Clone specific commit
sudo sh -c "git clone --branch ros2 https://github.com/Kukanani/vision_msgs src/vision_msgs && cd src/vision_msgs && git reset --hard ad6e80ee7bb2eb1d5d687568f71abece7c0b6941"

cd ~/ros2_build_root
sudo sh -c "git clone --branch foxy https://github.com/ros2/demos demos && \
    cp -r demos/demo_nodes_cpp src/ && \
    cp -r demos/demo_nodes_py src/ && \
    rm -r -f demos"

# download vision_opencv packages
cd ~/ros2_build_root/src
sudo sh -c "git clone https://github.com/ros-perception/vision_opencv.git -b foxy"

Install dependencies using rosdep

sudo apt update
cd ~/ros2_build_root
sudo rosdep init
rosdep update
# install missing ros package dependencies
rosdep install --from-paths src --ignore-src --rosdistro foxy -y --skip-keys "console_bridge fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers qt_gui"

sudo rm -rf /var/lib/apt/lists/*

Build it!

This process took more than 2 hours and max out the CPU.

cd ~/ros2_build_root
sudo mkdir -p /opt/ros/foxy
# sudo required to write build logs
sudo colcon build --merge-install --install-base /opt/ros/foxy
# We do this twice to make sure everything gets built
# For some reason, this has been an issue
sudo colcon build --merge-install --install-base /opt/ros/foxy
# (consider set 'No' for java compiling, and ignore the warning.)

# expand environment variables
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc
echo "export _colcon_cd_root=~/ros2_install" >> ~/.bashrc

source ~/.bashrc

Test

source ~/.bashrc

# You should see a `chatter` topic being published after
# running this line
ros2 run demo_nodes_py talker

Credits

jetson_ros's People

Contributors

gao-xinwei avatar

Watchers

 avatar

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.