• No results found

Adding an RP LiDAR onto the DJI Matrice 100 Drone to Implement Obstacle Avoidance

N/A
N/A
Protected

Academic year: 2021

Share "Adding an RP LiDAR onto the DJI Matrice 100 Drone to Implement Obstacle Avoidance"

Copied!
13
0
0

Loading.... (view fulltext now)

Full text

(1)

Adding an RPLiDAR onto the DJI Matrice 100

Drone to Implement Obstacle Avoidance

Brian Cruz1, Olu Roy2, Adam Wathieu3, Kamel Saidi4 19 June 2017

DOCUMENTATION

1 Wheaton High School 2 Marriots Ridge High School 3 Winston Churchill High School

(2)

Table of Contents:

List of Necessary Items

3

Introduction

4

Setup

5

Raspberry Pi

5

Raspberry Pi Network

6

Matrice 100 Drone

7

RP LiDAR A2

8

Mounting

9

3D Printing Configurations

9

Testing

12

Showcase

13

(3)

List of necessary items

Hardware:

• DJI M100 Drone o https://www.dji.com/matrice100 • Raspberry Pi 3 Model B o https://www.raspberrypi.org/products/raspberry-pi-3-model-b/ • Slamtec RP LiDAR A2 o https://www.slamtec.com/en/Lidar • 32 GB MicroSD Card o https://www.amazon.com/SanDisk-microSDHC-Standard-Packaging- SDSQUNC-032G-GN6MA/dp/B010Q57T02/ref=sr_1_2?s=pc&ie=UTF8&qid=1500473771 &sr=1-2&keywords=32+gb+micro+sd+card • Anker PowerCore 10000 o https://www.amazon.com/Anker-PowerCore-Ultra-Compact-High-speed-Technology/dp/B0194WDVHI/ref=ice_ac_b_dpb?s=wireless&ie=UTF8& qid=1500483592&sr=1-4&keywords=anker+battery

• A personal computer (tested on Mac and Linux)

• A monitor, keyboard, and mouse (for setting up Pi, unnecessary for later procedures)

Software:

• DJI Assistant 2 (for Mac)

o https://dl.djicdn.com/downloads/dji_assistant/20170619/DJI+Assistant +2+1.1.2_2.pkg

• DJI Go (for device connected to remote controller)

o http://www.dji.com/product/goapp?www&www=v1 • Etcher

(4)

Introduction

The objective of this project is to add a LiDAR onto the M100 drone to implement obstacle avoidance. This means that whenever the drone approaches an obstacle on its horizontal axis, it will autonomously stop and hover in a stable position to avoid

damage.

PLEASE NOTE:

This project is not designed to avoid obstacles above or below the drone. It only senses obstacles on its horizontal plane.

We will be doing this by mounting the Raspberry Pi, the external battery, and the LiDAR onto to the top part of the Matrice 100 center frame. We will collect data from the Pi via remote access from another computer. By having the data sent to a computer on the ground, we will be able to see what the Pi is doing and the decisions it’s making in real time while the drone is flying.

Before you begin, it is important to look at all the necessary manuals. Please take the time to read these manuals:

• DJI M100 Drone o https://dl.djicdn.com/downloads/m100/M100_User_Manual_EN.pdf o https://dl.djicdn.com/downloads/dev/Matrice/en/M100_Disclaimer_an d_Safety_Guidelines_en_160304.pdf o http://download.dji-innovations.com/downloads/dev/Matrice/en/M100_Intelligent_Flight_B attery_Safety_Guidelines_en_v1.0_201509.pdf o https://developer.dji.com/onboard-sdk/documentation/M100-Docs/main.html • RP LiDAR A2 o http://bucket.download.slamtec.com/a7a9b856b9f8e57aad717da50a2878 d5d021e85f/LM204_SLAMTEC_rplidarkit_usermanual_A2M4_v1.1_en. pdf o http://bucket.download.slamtec.com/63ac3f0d8c859d3a10e51c6b3285fcc e25a47357/LR001_SLAMTEC_rplidar_protocol_v1.0_en.pdf

(5)

Set Up

Raspberry Pi

