Introduction: Getting Started With Emlid Navio+/Navio2
Recently I've got need in building my own copter for research purposes. First of all, that was my first experience with drones, secondly I didn't have much resources to buy many expensive components. That is why I've decided to use Raspberry Pi 2 (which wasn't new to me) as flight controller and just buy a Navio2 board by Emlid. There were few options of autopilot HATs for RPi2 but I won't talk about them, because I don't know much about and of course I didn't try them. The only thing I should mention is that Navio2 reviews seems much nicer than feedbacks about other products on market as well as Emlids community forum seems active and rather friendly.
So I was very happy when it turned out that there are few Navio+ in my university and I can use one of them for my project. I know that Navio2 and Navio+ are different generation, these boards even have different docs but for my purposes Navio+ was more than enough.
However right after I started working with my copter brains I've bumped into the fact that Navio+ docs are outdated and in some place just don't work. Still I am sure that there are enough people like me who only start working with autopilots and drones and particularly Navio. Below I'll do and explain some basic steps to get started with Emlid's Navio+ and Navio2.
I should notice that most of things I am going to do here you will probably find in docs.emlid.com but still I have some important fixes for outdated instructions in the official Navio+ docs and I think if you are just beginning it will be easier to comprehend and learn basics if you follow real experience step by step.
Due to very little experience in this field I will very appreaciate every notice for mistake or inaccuracy in this instructable!
P.S. Some of you will say that starting copter building experience with RPi2 and autopilot shield for flight control is rather complicated and self-confident. So I should agree with the fact that I jumped over a lot of theory and practice, but very soon I will need exact configuration combining computing power and set of sensors for my research. If I'll stuck somewhere, I hope that I'll get help of experienced people.
Step 1: Preparing and Assembling Components
I'll work with Navio through wi-fi network from my laptop with Windows 10. Notice that RPi2 doesn't have its own wi-fi module so I've bought one.
Final bill of materials for this instructable:
1 Raspberry Pi 2 Model B (but you can use RPi3)
1 SD-card 8Gb
1 SD-card reader
1 USB Wi-fi module (I will use EDUP EP-N8508)
1 Navio+ Shield
1 Extension header for 40-pin gpio port (goes with Navio in the box)
1 Miсro USB cable
In addition you'll have spacers and screws to fix Navio on RPi2. They will be in Navio factory box. I won't use them, I'll just connect extension header to RPi2 and attach Navio+ on the top.
In case you'll decide to fix Navio and RPi2 you should first attach spacers on RPi2 and fix them, then install extension header and Navio and fix it with screws as well.
Step 2: Preparing Raspberry Pi With Navio+/Navio2 and Powering It
1. Download firmware
To start work with Navio+/Navio2 we should download and install the RPi firmware (its customized Raspbian) provided by Emlid. This firmware will have all needed libraries and it is preconfigured to work with autopilot shield.
Navio won't work with default Raspbian!
Here is official link to firmware (version from 18/07/2016). Before using this exact version I strongly recommend to check for new firmware release here, because some issues may have already been fixed by Emlids dev team that seems working really hard on every reported issue according to forum.
2. Write image
Then we should burn downloaded firmware on the SD-card. As I've already noticed, I am using Windows 10, so I will write firmware image using free Rufus Utility (download here). If you already have software for writing images you can use yours, however the successful result is not guaranteed (for instance Win32DiskImager doesn't properly work with Navios image).
To burn the image:
a. Run Rufus with administrator rights
b. Make sure your selected the right SD-card that should be burnt
c. Tick "Create bootable disc" and select correct firmware (while selecting make sure you are searching through All files)
d. Push Start and agree with all warnings. After few minutes it will be done.
3. Configure Wi-fi
a. After burning image we have to check firstly the content of SD-card, its capacity should be displayed reduced up to 60Mb and the root folder should contain file "wpa_supplicant.conf".
-If you don't have this file, then you are using older firmware version.
-If you have message that you SD card is damaged and needed to be formatted you should format it and try to use other image writing software.
b. Open "wpa_supplicant.conf" with WordPad and enter the SSID and Password for the Wireless Network you are going to work in. I suggest you not to use Wifi with complicated SSID or password to reduce the risk of mistake. Check that your password is put in quotes, otherwise RPi2 won't connect to Wi-fi.
c. Check that file changes are saved.
4.Before powering on
You can now insert an SD-card into RPi2. Make sure that Wi-fi module is inserted as well and Navio+ is securely connected to RPi2.
5. Powering on
I will provide power to RPi2 with Navio through micro-usb cable and my laptops USB3.0. After powering on there should be LED indication on RPi2 and LED indication on Navio. The blinking indication of USB Wi-fi adapter in RPi2 can mean successful connection, it will be not immediately but in few minutes.
Step 3: Finding IP-adress
1. Install NMAP
To start working with RPi2 through network you will need to determine its IP-adress. For this purpose I will be using open source network discovery utility NMAP (direct link for downloading) with Zenmap GUI.
2. Searching for Navio
Power on Rpi2 with Navio and Wi-fi attached, wait for a couple of minutes. Then launch Zenmap, in Zenmap set "navio" as Target and push Scan. If everything is OK, you will see IP-adress of your device (screenshot attached).
Step 4: Login and Updating
1. Getting Putty
To login to RPi2 with autopilot we first have to connect using SSH. To do this from Windows we have to download Putty (direct link for downloading).
2. Connecting and Login
In Putty type in yours RPi2 IP-adress and select SSH for connection type, click open. In console login request will appear. For RPi2:
After that you will find yourself at pi@navio.
First thing you can try to make is system update:
sudo apt-get update && sudo apt-get dist-upgrade
It takes quite a few minutes, during the process you should confirm updates. I recommend to make an update to reduce the risk of getting mistakes during further work.
Step 5: Introducing to Examples
Navio+/ Navio2 has plenty of built-in sensors including terrific inertial sensor MPU9250 (Gyro + Accelerometer + Compass), barometer. In addition there are GPS, ADC and many other stuff you'll need during drone building process.
One more great thing about Emlids Navio+/Navio2 is that its almost each onboard device has its own example in Python or C++, that is really helpful when you are getting started.
To get example folder on your RPi2 you should clone it from github:
git clone https://github.com/emlid/Navio.git
Then we should open this folder and see what is inside:
cd navio ls
You'll see 2 folders: C++ and Python with examples. Let's try them.
If you use Navio2 you should clone this Example folder:
git clone https://github.com/emlid/Navio2.git
Step 6: LED Example
First example is for RGB LED.
First I've tried C++:
When we are in right folder we should make and run the example:
make sudo ./LED
Built-in RGB LED should start shifting nicely.
To stop the example push CTRL+C in Putty interface.
Let's try the same with Python:
first we should return to Navio folder, enter Python folder and check the name for LED example:
cd ../../.. cd Python ls
When running Python examples we should do:
sudo python LED.py
Unfortunatly LED Python example doesn't work.
Let's move now to something more interesting
Step 7: Accelerometer, Gyroscope and Magnetometer Example. Barometer Example.
This example is demostrating the work of inertial sensors of Navio+. By the way, MPU9250 chip, used in Navio+ as IMU is also installed in many tablets, smartphones and other electronics.
I will run this example in Python:
sudo python AccelGyroMag.py
Immediately after start data will be shown on screen. It will update every second and there will be 9 values: 3 values for accelerometer, 3 for gyroscope and 3 for magnetometer. If you'll try to move the device you can see how this parameter are changing.
For demonstrating inertial measurement unit examples in both programming languages are working: in C++ and Python.
There is also Barometer in Navio+ (MS5611 chip) and there is an example demonstrating pressure and temperature. In python:
sudo python Barometer.py
Step 8: An Attitude and Heading Reference System Example
This is absolutely most exciting example for Navio+. It will obtain and visualize data from MPU9250 sensor on the screen of your computer. Before start we have to prepare PC with Windows and it will take sometime. In case with Mac or Ubuntu it is much easier and you don't need to do all this steps.
1. Install Python
I have Python 2.7, you can download it here.
You can download OpenGL on this page. (I tried file named "PyOpenGL-3.0.2.win32.exe")
Pyserial will be needed to receive data from Navio+. I downloaded "pyserial-2.7.win32.exe" from here.
4. Install Freeglut
Now we have to place 32-bit and 64-bit DLLs to Windows 32-bit (C:\Windows\SysWOW64) and 64-bit (C:\Windows\System32) dirs.
5.Download the archive with Navio utilities here
Extract the archive, enter the directory with 3DIMU utility and you'll see python script. You can open this script with IDLE (Python GUI) and run it (F5). Emlid IMU visualizer will appear. Still we need to run example on Navio+ for visualizer starts working.
6. Finding our PCs IP address
To start the example on Navio+ we should figure out our PCs IP address so Navio+ will know where to send data. To find your PCs IP start Command prompt and type "ipconfig". There you'll see your computers IP address.
7. Run example on Navio+
To run example type in Putty:
cd Navio/C++/Examples/AHRS make ./AHRS X.X.X.X 7000
Type in your computer IP address in istead of X.X.X.X. 7000 is the port number used in 3DIMU.
Now we can move and rotate Navio+ and see how the brick on the screen is doing the same.
Step 9: GPS Example
To try GPS example you can just do:
cd Navio/Python python GPS.py
After start we will see data from GPS module every second. Notice that you'll have to connect antenna to Navio+! Otherwise program will output zero values (like on the first picture).
To see how GPS module works in interactive way you can download U-center from here and connect you RPi 2 with Navio+ to it. Do the following to connect:
a. On RPi2 from Navio folder do:
cd Utilities/ublox-spi-to-tcp <br>make ./ublox-spi-to-tcp 5000
This command will run example and open port 5000. You see "waiting for connection" message
b. In U-center do:
Receiver->Port->New Connection->New-> enter the IP of RPi2.
After that in console (Putty) you'll see "connection accepted" message and some visual data in U-center.
Step 10: Autopilot Installation and Running
The last thing I'll do in Getting Started is autopilot installation and running on Rpi2 with Navio+/Navio2. For Navio+/Navio2 there is autopilot called APM (Ardu Pilot) which runs directly on Raspberry Pi 2. We can get it from here:
sudo apt-get install apm-navio
It will take about 7-8 minutes to download and install APM package from Emlid website.
While APM is installing on RPi2 we should download ground control station software on the laptop. For APM it is APM Planner.
After launching APM planner we can connect RPi2 with Navio to it:
sudo ArduCopter-quad -A udp:192.168.1.X:14550
192.168.1.X - the IP address of you computer. 14550- UDP port for APM planner, so it should catch telemetry from the future drone automatically.
After the successful connection Navio+ LED must be blinking orange and in APM planner you can see changes in on flight display while moving and rotating your device.
Please write me for any questions or comments!
Next time I'll try to make an instructable for a drone making process using Navio+.