Author: Arnaud

Last week I was at Lua Workshop 2015 in Stockholm, it was a very interesting conference with lots of interesting people. I also had the opportunity to see the office of King, the host for the workshop, and it gives a lot of idea for fun stuff and toys we could have in our office :-)

On a side note we are organizing a presentation in our office in Malmö the 22nd of October: Mandy from Seeedstudio is visiting us and will talk about manufacturing in China. If you want to come you can register.

lua-logo-crazyflie

Now, back to Lua. Lua is a dynamic programming language that is small, fast and meant to be embedded within other programs. Currently is is used a lot in video games and a bit on servers. It has also be used in deeply embedded system with the eLua project, for example Seeeds sells a Lua-preloaded ESP8266 wifi module. One of our plan for Crazyflie 2.0 is to be able to write deck drivers in Lua.

With Crazyflie 2.0 we are aiming to make a research-grade flying platform more accessible and versatile, hence the expansion capabilities (with decks) and the new API we are writing for it. Lua would fit well in this goal. It would allow to very quicky script and test a device driver. As a bonus Lua being safe (ie. the virtual machine cannot crash the system), there would be no risk of crashing the copter with those kind of driver. The architecture would look something like that:

cfluaArchitecture

Though Crazyflie Lua integration has not been prioritized so far, we think it is something that would be interesting to play with it in the future. If anyone is interested into testing and helping out please reach us on Github or on the forum.

This year we decided to save some time and split up for the last two Maker Faires. So last weekend Tobias and Christopher went to the Maker Faire in New York. They had a great but hectic time. More about it in a next post.

Meanwhile me and Marcus are going to Maker Faire Berlin next week end, from 2015-10-03 to 04. We will be standing in the Seeedstudio booth showing the Crazyflie. We’re also planning on having our first ‘meetup’ since we are sure to have at least Fred, the main Crazyflie Android client maintainer :-). We have created a forum thread to discuss it. If you are in Berlin next weekend and want to meetup and talk to us and other Crazyflie enthusiasts drop a line in the forum. The meetup will be somewhere in Berlin so do not hesitate to join even if you do not attend the Maker Faire. We will announce the exact time and place on the forum, it will certainly be on Saturday the 3rd.

icon_Berlin

On an other subject, Wolfgang, from USC, is having a talk at the IROS conference. He is going to present his research on Mixed Reality, where one of the platforms he’s using is the Crazyflie 2.0. We have visited Wolfgang’s lab and University before the Maker Faire Bay Area and we where really impressed, they are doing great research. Here’s the info on the talk:

Event: International Conference on Intelligent Robots and Systems (IROS), Congress Center Hamburg, Germany
Talk: “Mixed Reality for Robotics,” October 1, 12:20 – 12:35
Room: Saal A4
Abstract: link

IiROS logo

DWM1000 nodes
Last hacking-Friday we have had some time to put together the DWM1000 boards we ordered during the summer. The DWM1000 from Decawave is an ultra-wide-band ieee802.15.4 radio transceiver that can very precisely timestamp packets arrival and departure. More simply it means that it is a standard and it can be used to implement a real time local positioning system: this could be really handy for the Crazyflie. We soldered all the boards and we got some basic ranging working on the nodes. The next step is to implement an opensource driver to be able to implement the ranging in the Crazyflie. We will keep you updated on the progress but in the mean time here is a photo of the prototypes:

DWM1000 nodes and deck

 

Things happening on the firmware side
Recently the commit rate for the Crazyflie 1.0/2.0 firmware has increased a lot. Some of it because of pull requests, great work, and some because we are starting to move in hacks and such on feature branches into the master branch. Our new college Kristoffer has taught us that having stuff on feature branches can be a bad idea, they tend to stay there. It is then better to have them compile switched and in the master branch as it is more visible and get a better chance of getting in for real.

Github crazyflie firmware contributions

 

