---
# System prepended metadata

title: Pixhawk Lidar setup
tags: [setup]

---

---
title: 'Pixhawk Lidar setup'
disqus: hackmd
---

Build Pixhawk relay setup
===


[TOC]

## 1. Hardware 
### 1. RPlidar A2
如果使用RPlidar A2請參照下圖接腳
![](https://i.imgur.com/tbHaa69.jpg)
### 2. RPlidar A1M8
如果使用RPlidar A1M8請額外將5V_MOTO也短路到5V
![](https://i.imgur.com/Ad2rTKw.png)
:::warning
如果沒有短路鏡頭將不會旋轉
:::

## 2. Update Pixhawk FW
因為要使用Lidar關係，安裝Pixhawk FW請將Platform選擇fmuv3
![](https://i.imgur.com/1ghKrrv.png)


## 3. Full Parameter list setting for lidar

### 1. PRX_TYPE
![](https://i.imgur.com/QgXtboo.png)
| Information | meaning | 
| --------       | --------    | 
| 0| None|
| 1| LightWareSF40C-legacy|
| 2| MAVLink|
| 3| TeraRangerTower|
| 4| RangeFinder|
| 5| RPLidarA2|
| 6| TeraRangerTowerEvo|
| 7| LightwareSF40c|
| 10| SITL|
| 11| MorseSITL|
| 12| AirSimSITL|

將PRX1_TYPE設定為5，因為我們要使用的360 Lidar的是RPLidarA1M8所以我們選擇相同品牌的5:RPLidarA2

### 2. PRX_ORIENT 
![](https://i.imgur.com/yKO4Q47.png)
| Information | meaning | 
| --------       | --------    | 
| 0| Default |
| 1| Upside Down|

根據裝在Drone的上方或是下方決定設定0或是1


### 3. SERIAL2_PROTOCOL
因為將RPlidar接到TELTM2，所以將SERIAL2_PROTOCOL設為11，11對應的定義是Lidar360
![](https://i.imgur.com/h41t3yi.png)

### 4. SERIAL2_BAUD
將SERIAL2_BAUD設為115，115對應的定義是鮑率115200
![](https://i.imgur.com/3BsROot.png)
:::warning
根據RPlidar A1M8文件
![](https://i.imgur.com/yHYk7XV.png)

:::
### 5. BRD_SER1_RTSCTS
如果使用Telem1(又名Serial1)或Telem2(又名Serial2)，可能需要關閉流量控制。所以將BRD_SER1_RTSCTS設定為0
## 4. Full Parameter list setting for avoid





### 1. RC8_OPTION

將第八個通道設定為是否自動避障
![](https://i.imgur.com/EFCuMs5.png)

### 2. AVOID_MARGIN
將AVOID_MARGIN設為2m，使得如果有障礙物在Drone 2m內的時候會自動避障往反方向遠離障礙物

### 3. AVOID_BEHAVE



## 5. Check Lidar
回到飛行數據按下Ctrl+F，點選Proximity之後可以看到雷達對應八個象限所偵測到的結果，而0度則對應RPlidar A1M8較為平滑的一面如下圖所示，可用紙板等大面積東西確認RPlidar掃描結果
![](https://i.imgur.com/vNcWzuA.png)

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



參考資料 
---


1. https://ardupilot.org/copter/docs/common-rplidar-a2.html
2. https://bucket-download.slamtec.com/a7a9b856b9f8e57aad717da50a2878d5d021e85f/LM204_SLAMTEC_rplidarkit_usermanual_A2M4_v1.1_en.pdf
3. https://bucket-download.slamtec.com/d1e428e7efbdcd65a8ea111061794fb8d4ccd3a0/LD108_SLAMTEC_rplidar_datasheet_A1M8_v3.0_en.pdf
4. https://ardupilot.org/copter/docs/common-simple-object-avoidance.html
###### tags: `setup`,




