Friday, April 22, 2011

Broken Drone

HOW THE DRONE BROKE
We were trying to use a serial cable to connect to the drone motherboard. The drone motherboard has a port on it that is labeled as USB but it has a non-standard connector. On line were instructions on how to make a cable that would connect to the drone motherboard, but the instructions were not entirely clear.

The part of the process that was clear was that some special software needed to be compiled for the drone. This was a kernel module called 'dwc_otg.ko'. Then once the software was in place a special cable could be used to connect to the drone. The kernel module sources were modified and built for the ARM processor and installed on the drone. This took some time.

Then we ended up making two cables, one that was just a wire connecting a standard USB male connector with a specially made connector on the other side for the drone. The second cable was made with the standard USB male connector, an intermediary circuit in between, and again the special connector for the drone.

There were two test circumstances that we wanted to try. First we wanted to test the cables with a USB thumb drive, checking the 'dmesg' output on the drone to see if the device detected the drive. Then we wanted to connect to a computer and try to figure out a way to use the connection as something like a serial terminal. The reasoning for using the thumb drive was that the thumb drive had no power supply, so there was no chance of damaging the drone. In the forum posts people had success with this kind of testing, and the 'dmesg' output showed that a memory device was connected at the serial port.

We tried the cable with the intermediary circuit first. There was 'dmesg' output showing that the kernel module was working, but nothing showing the drive itself was recognized. There was some output on dmesg, but it was just a string of hexadecimal numbers, and it did not look like the output that people on the forums were getting. Then we tried that cable with a computer on the other end of the cable instead of the thumb drive. Again nothing showed on 'dmesg' to identify a computer.

Then on another day we tried the cable with no intermediary circuit. First we tried it with the thumb drive. There was output from 'dmesg' but not enough to identify the drive. Then, thinking that nothing would happen, we connected that cable to a computer. This is how the drone was damaged.

FIXING THE DRONE
Immediately after the drone was damaged we rebooted it. All the indicator lights on the motors went from red to green as they were supposed to do for a normal boot up. The drone even flew briefly, taking off and landing. The first indication was that it was not seriously harmed.

Later it stopped working, so at first we were confused as to what was happening. We could still telnet in to the motherboard but we could not fly the drone, and during boot up, two of the four motor lights that were supposed to light up and turn from red to green did not do that. We took the drone apart and identified a spot on the motherboard where a component had burned. For this reason we decided that the motherboard needed to be replaced.

A new motherboard was ordered and we installed it, but the two motor lights that would not light up before still would not light up. At the time of this writing the drone is still broken, and we are looking at the motors themselves as the cause of the latest problem. The idea now is to interchange the motors in different positions on the drone to see if the motor itself is broken or if it's some kind of other problem. The motors are replaceable but everyone is wary of replacing a part and finding that the drone still does not work.

UPDATE:
It was determined that two motors were broken. New motors were ordered and the old ones were replaced. The drone now works.

Friday, April 1, 2011

Watchdog Command

While working on my embedded program, I found that it needed to constantly be sending something called the "watchdog" command. Once this command is being sent every 100-150ms or so, the pitch and roll values actually make a difference.

Here is the command:
AT*COMWDG=seq

Thursday, March 31, 2011

New URBI Info

Take a look at this. It's an update from the guy that modified urbi for the AR Drone:

http://translate.google.fr/translate?hl=fr&sl=fr&tl=en&u=http%3A%2F%2Fwww.psykokwak.com%2Fblog%2Findex.php%2F2011%2F03%2F28%2F60-ar-drone-et-urbi-embedded

I think we can use urbi again, and even better, it's actually embedded on the drone in this more recent example. The site above is originally in French, but this link should provide a translated version. The post that I'm reading is dated March 28, 2011. The only question is weather or not the new urbi download he's providing works with the new firmware. The download is for urbi 2.6. I'm hoping it works.

This is the link to his urbi software package:

http://www.psykokwak.com/blog/images/ardrone/urbi-sdk-2.6-525.tar

This is the link to the howto video:

http://www.youtube.com/watch?v=Cdxq89CigcI&feature=player_embedded

There's more stuff on the translated french site:

http://www.youtube.com/watch?v=Wiv4rC-doJI&feature=player_embedded

Tuesday, March 29, 2011

Follow up to "Running an application on the drone"

So after working on my UDP client for a while (using a server to echo any commands received) I have been able to develop a working application for the drone that runs natively on it. The code has to be compiled for ARM and is through the CodeSourcery IDE.

Initially I had figured I'd make something that just runs a set of commands and then you would have to edit the source, recompile, etc. to get a different set of commands. Upon further review I decided this wouldn't be all that flexible and would generally be boring. So I wrote up a small command line app that takes commands directly from the standard input and sends them to the drone. Something like "takeoff" or "land" or "gaz .4". Today was the first day I was actually able to test the code and after a few minor changes it worked! I immediately found that I had the same issue with this code as we had had with nearly everything else we'd written for the Drone. We could do the usual takeoff and land and even adjust the Yaw and Gaz, but yet, as usual, we were unable to get the drone to move forward or backward. I dug into the AT command to make sure every bit of information was being sent correctly, and this seemed to be the case. Even other users in the community had used the same commands.

