From 097a6e9ba5a07910028ad7664c452efb879b7378 Mon Sep 17 00:00:00 2001 From: Chitoku YATO Date: Wed, 8 Dec 2021 17:35:00 -0800 Subject: [PATCH] Add gitignore and Jetson page --- .gitignore | 68 ++++++++++++++ .../nv-l4t-usb-device-mode-runtime-start.sh | 89 +++++++++++++++++++ docs/setup/jetson.md | 82 +++++++++++++++++ mkdocs.yml | 1 + 4 files changed, 240 insertions(+) create mode 100644 .gitignore create mode 100755 docs/setup/data/nv-l4t-usb-device-mode-runtime-start.sh create mode 100644 docs/setup/jetson.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c9bd6804 --- /dev/null +++ b/.gitignore @@ -0,0 +1,68 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo + +# Scrapy stuff: +.scrapy + +# PyBuilder +target/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# virtualenv +venv/ +ENV/ + +# MkDocs documentation +site/ \ No newline at end of file diff --git a/docs/setup/data/nv-l4t-usb-device-mode-runtime-start.sh b/docs/setup/data/nv-l4t-usb-device-mode-runtime-start.sh new file mode 100755 index 00000000..095c906e --- /dev/null +++ b/docs/setup/data/nv-l4t-usb-device-mode-runtime-start.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of NVIDIA CORPORATION nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +script_dir="$(cd "$(dirname "$0")" && pwd)" +. "${script_dir}/nv-l4t-usb-device-mode-config.sh" + +if [ -f "${script_dir}/IP_ADDRESS_FOR_CREATE3_ROBOT.conf" ]; then + robot_ip_conf_file=${script_dir}/IP_ADDRESS_FOR_CREATE3_ROBOT.conf + cat $robot_ip_conf_file +fi + +/sbin/ifconfig l4tbr0 up +# The interface might lose the address when down. Add it here to make sure +# it's configured. +/sbin/ifconfig l4tbr0 ${net_ip} netmask ${net_mask} +/sbin/ifconfig l4tbr0 add ${net_ipv6} + +# IF the config file for iRobot Create3 (IP_ADDRESS_FOR_CREATE3_ROBOT.conf) exists, +# then apply the static IP address (192.168.186.3), instead of enabling DHCP server +if [ -n "$robot_ip_conf_file" ]; then + static_ip_for_robot=`cat $robot_ip_conf_file` + /sbin/ifconfig l4tbr0 $static_ip_for_robot netmask 255.255.255.0 broadcast 192.168.186.255 + echo "Static IP address set to $static_ip_for_robot" +else + +# Start a DHCP server so that connected systems automatically receive an IP +# address. This avoids users having to manually configure the connection, and +# also prevents Network Manager on Linux from destroying any manually applied +# configuration. +# +# The DHCP server must be started here, because it won't start if it's told to +# run on an interface that's down. +if [ -n "${net_dhcp_start}" ]; then + echo "### IN" + dhcpd_conf="${script_dir}/dhcpd.conf" + dhcpd_leases="/run/l4t-usb-devmode-dhcpd.leases" + dhcpd_pid="/run/l4t-usb-devmode-dhcpd.pid" + cat > "${dhcpd_conf}" < /opt/nvidia/l4t-usb-device-mode/IP_ADDRESS_FOR_CREATE3_ROBOT.conf' + + 2. Then, modify the "nv-l4t-device-mode-runtime" service script (`/opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode-runtime-start.sh`). The complete file is [here](data/nv-l4t-usb-device-mode-runtime-start.sh). +
+ +2. Connect micro-B end of the USB cable from Create3 robot to the micro-B USB port of Jetson. Then check if the static IP address is set by issuing `ifconfig` command. + + $ ifconfig l4tbr0 + + l4tbr0: flags=4163 mtu 1500 + inet 192.168.186.3 netmask 255.255.255.0 broadcast 192.168.186.255 + inet6 fe80::1 prefixlen 128 scopeid 0x20 + inet6 fe80::ecb6:edff:feac:7dd5 prefixlen 64 scopeid 0x20 + ether ee:b6:ed:ac:7d:d5 txqueuelen 1000 (Ethernet) + RX packets 169 bytes 36206 (36.2 KB) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 1644 bytes 213306 (213.3 KB) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 + + +!!! note + If you ever want to stop using the Jetson device for Create3 and re-enable the original USB Device Mode feature (so that you can connect to your Windows PC in headless style), you can simply remove the flag file, or execute the following. + + sudo mv /opt/nvidia/l4t-usb-device-mode/IP_ADDRESS_FOR_CREATE3_ROBOT.conf /opt/nvidia/l4t-usb-device-mode/IP_ADDRESS_FOR_CREATE3_ROBOT.conf.bak + + +### Start ROS2 Galactic container + +The recommended way to run ROS2 on Jetson is to use a pre-built Docker containers. + +1. Enable NVIDIA runtime for docker, if this is the first time running Docker containers on Jetson, to allow access to GPU from containers. + + Edit `/etc/docker/daemon.json` to be following. + + { + "runtimes": { + "nvidia": { + "path": "nvidia-container-runtime", + "runtimeArgs": [] + } + }, + "default-runtime": "nvidia" + } + + +2. Use `jetson-containers`' script to simplify the inovocation of `docker run` command. + +``` +git clone https://github.com/dusty-nv/jetson-containers/ +cd jetson-containers +scripts/docker_run.sh -c dustynv/ros:galactic-ros-base-l4t-r32.6.1 +``` + diff --git a/mkdocs.yml b/mkdocs.yml index 98664e11..c58eefee 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -29,6 +29,7 @@ nav: - Connect to Wi-Fi: setup/provision.md - Multi-Robot Setup: setup/multi-robot.md - ROS 2 on a Pi 4: setup/pi4.md + - ROS 2 on a NVIDIA Jetson: setup/jetson.md - Create® 3 APIs: - ROS 2 Interface: api/ros2.md - Docking: api/docking.md