Here are some of the recent thing going on:

  • A situation awareness framework originating from this pull request by fredgrat. It allows the Crazyflie 1.0/2.0 to react to triggers. Currently there is a free-fall, tumbled and at-rest detection. He recently also submitted an auto-takeoff functionality. Enable the functionality with the define here.
  • The beginning of a Arduino like API for the deck port. Currently GPIO and ADC are the only functions there but more will come.
  • Possibility to fly in rate (acrobatic) mode committed here. Support in the cfclient for this is being developed so currently one have to change the parameters to activate it manually.
  • Carefree, plus and X-mode implemented in firmware. There is also support for this being added to the cfclient.
  • Automatically switch to brushless driver. Motor driver being rewritten so it can be dynamically configured. This means that if the Crazylfie 2.0 is attached to the big-quad-deck it can automatically switch over to the brushless driver during power on.

Summertime are good times, less administration and more time to develop! As soon as things has been integrated and fully tested we will do a new release of the firmware and the cfclient :).

Big Quad Deck

So last week we received the first prototypes of the Big-quad-deck. With this deck it will be possible to transform the small Crazyflie 2.0 into a flight controller of a bigger quad. It does this by using some of the deck port pins to drive brushless motorcontrollers. This has been explained how to do using a prototype board in a previous post. For those that like it to be more convenient the Big-quad-deck will be a good choice. This will also use the one wire memory so that it will automatically detect the big-quad-deck board and configure it, that is the idea at least :-). So currently the dynamic motor driver is one of the things we are working with. Well that and fixing the layout of the board as there was a major mistake of mirroring the deck port connectors… no blaming :-)

big-quad-deck
Big-quad-deck with cf2

 

iPhone bootloader

The bootloader is finally implemented on iPhone. The change have been pushed to github and will be released before the next firmware release. The GUI is simple and hopefully clear enough:

bootloader-flashing bootloader-idle

The iOS app fetches the latest firmware directly from GitHub and the flashing operation takes about 10 minutes. All new code written for the app is written in Swift, there is an ongoing work to cleanup the app architecture to make it easier to implement more advanced functionality like log/param. We are actually thinking of converting the full app in Swift to make it easier to work with.

The next step is to implement the bootloader in the Android client, this will be one of our main tasks for next week.

We have had a lot of deck ideas for the Crazyflie 2.0 but not much time to finish anything, now we finally took the time to order batch PCBs at seeeds so we though we could show a bit what we are working on. Our idea is to order during the summer while some of us are in vacation so that we have all the hardware available when everyone comes back.

One deck that we are working on for a long time is the GPS deck:

ublox GPS deck

We had a prototype last summer but we never managed to get it to work properly: the antenna of the module we used relied too much on the ground plane and was disturbed by the proximity of the Crazyflie. Now we are using a more traditional chip-antenna which, we think, might work better in our design. We also added a u.fl connector to add an external patch-antenna in case the chip antenna is not good enough.

Lately we posted about connecting Crazyflie to a bigger quad frame to use it as a flight controller. We made an adapter deck for this purpose:

Big quad addapter deck

 

The deck can be on top or bottom of the Crazyflie and has output for 4 motor controller, a SPPM input for RC receiver, monitoring input for battery current and voltage, I2C connector and finally a GPS connector. We tried as much as possible to use standard pinout for the connector. Finally this board has holes spaced at 30.5mm, which is common for attaching controller boards.

Some time ago we have seen an interesting kickstarter that implemented local positioning, the pozyx project. While looking at it we found that the transceiver they are using is available, it is the DWM1000. We are really interested about this technology so we made a deck out of it:

dwm1000 deck

 

The DWM1000 tranceiver allows for time-of-flight measurement which would allow to make a local positioning system. This is something we have been looking at for a long time. Of all the prototype board this is the one that might take the most time to develop though, as the software work will be extensive.

Another board we wanted to do for a while is an Intel Edison adapter deck:

edison

 

One thing that delayed us to make this board is the use-case: the main use-case we see for Edison is to connect a camera but the Edisson does not have the MIPI interface required to connect a small and lightweight camera. On this deck we wired the USB port both to a uUSB connector and to breakout pins giving options on how to connect a USB camera.

Finally for the end we keep the simplest but very useful for development FTDI cable adapter deck:

ftdi

 

