본 글은 18. [ROS RC카] Jetson Nano 셋업 (ROS 설치, 하드웨어 연결 확인) 상당수 복사하였음을 알려드립니다.
Jetpack 4.6.1에 OpenCV 3.4.6, Python3 3.7, piOLED등을 설치한 이미지는 아래 사이트에서 받습니다.(2023.03.30 작성)
Jetson 4G image
https://drive.google.com/file/d/1HU5F1cwiw2wzuNBdLL9R3Wvpg5AXLzw5/view?usp=sharing
Jetson 2G image
https://drive.google.com/file/d/1mT9gTjAO0WtUF7FNO4q0Yf8rEwAnV8Ca/view?usp=share_link
prompt는 jetson@jp4612GCv346Py37입니다.
id: jetson
passwd: jetson
아래는 login할때 메시지입니다.
Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 4.9.253-tegra aarch64)
* Documentation: <https://help.ubuntu.com>
* Management: <https://landscape.canonical.com>
* Support: <https://ubuntu.com/advantage>
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
271 updates can be applied immediately.
228 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
Last login: Wed Mar 22 20:44:29 2023 from 192.168.55.100
#용량은 26G, 48%를 사용하고 있습니다.
jetson@jp4612GCv346Py37:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk0p1 57G 26G 29G 48% /
none 951M 0 951M 0% /dev
tmpfs 990M 4.0K 990M 1% /dev/shm
tmpfs 990M 28M 963M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 990M 0 990M 0% /sys/fs/cgroup
tmpfs 198M 8.0K 198M 1% /run/user/1000
PC에서 SSH로 Jetson에 접속하기 위해서는 PC에 SSH client 프로그램이 있어야합니다. 물론 default CLI명령어인 ssh를 사용할 수 있습니다. 그러나 본인이 즐겨 사용하는 프로그램을 PC에 설치해주세요. 즐겨 사용하는 게 없으면 아래 프로그램을 설치해주세요. 무료입니다.
Windows
Teraterm, SecureCRT, Termius, PuTTY
Ubuntu
Termius, PuTTY, asbru-cm
자율주행하기에 앞서 jetson, notebook을 동일한 AP에 연결해야합니다. 192.168.55.x를 사용하는 USB 연결을 주행에서는 사용할 수 없기 때문입니다. terminal에서 아래 방법으로 AP에 연결할 수 있습니다.
jetracer/software_setup.md at master · NVIDIA-AI-IOT/jetracer
# 실행해야할 명령
$ sudo nmcli device wifi list
$ sudo nmcli device wifi connect <ssid_name> password <password>
$ ifconfig
# 명령어 실행 예제
# password가 없는 경우
zeta@jp461:~$ sudo nmcli device wifi connect STARTUP_LOUNGE_love
Device 'wlan0' successfully activated with 'e1d72d88-360a-468b-8487-3cf3ef5b343c'.
zeta@jp461:~$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
:
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.37.160 netmask 255.255.255.0 broadcast 192.168.37.255
inet6 fe80::89c:53da:d58:afc1 prefixlen 64 scopeid 0x20<link>
ether 00:28:f8:7d:61:03 txqueuelen 1000 (Ethernet)
RX packets 734 bytes 1018170 (1.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 350 bytes 35354 (35.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# password가 있는 경우
jetson@jp4512G:~$ sudo nmcli device wifi connect U+NetD681 password xxxxxxx
Device 'wlan0' successfully activated with '51523154-f356-461f-b8bb-54e1ac21bd10'.
jetson@jp4512G:~$ ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.219.107 netmask 255.255.255.0 broadcast 192.168.219.255
inet6 fe80::21d:8403:c491:2b80 prefixlen 64 scopeid 0x20<link>
ether 00:e0:4b:af:07:1f txqueuelen 1000 (Ethernet)
RX packets 6110 bytes 9029131 (9.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3666 bytes 340490 (340.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# 연결을 해제할 때
$ sudo nmcli device disconnect wlan0
#명령 실행 로그
jetson@jp4512G:~/catkin_ws$ sudo nmcli device disconnect wlan0
Device 'wlan0' successfully disconnected.
쿨링팬이 없으면 생략하세요.
3선 쿨링팬은 바로그 동작합니다만, 4선 PWM 쿨링팬은 아래 작업을 해야 동작합니다. 즉 PWM 신호에 출력을 주어야 동작하는 것입니다. CPU 사용에 따라 쿨링팬 속도를 자동으로 조정하는 utility를 설치하는게 좋습니다.
cd Downloads
git clone <https://github.com/jetsonworld/jetson-fan-ctl.git>
cd jetson-fan-ctl
sudo sh install.sh
실행 로그는 아래와 같습니다.
jetson@jp4512G:~$ cd Downloads/
jetson@jp4512G:~/Downloads$ git clone <https://github.com/jetsonworld/jetson-fan-ctl.git>
Cloning into 'jetson-fan-ctl'...
remote: Enumerating objects: 90, done.
remote: Counting objects: 100% (90/90), done.
remote: Compressing objects: 100% (83/83), done.
remote: Total 90 (delta 40), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (90/90), done.
jetson@jp4512G:~/Downloads$ cd jetson-fan-ctl/
jetson@jp4512G:~/Downloads/jetson-fan-ctl$ sudo sh install.sh
[sudo] password for jetson:
install.sh: 4: [: !=: unexpected operator
settling to /usr/local/bin/automagic-fan/...
done
adding service to /lib/systemd/system/...
done
creating config at /etc/automagic-fan/
done
starting and enabling service...
Created symlink /etc/systemd/system/multi-user.target.wants/automagic-fan.service → /lib/systemd/system/automagic-fan.service.
done
automagic-fan installed sucessfully!
To configure, edit /etc/automagic-fan/config.json (needs sudo)
자세한 내용은 아래 블로그를 참고해주세요
VNC는 다음과 같은 경우 반드시 필요합니다. 만일을 위해 설치해두는게 좋습니다.
ROS remote 환경 설정을 만들지 못했을 때
Jetson에 TV를 연결할 수 없을 때
젯슨 나노는 화면 공유를 바로 허용하지 않게 되어있습니다. VNC를 사용해서 노트북에서 젯슨 화면을 보면서 작업할 경우 아래 글을 따라서 VNC 서버를 동작하게 해주십시오.
https://developer.nvidia.com/embedded/learn/tutorials/vnc-setup
# Jetson Nano 2GB(running LXDE)
mkdir -p ~/.config/autostart
cp /usr/share/applications/vino-server.desktop ~/.config/autostart/.
# Jetson Nano 4GB (running GNOME)
cd /usr/lib/systemd/user/graphical-session.target.wants
sudo ln -s ../vino-server.service ./.
# 공통
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino require-encryption false
gsettings set org.gnome.Vino authentication-methods "['vnc']"
# 아래 passord에 본인이 사용할 비밀번호로 변경하세요
gsettings set org.gnome.Vino vnc-password $(echo -n 'passsword'|base64)
# example, password is jetson
# gsettings set org.gnome.Vino vnc-password $(echo -n 'jetson'|base64)
위에서 ‘password’는 본인이 사용할 password로 대체해주세요.
그 후 PC에서 VNC viewer를 설치하여야합니다. 우분투의 경우 “Ubuntu Software” → “Remina”를 클릭하여 설치할 수 있습니다.
다른 OS일 경우 아래 site에서 본인 OS에 맞는 프로그램을 다운로드할 수 있습니다.
Desktop OS 다운로드
아래 화면은 Ubuntu Remina를 실행해서 Jetson을 연결하는 화면입니다.
micro-USB 케이블로 PC와 Jetson을 연결
해상도가 낮을 경우 아래 글을 참고하여 xorg.conf를 수정하세요.
$ sudo gedit /etc/X11/xorg.conf
#아래 내용 추가
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Default Device"
SubSection "Display"
Depth 24
Virtual 1280 800
EndSubSection
EndSection
이 수정사항은 해상도를 1280x800으로 변경합니다. TV를 연결할 경우 해상도가 충분치 않을 수 있습니다. 그 때는 Virtual을 “1920 1080”으로 변경해주세요.
설정 버튼을 click하여 화면의 품질을 변경할 수 있습니다.
jtop은 아주 유용한 툴이므로 설치하는게 좋습니다. 구글 드라이브에 공유한 이미지에는 이미 jtop이 설치되어있습니다.
동작하지 않을 경우, 즉 설치가 필요한 경우 아래 명령을 사용하십시오.
sudo apt install python3-pip
sudo -H pip3 install -U jetson-stats
자세한 내용은 아래 글을 참고하세요
Jetson에 SSD1306 OED를 연결한 경우 3c가 보여야합니다.
jetson@jp4612GCv346Py37:~/Downloads$ sudo i2cdetect -r -y 1
[sudo] password for jetson:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
우분투에서 sftp를 연결하는 방법은 아래 그림을 참고하세요. sftp로 연결하여 파일을 PC와 공유할 수 있습니다. 물론 PC gedit로 Jetson 파일을 수정할 수 있습니다.
Windows의 경우 winscp를 설치하시면 같은 기능을 사용할 수 있습니다.
WinSCP :: Official Site :: Download
jugfk에 있는 script가 pgp key 때문에 동작하지 않아 shell을 수정했습니다. zeta0707 github에서 clone합니다.
cd ~/Downloads/
sudo apt update
git clone <https://github.com/zeta0707/installROS.git>
cd installROS
./install-ros.sh
~/catkin_ws까지 만들어집니다. 지금까지 작업하면 폴더는 아래와 같을 것입니다.
jetson@Jp2G451Cv346:~$ ls
catkin_ws Documents examples.desktop Pictures Templates
Desktop Downloads Music Public Videos
jetson@Jp2G451Cv346:~$ cd Downloads/
jetson@Jp2G451Cv346:~/Downloads$ ls
installROS jetson-fan-ctl opencvDownTo34
PC, Jetson에 작업을 편리하게 할 환경을 .bashrc에서 추가해줍니다. alias 명령어추가, PC ↔ Jetson remote 환경을 설정합니다.
# mirco USB 케이블 연결을 사용할 경우
192.168.55.1: Jetson IP
192.168.55.100: PC IP
Jetson
$ gedit ~/.bashrc
# 또는 편리한 에디터로 .bashrc 열기
# 파일 제일 아래에 다음과 같은 내용 입력
alias cma='catkin_make -DCATKIN_WHITELIST_PACKAGES=""'
alias cop='catkin_make --only-pkg-with-deps'
alias sds='source devel/setup.bash'
alias coc='catkin clean'
alias cca='catkin clean -y'
# mirco USB 케이블 연결을 사용할 경우, jetson master
export ROS_MASTER_URI=http://192.168.55.1:11311
export ROS_IP=192.168.55.1
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bas
# 에디터 종료 후 터미널 업데이트
$ source ~/.bashrc
PC
$ gedit ~/.bashrc
# 또는 편리한 에디터로 .bashrc 열기
# 파일 제일 아래에 다음과 같은 내용 입력
alias cma='catkin_make -DCATKIN_WHITELIST_PACKAGES=""'
alias cop='catkin_make --only-pkg-with-deps'
alias coc='catkin clean'
alias cca='catkin clean -y'
# mirco USB 케이블 연결을 사용할 경우, jetson master
export ROS_MASTER_URI=http://192.168.55.1:11311
export ROS_IP=192.168.55.100
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bas
# 종료 후 터미널 업데이트
$ source ~/.bashrc
아래 명령어를 사용하여 clean을 한 번 하면 cma가 문제없이 실행됩니다.
jetson@jp4512G:~/catkin_ws$ cca
jetson@jp4512G:~/catkin_ws$ cma
실행로그를 참고를 위해 아래에 추가했습니다.
jetson@jp4512G:~/catkin_ws$ cca
[clean] Removing develspace: /home/zeta/catkin_ws/devel
[clean] Removing buildspace: /home/zeta/catkin_ws/build
[clean] Removing log space: /home/zeta/catkin_ws/logs
jetson@jp4512G:~/catkin_ws$~/catkin_ws$ cma
Base path: /home/zeta/catkin_ws
Source space: /home/zeta/catkin_ws/src
Build space: /home/zeta/catkin_ws/build
Devel space: /home/zeta/catkin_ws/devel
Install space: /home/zeta/catkin_ws/install
Creating symlink "/home/zeta/catkin_ws/src/CMakeLists.txt" pointing to "/opt/ros/melodic/share/catkin/cmake/toplevel.cmake"
####
#### Running command: "cmake /home/zeta/catkin_ws/src -DCATKIN_WHITELIST_PACKAGES= -DCATKIN_DEVEL_PREFIX=/home/zeta/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/zeta/catkin_ws/install -G Unix Makefiles" in "/home/zeta/catkin_ws/build"
####
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/zeta/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/zeta/catkin_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/zeta/catkin_ws/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/zeta/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.17")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zeta/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/zeta/catkin_ws/build"
####
설치 후 제대로 되었는지 turtlesim으로 확인할 수 있습니다. 세 개의 창에 하나씩 아래 명령어를 실행해주세요. 두가지 방법으로 실행 가능합니다.
. ROS remote 환경
. PC에서 VNC로 Jetson에 접속, 또는 Jetson에 TV를 연결
# 터미널 #1
jetson@jp4512G:~/catkin_ws$ roscore
# 터미널 #2
jetson@jp4512G:~/catkin_ws$ rosrun turtlesim turtlesim_node
# 터미널 #3
jetson@jp4512G:~/catkin_ws$ rosrun turtlesim turtle_teleop_key
Jetson에 TV를 연결한 경우
VNC로 PC에서 Jetson으로 접속한 경우
vscode에서 remote ssh extension를 설치하시면 source 수정 작업이 더 편합니다. 즉 PC vscode를 사용하여 Jetson에 있는 code를 편리하게 수정할 수 있습니다.
그 외 여러 extension도 선호하시는 것을 설치해주세요.
EOF Mark
C/C++
CMake
Python
:
vim을 주 에디터로 사용하는 분은 vim을 설치해주세요
$ sudo apt-get install vim