## Getting started with the Raspberry Pi : From the box to SSH

Hi there !

In this article, we'll discuss about the famous Raspberry Pi, a tiny and cheap computer. You can get one for around \$30 and it has a credit card size. The whole thing is run by a 700MHz ARM-based SoC ,assisted by 256MB of RAM (512MB on recent models), 2 USB ports, an ethernet port, both HDMI and composite video output and a SDcard slot where you basically put your OS. It's powered via a micro-USB input (5V @~700mA).

When you receive your Pi, first thing that comes in mind is "gosh it's tiny !". Indeed, this credit card size is quite astonishing for a computer, even if you are used to deal with Arduino and other PCBs of the same size. Fact is that you have here a fully capable computer on which you can put a Linux distribution, decode 1080p videos and run "reasonably powerful" programs. Let's try this little piece of silicon.

Basically, all the information you'll need are gathered here : http://www.raspberrypi.org/. You'll only need a SD card (4go is fine, 8Go is good), and an other computer with a SD card slot to burn your OS.

First thing to do is to download the burner : Win32 Disk Imager. Then download an OS that is compatible with your Raspberry. I strongly encourage you to choose Raspbian “wheezy” if you never experienced Raspberry before. It's a Linux OS based on the Debian distribution.

Then you'll have to burn this. Open Win3D Disk Imager, select your distribution, and write it to the SD card. The process can take several minutes. When it's done, just insert it into your Rasp slot, and it should do the trick.

To start using your Pi without a display, you can use putty and SSH to remotely take control over your Rasp. All you have to do is connect your Rasp to your local network, download PuTTY and connect to the default name of the Raspberry : raspberrypi (or its IP address).

If you see (after  a possible warning message ) a console that invites you to enter a login, your Raspberry is OK and connected ! If not, check again if you're connected to the network.

Enter the default user : "pi" with password "raspberry" (without double quotes). You'll have a prompt that indicates you are now able to type commands over your raspberry. Before doing anything, type the following command :

sudo raspi-config

Select expand_rootfs so your raspberry will use your whole SD card memory. You can also overclock it up to 1000Mhz (I did it without a problem). Reboot your raspberry as asked.

Now, want to see more ? You can use a protocol named VNC that allows you to launch a desktop interface on your Raspberry over the network. Reconnect to your Pi and use this command to download a vnc server :

sudo apt-get install tightvncserver

then launch a server with the command

vncserver

You'll be prompt to enter a password.

If you're on Windows, download VNC Viewer. Once you get it, launch it and select as VNC server "raspberrypi:1". Then hit the connect button and see the magic!

From now on, you are able to remotely use your Raspberry and start thinking about all the applications it has! For example, you can use it as a file server by installing a samba server (which is really easy), as a media center with the well known XBMC... This is totally up to you!

## The quadcopter part 2 : specifications and first manufacturing

So, as you can see there, we had a beginning of stabilization at the end for our first prototype. Still, we were not able to correct the yaw axis, making the drone really hard if not impossible to control. We decided last weekend to build from scratch a new version of the drone. We established the following requierements for this V2 :

- The drone must be built from carbon tubes and balsa wood (that solution seems to be the easiest way to have something very light and robust). To ensure a perfect aligment of the 4 motor axes, we'll double the carbon tubes  for each arm.

- We'll use the following sensors :

• A gyroscope L3G4200D and an accelerometer ADXL345 to capture the rotation angles of the drone
• A magnetometer to capture the absolute rotation around the yaw axis (actually, we found a thesis paper showing how a magnetometer, a gyroscope and an accelerometer can work together to give a very precise angle for each axis, so it will do more than only give us the cap)
• A GPS to capture the absolute position in the 3D space
• A telemeter (basically a sonar) to capture preciselly the altitude of the drone between 0m and 5m.

Here is a little description of the elements we ordered (unfortunately, we didn't receive the shipment this weekend)

You can find pictures of the accelerometer and the gyroscope in the previous article. if you want to know more, here are the links to the datasheets

As you can see, all the devices are controlled by numerical interfaces : I²C , SPI or serial bus. This is very convenient to use thanks to the existing Arduino's libraries.

We tried after this to build a 3d model of what the drone will look like

Actually, this modelisation will be also used to machine the different parts. Indeed, we made a CNC a few years ago (may be will come an other series of articles to describe this awesome project). To generate the toolpaths, I use Mastercam , and the software used to control the mill machine itself is Mach3.

For now, I made a little video of the machining of a motor mount.

To assemble the parts, we massively use epoxy glue (made of 2 components : a resin and a hardener) so there is no possibility for the vibrations to disassemble it.

Here is the result. So far, so good : the 4 motors are perfectly aligned, and we should avoid any excessive yaw-drift problems.

## The quadcopter part 1 : genesis of the project

When I was a student in my engineering school, we decided to build a drone. The project was abandonned after about one year, more or less because members of the robotic team didn't succeed to stabilize the drone. So with my bored engineer friend , we decided to give a second chance to this project. We took what the students made, which basically looks like this:

After a few tries, it turned out that the power of the 4 motors wasn't enough for the drone to fly. So, we decided to make another frame, using light materials: carbon tubes and balsa (it's a very light wood used by modelists for their aircrafts). The verdict was straightforward : old frame's weight : 350g, new one : 70g. Only half of the power was enough to make it fly.

We had here a nice frame to start our experiments. The first version came with an accelerometer and a gyroscope that we decided to keep. We also decided to use an Arduino because it's really easy to use, and there is out there a massive list of existing libraries. Implementing a PID controller, and gathering the commands of a 4 channels radio-emmiter, we were able to make it slighly steady. So this is how it worked. The 2 sensors (accel and gyro) are constantly read by the Arduino, which compute the angle of the 3 orientations of the drone. Why using a combination of a accelerometer and a gyroscope ? Because the accelerometer is nice for a static use of the drone (i.e. it flies at a constant speed), but as soon as it start to move, the accelerometer can't be used. The gyroscope gives us an angular velocity, which means that we have to integrate the value to retrieve the angle. The wrong part is that, due to the integration, the obtained angle will slowly drift. We compensate with a negative term in our equations, which is found experimentaly.

Basically :

Where, if the ADXL gives us a value between 0 and 1g:

And if the gyroscope gives us a value in ° per second, and $d$ the drift value.

Then, we use a PID to control each of the drone axis :

Now come the hardest part of that chemistry : find out $k_p$,$k_i$ and $k_d$; which can bring the drone to destruction (actually, it did).

But still, there is a lot of work there before this drone can fly on its own. We are currently working on a frame v2, which will be the object of a soon-coming article.