On the middle of this deck can be connected a standard 3V3 FTDI cable, and jumper allows to connect the RX and TX pins to UARTs on the deck port. It can be used both to debug the Crazyflie 2.0 firmwares and to debug other decks (for example to talk to the GPS deck).

We will keep you updated when we have received and gotten to work the boards (some will be much quicker that other as you can imagine).

While we where in the US we finally received our long-awaited HackRF Blue. Our plan was to use it to sniff the Crazyradio and Crazyflie communication in order to be able to better debug the communication.

HackRF Blue is a lower cost build of the open source HackRF One. It is a Software Defined Radio (SDR), you can think of it as a sound card for radio. It allows to observe and manipulate radio signals from ~1MHz up to 6GHz within a maximum bandwidth of 20MHz. We use it with GNU Radio on the PC which is a signal processing library that contains all we need to do using SDR. Gnuradio has a nice GUI, the Gnu Radio companion, that allows to start testing without having to write code (this GUI actually output a Python program). Getting into SDR is not easy, we have been looking at the Michael Ossmann’s SDR videos (I suggest you look at them if you want to learn about SDR!) and it helps a lot understanding what to do. In this post I will try to briefly explain the step to detect and decode the Crazyradio nRF24 signal. We wrote an howto in the wiki if you want to set up an nRF24 sniffer.

To test the HackRF I just created a very simple python script that sends 10 packets per seconds with Crazyradio:

from crazyradio import Crazyradio
import time

cr = Crazyradio()
cr.set_channel(26)
cr.set_data_rate(cr.DR_1MPS)

while True:
    cr.send_packet((0,1,2,3,4))
    time.sleep(0.1)

Then we just tune HackRF to the Crazyradio frequency, and we can see the GFSK signal!

iq_scope_grciq_packet

GFSK is a kind of Frequency Modulation. Which means that it should be a cosine wave of constant amplitude. So calulating the magnitude of the complex signal allows to locate data packets by setting the scope trigger:

mag_grcmag

Now that we can synchronize on a packet, we can add a filter and a quadrature demodulator to demodulate the fm signal and show the data packet (in green):

mag_demod_grcmag_demod

The preamble (series of 0101010101) is clearly visible followed by the radio address which is 0xe7e7e7e7e7. Now the ‘only’ things left would be to decode the packet. Hopefully for us Cyber Explorer already did the hard work and all we have to do is to send the demodulated data in a unix fifo and send the fifo in the decoder. This procedure is explained in the wiki. As a result we receives the packets:

nrf24_recv

As a conclusion we found that with the current setup we have a lot of packet lost. We also have a sniffer made out of an nRF51 evaluation kit and it gets much more packets so it is still preferred to analyse protocols. However we can still enhance the SDR algorithm and the 20MHz bandwidth of the HackRF will allow us to sniff on many channels at once, making it perfect to debug channel hopping when we implement it for the Crazyflie.

 

We were at Maker faire bay area 2015 and that was an awesome experience! Thanks a lot to everyone that came to meet us.

Bitcraze booth

Our demos finally worked quite well. We had a Crazyflie flying autonomously for a total of about 24 hours during the faire and we could play music using a Crazyflie with a Buzzer expansion boards.

We are still in the US with limited Internet access but as soon as we return to the hyper-connected Sweden we will push codes and documentation Online so that you too can get autonomous flight with your Kinect 2.

Recently I got a Chromebook, mostly out of curiosity for this odd “computer that runs only a web browser”. While playing with Google dev tools I quickly saw a possibility to make a Crazyflie client as a Chrome app: the Chrome API provides USB connectivity,and HTML5 has a javascript gamepad API. A chrome app is designed to look and feel like a native application: the app does not require internet connection and is launched in its own window.

This week-end I finally got around to test it, it’s not pretty but it works :-)

crazyflie_chrome_client

The current functionality is:

  • Channel and datarate can be changed
  • Read input from a gamepad, the mapping is fixed to mode 3 and the sensitivity is fixed
  • Sends set-points to Crazyflie 33 times per seconds.

I haven’t had time to do any layout work on it (that is pretty obvious in the screenshoot :) ), but the plan is to use Angular Material to handle the GUI.