When developing the app I had figured I might run into this issue again, so I had written it so that a thread is immediately dispatched when the code is executed. This thread sends a simple AT command to the drone every 100ms or so, simply to keep the connection alive. In the past when we had looked at this issue before, Dave had found that with a constant "heartbeat" command, we were able to get Pitch and Roll working. Alas, this didn't seem to fix the issue in my case, or so I thought. So I had been sending a command that simply set the Yaw, Pitch, Gaz and Roll to their current settings. So the command had no visible effect on the drone but it did keep reminding it of its current status.

Upon further research I found that this issue had actually been come across by others and they had take a similar, yet slightly different, approach. They had used a heartbeat AT command but the command itself was different. Instead of setting those values mentioned, the simply trigger something called the "Watchdog", using AT*COMWDG=seq, where seq is the current sequence number.

At last, it worked! I was able to get the roll and pitch to change. I quickly realized that it wasn't sticking though and came to the conclusion that I should re-include the other heartbeat command I had used before, to constantly remind the Drone of its state. This fixed it and now the pitch and roll (and yaw and gaz...) stick!

One of the goals of this course was to get the Drone to perform a certain flight pattern on its own. Having to sit in front of the screen typing command after command was somewhat tedious and I thought I might develop a way for the program to read a file. The final scripting files are quite simple and are really the same as typing the commands, with each command one 1 line. I had some trouble getting this to work initially because I had forgotten about implementing a sort of "wait" functionality to pause between commands. Once that was up and running, though, I was able to write out some simple scripts to get the Drone moving.

Here are my sample scripts:

script1.ard:
takeoff
wait 7
land


script2.ard:

takeoff
wait 6
yaw .7
wait 5
yaw 0
wait 4
gaz .3
wait 7
gaz -.3
wait 4
pitch -.3
wait 2
pitch 0
land


script3.ard

takeoff
wait 7
pitch -.3
yaw .3
wait 2
land


These are simply text files and .ard was an extension I made up. I plan on testing this out further and will likely allow you to execute the program with a script as an argument instead of the current method of entering "file" then the script. Or maybe I'll keep both?

I'm also going to look into any startup scripts that the Drone has and look at the possibility of having the drone immediately run a set flight pattern when it starts.

AR Drone Demo Android App

I've been working on an Android app for the class that controls the drone and also directs the drone on simple preset flights. The app is about done, and I feel all I have to do is test it out a couple of times in a large room to fine tune the preset flights. The app also records and plays back drone movements. This part of the app still only works marginally well. I'm going to write a short explanation of how the controls for the app work, and put it on the wiki page of the google-code project.

For the time being, there's a version of the app that can be downloaded from the 'Downloads' page of the google code site. I have not yet put it on the Android market. The link to the 'Downloads' page is below.

http://code.google.com/p/ardrone-smash/downloads/list

Monday, March 21, 2011

Running an application on the drone

So I've taken up the project of trying to get something running on the AR Drone. The idea is that there will be an program that will be stored within the memory of the Drone that we can run and it hopefully will be able to send commands which the Drone will respond to. As a start, I was given some (non-working) code that would send UDP packets to a specific port on localhost. The thinking here is that since the Drone already received commands over UDP, it would make sense that an application running on the Drone would simply send commands to itself.

I was given a start with a basic client and server code in C++ that needed to be cleaned up and fixed before I could run it. Once I had gotten it running, I ran into different issues with the network buffers and buffer sizes where the commands weren't being sent as a complete string. Anyway things seem to be running relatively well now.

The server is basically an echo server and outputs anything that is sent to it. It appears to be receiving the entire command, as it should. The client is a basic command line program that lets you input specific commands, although only "land" and "takeoff" right now. Once we are back from break I will ftp the files onto the Drone and hopefully they will work!

Monday, March 14, 2011

more on dwc_otg.ko module

I built the module as per instructions from the earlier post, and edited the 'vermagic' number in the binary file with a hex editor. Hopefully it will still work. The link to the building instructions is here:

http://embedded-software.blogspot.com/2011/01/creating-testing-and-flashing-tbd.html?showComment=1298131219050#c8216733809012047042

The critical part I was missing was to execute

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig

which gives you a group of config options that is different from those to be found just by typing 'make menuconfig'. With these options, select "System Type ---> Parrot drivers ---> PARROT6 USB driver (Synopsys)" . Then you can type

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules

This will compile the modules, including the dwc_otg.ko module. Then you have to edit the 'vermagic' string as described in the link below:

http://www.rcgroups.com/forums/showthread.php?t=1335257&page=33

Then you ftp the module over and try the insmod command to see if it inserts.

$ ftp -n 192.168.1.1 (with no port num specified)
ftp> put dwc_otg.ko
ftp> exit

$ telnet 192.168.1.1
# ls /data/video
# mv /data/video/dwc_otg.ko /home/default/dwc_otg.ko

check to make sure that the file is large enough because 'ftp 192.168.1.1 5551' puts files in the /update directory, BUT the files have no contents.

# cd /home/default
# insmod dwc_otg.ko
# lsmod
(listing of inserted module)
# rmmod dwc_otg

So, so far it seems to work. Now we need to test the usb cable itself.