---
# System prepended metadata

title: Setup

---

# Setup
Fixed Frame [map] does not exist
## Jetson nx setup

- [系統安裝步驟](https://developer.nvidia.com/embedded/learn/get-started-jetson-xavier-nx-devkit)
- Jetson Xavier NX Developer Kit SD Card Image [[Download](https://developer.nvidia.com/embedded/l4t/r32_release_v7.1/jp_4.6.1_b110_sd_card/jetson_xavier_nx/jetson-nx-jp461-sd-card-image.zip)]

####     系統更新
```bash
$ sudo apt-get update

$ sudo apt-get -y dist-upgrade

$ sudo apt update
```

#### 安裝 git
```bash
$ sudo apt-get install git
```

#### install VSCode
The easiest way to install for Debian/Ubuntu based distributions is to download from https://code.visualstudio.com and install the .deb package (64-bit) either through the graphical software center if it's available or through the command line with:

```bash
$ sudo dpkg -i <file>.deb
$ sudo apt-get install -f 
```
---


## 遠端桌面

xrdp setup
```bash
$ sudo apt-get install tightvncserver xrdp

$ sudo reboot
```

xubuntu-desktop install
```bash
$ sudo apt-get install xubuntu-desktop

$ echo xfce4-session >~/.xsession

$ sudo service xrdp restart
```
:::spoiler
[參考資料](https://blog.cavedu.com/2019/12/19/jetson-nano-remote-desktop-windows-mac-osx/)
:::

---



## FTP
setup
```bash
$ sudo apt install vsftpd
```
驗證vsftpd是否安裝成功並且正常啟動
```bash
$ systemctl status vsftpd
$ netstat -tupln | grep ftp
```
修改vsftpd.conf:
```bash
$ sudo vim /etc/vsftpd.conf
```
cinfig
```python
# Allow anonymous FTP? (Disabled by default).
anonymous_enable = YES

# Uncomment this to enable any form of FTP write command.
write_enable=YES

# Uncomment this to allow the anonymous FTP user to upload files. # This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user.
anon_upload_enable=YES
```
## YDLIDAR X2

#### Compile and Install YDlidar-SDK

SDK install
```bash
$ git clone https://github.com/YDLIDAR/YDLidar-SDK.git

$ cd YDLidar-SDK/build

$ cmake ..

$ make

$ sudo make install
```
**python API** 


if you want to use python API, you need to install python and swig(3.0 or higher):


```bash
$ sudo apt-get install python swig
$ sudo apt-get install python-pip
```
python API install separtately:
```bash
$ cd YDLidar-SDK
$ pip install .

# Another method
# $ python setup.py build
# $ python setup.py install
```

#### ROS Melodic
sourse.list setting and update

```bash
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

$ sudo apt update
```
Package environment Settings
```bash
$ sudo apt install ros-melodic-desktop-full

$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

$ source ~/.bashrc
```
:::danger
:warning: **建議完成後重新啟動系統**

```bash
$ sudo reboot
```
:::

#### ROS Driver Installation
Cloning GitHub's YDlidar ROS Driver Package and build
```bash
$ git clone https://github.com/YDLIDAR/ydlidar_ros_driver.git ydlidar_ws/src/ydlidar_ros_driver

$ cd ydlidar_ws

$ catkin_make 
```
Package environment Settings
```bash
$ source ./devel/setup.sh

$ echo "source ~/ydlidar_ws/devel/setup.bash" >> ~/.bashrc

$ source ~/.bashrc
```

#### ROS OPERATION

#### Run the ydlidar_ros_driver

```bash
$ roslaunch ydlidar_ros_driver X2.launch 
```

#### RVIZ View Scan Results

```bash
$ roslaunch ydlidar_ros_driver lidar_view.launch
```
:::info
:bulb: Note: Take G4 as an example by default, if use other types of lidar, need to change lidar.launch in
lidar_view.launch file to the corresponding \*\*.launch file. (If X2 lidar is used, it needs to be changed to
X2.launch)
![](https://i.imgur.com/q1SP0j4.png)
:::


:::spoiler
- [YDLIDAR SDK](https://github.com/YDLIDAR/YDLidar-SDK)
- [YDLIDAR X2 Lidar User Manual](https://www.ydlidar.com/Public/upload/files/2022-06-21/YDLIDAR%20X2%20Lidar%20User%20Manual%20V1.3(211228).pdf)
- [ROS基本環境設置](https://ithelp.ithome.com.tw/articles/10239445)

:::





rosrun gmapping slam_gmapping scan:=scan _delta:=0.1 _maxUrange:=4.99 _xmin:=-5.0 _ymin:=-5.0 _xmax:=5.0 _ymax:=5.0 _particles:=30 _srr:=0 _srt:=0 _str:=0 _stt:=0.1 _minimumScore:=10000

```
<node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="0.20 0 0 0 0 0 base_link laser 50" />
```
[<node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="0.20 0 0 0 0 0 base_link laser 50" />](https://www.guyuehome.com/34092)

---

#### 檢查是否有nvm (nodejs)

檢查是否已有nodejs
```bash
$ node -v
```
檢查是否已有nvm(有則略過下方安裝)
```bash
$ nvm --version
```
沒有安裝nvm 則先移除nodejs(若有安裝)
```bash
$ sudo npm uninstall npm -g
```

---

#### 安裝nvm (nodejs)

```bash!
$ sudo apt install curl
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
```

安裝完後**重新開啟終端機**檢查是否安裝成功
```bash!
$ nvm --version
```

安裝nodejs
```bash!
# nvm install (版本)
$ nvm install v16.14.0
```

檢查是否安裝成功
```bash!
$ node -v
```