This is only a proof of concept but we are seeing a lot of potential: the Chrome app runs on Linux, Mac, Windows and Chromebook, is easy to install and is written in HTML/CSS/Javascript which seems to be a very popular platform nowadays.

I have pushed the code on Github so if anyone is interested in helping to shape up the app head to the forum to read the discussion about it.

 

Last Saturday it was Arduino day 2015 and it happens that the Arduino office in Sweden is in the same building as ours. So we where invited and presented Crazyflie. It was a really fun event with a lot of interesting people passing  by and we had a lot of fun.

Arduino day 2015

There was also Helium balloon, which gave us a perfect occasion to use the blimp hack we did more than a year ago. We attached a brunch of ‘Arduino colored’ balloon to it and flew it around using the Deviation TX. It is definitly something we have to port to Crazyflie 2.o.

blimp_scaled

Finally as the event was hosted by Arduino, and we do not have Arduino compatibility (yet … ; ), we thought we would make something with Arduino and present it. We ended up making a Crazyflie Controller using an Arduino and using a thumb stick and ultrasonic distance sensor that was lying around the office. We attached everything to a glove to make it a ‘wearable’ controller.

arduino_glove

 

 

glove_action glove_closeup

The glove is working as follow: you place your hand over a hard surface (concrete floor or table), click the thumb-stick button to set the zero and from now-on rising the hand higher will increase the Crazyflie thrust. Then the thumb-stick can be used to steer the Crazyflie. The program is quite simple and implemented in a single loop.

Technically the most work has been put in enabling the serial port of the Crazyradio so that the Arduino can send commands to the Crazyflie using the Crazyradio directly without a computer. As there is a lot of pins available on Crazyradio and a voltage regulator capable of accepting up to ~16V, the aim has always been to be able to use it as a radio module for other system. Our first thought was PPM input, but now serial control will also be possible. We are still cleaning up the code and working on other new functionality on the Crazyradio. We plan to release a new firmware soon that will support PPM, UART and a more efficient USB protocol to communicate with many Crazyflies using one radio dongle.

Lately we have merged a new input subsystem to the Crazyflie python client, it allows for more flexible input configuration like connecting more than one gamepad in training mode, or having external input like the LeapMotion appear as standard input. To test the flexibility of the new input system, on Friday, we implemented a ØMQ input driverØMQ is a library that permits to easily transmit messages between program. It is high speed, low latency and extremely easy to use. It has binding and implementation for a lot of programming language, which opens Crazyflie control to a lot more people and application.

The way it currently work is: You connect the graphical Crazyflie client and select ZMQ as input device. You connect the ØMQ socket and send json to it containing pitch/roll/yaw/thrust. And voila, you are controlling Crazyflie from your own program.

We just got a Kinect 2 and started playing around with it, suddenly the new ØMQ control became very useful. We already worked with the kinect long time ago so we had control code from back then. Also we wanted to quickly do a proof of concept so we started working with the Microsoft SDK to see what is possible, we are going to use libfreenect2 on Linux later. Finally we know how hard it was to control the thrust so we wanted a way to test pitch/roll first as a proof of concept. At the end of the day we ended up with this architecture in the office:

zmq_kinekt

The C++ implementation in visual studio detects the Crazyflie and sends coordinate to the Controller python script. The controller script is a stripped down version of or previous kinect experiment and only runs PID control loops to control pitch and roll, trying to keep Crazyflie at a fixed coordinate in space. Finally the Crazyflie client is setup in training mode with ZMQ handling pitch and roll and the gamepad handling thust and yaw. The gamepad can take-over completely in case of problem.

Thanks to ZMQ resiliance we can stop any part of the system and start it again, the connections automagically reappears. So we ended up with the following workflow:

  • Fly in the Kinect detection area
  • hand-over pitch/roll to the controller loop
  • When the Crazyflie starts oscillating or going away, take over control and land
  • Stop controller, modify things, restart

This was quite painless and nice. We ended-up connecting together very different systems and they just worked. We got so interested by the experiment that we now have a full ZMQ Crazyflie server on the work that would allow other program to do what is possible with the standard Crazyflie API: scan for Crazyflie, connect, read and write log and params.