First, we have to set up the Raspberry Pi. Insert the MicroSD card into your computer. Then download the following image of the Raspberry Pi operating system:

https://downloads.raspberrypi.org/raspbian_latest

Then use Etcher to convert this image onto the MicroSD card. Then insert the MicroSD card into the Raspberry Pi, and boot it up.

Once you are in, open Command line. Execute these following commands: Update the software of Raspbian Jessie5:

sudo apt-get update sudo apt-get install

Install gcc6:

sudo apt-get install gcc-4.8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50

Install CMake7:

sudo apt-get install cmake

Install Git8:

sudo apt-get install git-all

Now we have to download the SDK necessary to make this all work. In your desired directory, execute the following command:

git clone https://github.com/cruzsbrian/m100-lidar.git

Please read README.txt to get information about this sdk.

Now we have to setup all the hardware pertaining to the Pi. Connect the raspberry pi to the LiDAR through the USB port. Then connect the Raspberry Pi to the drone using the UART cable that is provided in the DJI M100 contents. The cable is connected into the

5 Raspbian Jessie is an operation system for the pi. More information at: https://en.wikipedia.org/wiki/Raspbian

6 gcc is a C++ compiler. More information at:

https://en.wikipedia.org/wiki/GNU_Compiler_Collection 7 CMake is a building platform. More information at: https://en.wikipedia.org/wiki/CMake

8 Git is a version control system. More information at: https://en.wikipedia.org/wiki/Git

(6)

UART_CAN2 port of the drone (figure 1.0). The other side is connected to the GND, TXD, and RXD pins of the pi (figure 1.1). Make sure that the RXD cable of the wire goes to the TXD Port (Port 8), and that the TXD cable of the wire goes to the RXD Port (Port 10).

Raspberry Pi Network

In order to communicate with the pi while the drone is flying, we set up a remote access network using SSH9. This makes the Pi create a local network on boot up, which your computer can connect to so that you are able to communicate with the Pi via your computer.

Save /etc/network/interfaces file in case you need it again:

cp /etc/network/interfaces /etc/network/interfaces

Now modify etc/network/interfaces:

nano /etc/network/interfaces

Once you are in the nano platform, delete everything and add:

auto wlan0

iface wlan0 inet static address 192.168.1.1 netmask 255.255.255.0 wireless-channel 1 wireless-essid Matrice 100 PI wireless-mode ad-hoc

9 SSH allows us to use the command line of the Pi remotely from another computer. More information at:

https://www.raspberrypi.org/documentation/remote-access/ssh/

(7)

Now reboot the pi. On your computer network settings, there should be a network called Matrice 100 PI. Connect to it. Then, open up command line, and execute the following command:

Use the command line of the Pi:

ssh [email protected]

If that doesn’t work, try:

ssh [email protected]

After entering the password of your pi, you are using your Raspberry Pi’s command line, denoted by:

pi@raspberrypi:~ $

Now you can put away the Pi’s monitor, keyboard, and mouse. To use your Pi now, simply plug it in to the Anker or any power source, connect to its network on your computer, and execute ssh [email protected] in your computer’s command line.

DJI Matrice 100 Drone

To get everything to properly work, we need a way for the pi to communicate only and directly to the drone. Hence, we have to create what is called an app. First, if you aren’t one already, register as a developer at:

https://developer.dji.com/register/

Then, you must create the app. Hover over to User Center and create an Onboard SDK app. Take note of the app information, namely the App ID and App key. We will use these later.

If you haven’t familiarized yourself already to the software, and what capabilities it has, consult:

https://developer.dji.com/onboard-sdk/documentation/M100-Docs/main.html

PLEASE NOTE:

Most of the information in the developer documentation portion of their website regards version 3.3 of their SDK. As of June 19, 2017, the latest version of the SDK that supports the Matrice 100 is 3.2. Please be aware of the documentation you are using. To avoid risk, we recommend that you only use the above link to research the documentation of the Matrice 100.

(8)

Next, we need to modify the drone settings to accept API control and we need to update its firmware if

necessary. In Assistant, hover to SDK and check the box labeled “Enable API Control” (figure 1.2). Also, make sure that the Baud Rate is set to 230400. Then, in the firmware Upgrade section, check to see if any updates are required.

