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

August 9, 2017 | Author: Adam Wathieu | Category: Technology, 3 D Printing, 3 D Computer Graphics, Unmanned Aerial Vehicle, Lidar
Share Embed Donate

Short Description

Some notes on how to add an RP LiDAR onto the DJI Matrice 100 drone so that the drone stops and hovers when it is approa...


Adding an RPLiDAR onto the DJI Matrice 100 Drone to Implement Obstacle Avoidance Brian Cruz1, Olu Roy2, Adam Wathieu3, Kamel Saidi4 19 June 2017


Wheaton High School Marriots Ridge High School 3 Winston Churchill High School 4 National Institute of Standards of Technology 1



Table of Contents: List of Necessary Items Introduction Setup Raspberry Pi Raspberry Pi Network Matrice 100 Drone RP LiDAR A2 Mounting 3D Printing Configurations Testing Showcase

3 4 5 5 6 7 8 9 9 12 13


List of necessary items Hardware: • • • •

• •

DJI M100 Drone o Raspberry Pi 3 Model B o Slamtec RP LiDAR A2 o 32 GB MicroSD Card o &sr=1-2&keywords=32+gb+micro+sd+card Anker PowerCore 10000 o 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 +2+1.1.2_2.pkg DJI Go (for device connected to remote controller) o Etcher o


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 o d_Safety_Guidelines_en_160304.pdf o attery_Safety_Guidelines_en_v1.0_201509.pdf o

RP LiDAR A2 o d5d021e85f/LM204_SLAMTEC_rplidarkit_usermanual_A2M4_v1.1_en. pdf o e25a47357/LR001_SLAMTEC_rplidar_protocol_v1.0_en.pdf


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: 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

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 Raspbian Jessie is an operation system for the pi. More information at: 6 gcc is a C++ compiler. More information at: 7 CMake is a building platform. More information at: 8 Git is a version control system. More information at: 5


Figure 1.0

Figure 1.1

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 netmask wireless-channel 1 wireless-essid Matrice 100 PI wireless-mode ad-hoc

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


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: [email protected]:~ $

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: 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: 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.


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. Figure 1.2

RP LiDAR A2 If you haven’t familiarized yourself already to the software and its capabilities, consult: LM204_SLAMTEC_rpLiDARkit_usermanual_A2M4_v1.1_en.pdf

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


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 Figure 2.0 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 • SketchUp (for Mac)11 o • Slic3r (for Mac)12 o LulzBot Taz 4 is a 3D printer. More information at: 11 SketchUp is a 3D modeling application. More information at: 12 Slic3r is a G-code generator for 3D printing. More information at: 10


Insert the SD card provided by the LulzBot Taz 4 into your computer. Then, download the following STL file13: 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: If you are using this filament, then your settings should be as follows: Print Settings:

Filament Settings:

STL is a file format specific to 3D models. More information at: 13


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.


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.




View more...


Copyright ©2017 KUPDF Inc.