---
# System prepended metadata

title: LIDAR
tags: [software]

---

---
title: LIDAR
tags: software
---

## Configuring environment

### 1. Source the setup files
```bash
source /opt/ros/foxy/setup.bash
```

### 2.Add sourcing to your shell startup script
```bash
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
```

### 3. Check environment variables
```bash
printenv | grep -i ROS
```
```
ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_DISTRO=foxy
```

## Creating a workspace

### 1. Source ROS 2 environment
```bash
source /opt/ros/foxy/setup.bash
```

### 2. Create a new directory
```bash
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
```

### 3. Clone a sample repo
```bash
git clone https://github.com/Slamtec/sllidar_ros2.git
```

### 4. Build sllidar_ros2 package
```bash
colcon build --symlink-install
```

### 5. Package environment setup
```bash
source ./install/setup.bash
```

### 6. Run sllidar node and view in the rviz
```bash
ros2 launch sllidar_ros2 view_sllidar_s1_launch.py
```

## debug
### Check the authority of rplidar's serial-port

```bash
ls -l /dev |grep ttyUSB
```

### Add the authority of write: (such as /dev/ttyUSB0)
```bash
sudo chmod 666 /dev/ttyUSB0
```

### Check serial-port details
```bash
ls /sys/class/tty/ttyUSB* -l
```

```
lrwxrwxrwx 1 root root 0  四  17 17:09 /sys/class/tty/ttyUSB1 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-5/3-5:1.0/ttyUSB1/tty/ttyUSB1
```

### setting number

:::warning
#ACTION=="add",KERNELS=="1-2:1.0",SUBSYSTEMS=="usb",MODE:="0777",SYMLINK+="name"
:::

```bash
sudo vi /etc/udev/rules.d/10-local.rules
```

```
ACTION=="add",KERNELS=="3-5:1.0",SUBSYSTEMS=="usb",MODE:="0777",SYMLINK+="ttyUSB0"
```

![](https://i.imgur.com/zstkv7Z.png)