RP LiDAR A2

If you haven’t familiarized yourself already to the software and its capabilities, consult: http://bucket.download.slamtec.com/a7a9b856b9f8e57aad717da50a2878d5d021e85f/ LM204_SLAMTEC_rpLiDARkit_usermanual_A2M4_v1.1_en.pdf

Figure 1.2

Figure 1.3:

From left to right: Matrice 100 remote, Matrice 100, Raspberry Pi, Anker Power bank, RPLiDAR A2

(9)

Mounting

To mount these pieces onto the M100, we used zip ties and 3D printed a mounting plate for the LiDAR. We placed our Pi under the first expansion bay, and replaced the expansion bay plate with our own 3D printed plate that was custom fit in order to accommodate the LiDAR that was to be placed on top of it. We zip tied the Anker power bank on top of where the camera is

mounted, in the front of the drone. Our program is

designed to omit the GPS module as an “approaching obstacle,” so there is no need to displace the GPS module or remove it. Our mounting setup is shown in Figure 2.0.

3D Printing Configurations

Although the LiDAR can be mounted several ways, we decided to 3D print a mounting plate that holds the LiDAR and replaces the expansion bay plate. For those who are interested in 3D printing the plate, our documentation is as follows:

First, we need all the necessary hardware and software: • LulzBot Taz 410

o

https://www.amazon.com/LulzBot-TAZ-4-3D- Printer/dp/B00JXQZ8CC/ref=sr_1_1?ie=UTF8&qid=1501513886&sr=8-1&keywords=lulzbot+taz+4

• SketchUp (for Mac)11

o https://www.sketchup.com/Download • Slic3r (for Mac)12

o https://dl.slic3r.org/dev/mac/slic3r-1.3.0-dev-13f121e-.dmg

10 LulzBot Taz 4 is a 3D printer. More information at: https://www.lulzbot.com/store/printers/lulzbot-taz-6

11 SketchUp is a 3D modeling application. More information at: https://en.wikipedia.org/wiki/SketchUp

12 Slic3r is a G-code generator for 3D printing. More information at: http://slic3r.org/

(10)

Insert the SD card provided by the LulzBot Taz 4 into your computer. Then, download the following STL file13:

https://slack-files.com/T61ST81T3-F6G3GSH45-7c281d5d98

Open Slic3r, and click Add. Then select the downloaded STL file to add. In the Print Settings, Filament Settings, and Printer Settings, change the settings according to your configuration and your filament type. We used the following filament:

https://www.amazon.com/Verbatim-PLA-Filament-3mm-Reel/dp/B00LPSD7YC?th=1 If you are using this filament, then your settings should be as follows:

Print Settings:

Filament Settings:

13 STL is a file format specific to 3D models. More information at: https://en.wikipedia.org/wiki/STL_(file_format)

(11)

Printer Settings:

Next, in the Plater tab, hit Export G-code. Save the exported file into the SD card. Then, insert the SD card into 3D printer, and print form the SD card. If you want to change the 3D model, use SketchUp to design your own model.

(12)

Testing

Now, to test and run the drone with obstacle avoidance, make sure the drone is in a netted area, and that everyone surrounding this net knows and is aware of the flying drone. It is also very important that this is tested and run outside, so that the Matrice 100 can use the GPS to stabilize when hovering. Again, make sure the drone is a safe distance from anyone, and if possible, add a net. After booting up everything, SSH into the Pi via your computer. Now, get into the m100-lidar directory, and execute the following commands to get the obstacle avoidance up and running:

Go into build directory:

cd onboard-sdk/build

Compile the program:

make

Go into the bin directory:

cd bin

Edit UserConfig.txt:

nano UserConfig.txt

Enter in App ID and Key (For more information, refer to Set Up page):

ID: KEY:

DeviceName: /dev/ttyS0 BaudRate: 230400

Version: versionM100_31

Execute following command to start the program:

./djiosdk-linux-sample -interactive

Hit ‘Z’ to start obstacle avoidance. The drone must have lifted off before obstacle avoidance is started.

(13)

References

Related documents