We have always been interested in controlling Crazyflie with various devices. For example we had the Leap Motion that enabled us to control the Crazyflie with our bare hand. Then we hacked a glove for Arduino day. At Maker faire Berlin 2016 we met the team from Specktr. Specktr is a midi glove and since our demo was controlled with midi we had to try connecting the Specktr with Crazyfile 2.0 flying using Loco Positioning System!
We met in the evening, after the faire was closed, and started hacking to map the midi messages transmitted by the glove to our midi to position ROS node. After a couple of mandatory crashes and crazy behavior (like setting the flight area way too big and sending the Crazyflie high speed away at the snap of a finger, too bad we have no video of that …) we had things working well and the glove could control the Crazyflie X position:
The second and last day of the faire we did a more proper connection where both X and Y could be controlled. The result is quite nice. It looks near magic, and quite fun, to control Crazyflie just by just moving the hand:
Speccktr is currently running a crowd funding campaign and we cannot wait to get ours to be able to hack more with it together with Crazyflie and Loco Positioning System.
One week ago we where presenting Crazyflie 2.0 and the Loco Positioning System at Maker Faire Berlin 2016. It was a lot of fun being there, we enjoyed it very much, and it also required a couple of weeks of preparation. The preparation was both mechanical and markerting: out booth was built with and outdoor tent frame and we featured the first roll-ups of Bitcraze history (almost felt a bit too ‘corporate’ for us :-).
On the technical side it was an opportunity to test Crazyflie and the Loco Positioning System in real event situation. This required stabilizing the system and testing it so that no bad surprises would happen during the faire. The result is pretty good: we flew more than 91% of the opening time, we had 2 fly-away the first day, fixed the problem and had none the second day. We were flying with 2 Crazyflie sequentially and had not broken any motor mount or other part during opening hours (some crazyness did happen after-hours though, maybe more on that on a later post ;-).
For our demo the Crazyflie was flying autonomously with the loco positioning system using the Kalman filter to fly towards a given x/y/z set-point. We made a midi-to-crazyflie bridge in ROS that allowed to give control of the Crazyflie position via a midi cable. We actually used a physical midi cable which was the safest and simplest. On the other side of the midi cable was a computer running a midi sequencer, lmms. Part of the sequence was playing actual music to make the Crazyflie dance and part was just silent movement. The setup looked like that:
Midi can encode notes pitch (ie. where in the piano you play) and velocity (ie. how hard you press the piano key). The midi track contained 4 tracks: X, Y, Z and LED-ring. In X, Y, Z tracks the note pitch converted into a position and we don’t use the velocity. The led ring track maps the note pitch to a color and the velocity to a brightness. It looks like that:
This setup was a bit of a test, we found it to be very reliable. Some functionality were implemented on-site after Friday morning experience: automatic landing when the battery was low and reconnect on take-off to allow taking off without restarting anything in the PC just at a press of a button. The midi link worked well even though it feels a bit hackish to setup a choreography like that. If you have any better idea what to use to make a Crazyflie dance please tell us!
Last but not the least we have share all the codes, files and documentation for this demo on github so that you can run it yourself with an loco positioning system. We also made a short video showing the demo in action:
We are just back from the Maker Faire Berlin where we have met lot of interesting people and shown the loco positioning system. We have calculated that Crazyflie 2.0 has flown for more than 91% of the faire thanks to the autonomous flight with Loco Positioning System.
Our neighbor at the Maker Faire was Gerhard Fließ from Deskbreeze and he was presenting a mini desktop wind-tunnel:
This was a great opportunity for us to test the Crazyflie in a wind-tunel. The result is really impressive slow motion videos:
The wind-tunnel is mainly designed for education. The wind goes at 1 m/s which is apparently too slow for aerodynamic study but nevertheless we can see some interesting effects. Then the propeller pulls the air, we can see the lines getting tighter just before the propeller, this is a sign of higher speed flow and lower pressure. The difference of pressure between the bottom and the top of the propeller is what makes the Crazyflie fly. When the Crazyflie pushes the airflow, simulating a descent, we can see an oscillation of the air flow. This is most likely what can cause instability when descending fast.
We will post more about the Maker Faire Berlin and our autonomous flight demo in the following weeks so stay tuned. Thanks to all we have met, it is awesome to meet and talk about the Crazyflie in person. A mostly great thanks to Fredg (derf on the forum ;), that was there to help us during the whole week end.
The last couple of weeks has been really busy getting ready for the Maker Faire Berlin. The plan is to show multiple Crazyflies flying autonomously enabled by the Loco positioning system. To spice up the experience of autonomous flight and to inspire the visitors to imagine future applications we have made a small light and sound show where the Crazyflie is dancing to a soundtrack Kristoffer made.
Here is a teaser where we are maybe stretching the limits a bit too far ;-):
Taking the opportunity to exhibit what we do at events like the Maker Faire Berlin is really exciting and we are looking forward to hanging out with cool people and getting feedback about what we do.
So come and visit us at Maker Faire Berlin is Sept 30 to Oct 2 at Station Berlin. You will find us in hall 3, stand 149.
Until now, the Loco Positioning System have been limited to flying only one Crazyflie autonomously. In this post we will try to explain the reason of this limitation and what are the way forward.
The loco positioning system is based on Ultra Wide Band (UWB) radios that can very precisely measure the time of departure and arrival of a radio packet. This allows us to do two things:
Use these times directly to calculate the flight time of the radio packet. This is called time of arrival (ToA) measurement, it can be done by simply pinging one anchor. No extra synchronization is required.
Use the difference between the arrival of packets from two different anchors. This is called time difference of arrival (TDoA), it requires the system of anchors to be synchronized together.
The method 1) is simpler to implement since it does not require the anchor system to be synchronized, though it requires bidirectional communication between the tag (eg. Crazyflie) we want to locate and the anchors. It means that if you want to locate more than one tag you have to somehow share the air by not ranging all at the same time. The method 2) requires extra work to synchronize the system of anchor and is theoretically more sensitive to measurement noise. However TDoA measurements have a huge advantage: they can be made to work with unidirectional signal sent from the anchors. This means that the tag only has to listen to the air to receive all information needed to locate itself. This allows to scale the location system to as many tag as we want since adding a tag do not have to share the air, they are not transmitting anything.
So far we have been concentrating on ToA measurement since it could easily be implemented and gives us the best theoretical ranging performance. This allows to develop the algorithms to calculate position estimates and stabilize the autonomous flight. The problem is that, since we are just ranging as fast as possible with all the anchors of the system, one Crazyflie will take all the available air-time and we cannot fly another Crazyflie at the same time. We have just implemented a solution to fly more than one Crazyflie with ToA measurement using time-slots, this is called TDMA for Time Division Multiple Access, and it can be done without anchor code modification. We are working on the Maker Faire demo using this method and it is starting to work quite well:
For TDMA we define frame and time slot. One time slot is a space in time where one tag will be allowed to communicate without risking collision with others. One frame is a group of timeslot. Each Crazyflie is configured to use one time slot in each frame.
TDMA frame structure. Image from the Wikipedia TDMA article.
Normally implementing TDMA would require some kind of synchronization to make sure each Crazyflie knows when its time slot starts. With the LPS we are in luck though since transmitting time is part of the way the ranging is working: we do not have to implement new messages or even to modify the anchors to implement TDMA.
We chose the timer in anchor 1 as our master clock for TDMA. When a Crazyflie starts it ranges with anchor 1 which allows to get the current time in anchor 1, then the start of the next frame can be calculated and the Crazyflie can schedule to range in its next time slot. We range with one anchor per time slot and each time we range with anchor 1 we get a chance to re-synchronize.
The TDMA has been pushed to the Crazyflie master branch. It is documented in the commit message so please feel free to test it, report, and pull-request ;-). We have tested running in 2 slots mode with success. Very quickly though, when adding more time slots, the performance deteriorates because the rate of ranging per Crazyflie decreases. Then TDoA will lead to better performance which is the next target, after the Maker Faire Berlin :-).
It’s been over six months since our last Crazyflie 1.0/2.0 firmware release and it was about time to do a new one. We have always had the idea to release often but can’t really say we have succeed. Something we are trying to improve but it has turned out to be really hard. Since it has been quite some time since the last release a lot of things have happens. To summarize the bigger ones:
There is now a Kalman filter option to use with the Loco Positioning system and hopefully later with other systems such as GPS and camera based systems (thanks to @mikehamer)
Improved altitude hold
Rewrites of low level code to improve stability
Architecture updated to support on-board position awareness
New streamlined I2C driver
Driver for Loco Positioning deck
CMSIS-DSP added to the firmware project
Improved PID tuning for the Crazyflie 2.0 (thanks to @theseankelly)
More reliable radio communication link
Please go to this page for instructions about how to upgrade to release 2016.09
ST Microelectronics have become quite known for their complex and somewhat buggy I2C peripheral, especially for their STM32F103 device (see errata). Where for instance the I2C interrupt priority needs to be the highest in the system, otherwise some I2C events might be lost which could cause random behavior. Since we use the STM32F103 for the Crazyflie 1.0 we have been using ST provided drivers as a solution for not having to take care of these cases. On the Crazyflie 2.0 we’re using the STM32F405 which doesn’t have the same I2C implementation and where ST has moved over to using the CPAL library for I2C drivers. This driver has turned out to be “bulky” and cause compatibility problems with our FreeRTOS due to handling of CPAL timeouts. Therefore we recently decided to see if we could write our own driver for the STM32F405 instead. How hard can it be..? Well after two weeks of pulling my hair and swearing it turned out to be a bit harder than we first thought. But now we hopefully have a slick and optimized I2C driver that works great for our purpose. Instead of polling it uses interrupts for I2C writing and DMA for I2C reading to keep MCU intervention low, leaving more processing power to Kalman filters etc :-).
Like I said, there was a few more obstacles along the way than we initially thought. So here are are some pointers I collected on the way:
I quickly dropped the interrupt event handling the ST-LIB suggest, I2C_GetLastEvent(…), because during the address event status register 2 (SR2) needs to be cleared (by reading it) after DMA has been setup (as noted in the datasheet when reading the fine print…). The I2C_GetLastEvent reads SR1 and SR2 at once which thus doesn’t work out.
This took most time to find, but using my I2C analyser I found that the I2C connection suddenly stopped after a small period of time with a START then STOP event of 3.9us. Doing a lot of trial and error a eventually found that the only way to trigger such a quick start-stop condition was if both the start and stop flag in the control register where set at once. I therefore tried manipulating the CR1 register only with a write operation and not a read-modify-write which solved the problem. This requires that you know what the whole content of the register needs to be when setting it. Luckily such is the case. A very strange behaviour but now it’s working, let’s leve it at that :-)
And finally don’t always trust the tools. I found that using my TotalPhase Beagle I2C analyzer I sometimes got corrupt transactions. I tried a lot of things in my I2C driver but I didn’t get why. I posted a topic in the ST forum to get some desperately needed help but then one of my colleges suggested that I should try a different analyser. Well there was no problems with the I2C bus according to that analyser. Turned out that the problem was that I was using the Totalphase Data Center software in a virtual machine. I couldn’t get it to run natively on Ubuntu, which must have been causing slow USB communication or something that the Data Center software doesn’t handle correctly.
What’s better than a single Crazyflie? A swarm of them! Over a year ago our research group at the University of Southern California posted a blog post with the title “Towards CrazySwarms“, explaining how to fly six Crazyflies at the same time. Since then, we’ve expanded our fleet to 49 Crazyflies. It turns out that flying 49 requires a completely different approach. We will outline the additional challenges, and of course show a fun video!
Why is flying many Crazyflies hard? It comes down to two different categories:
Communication Limitations: The standard Crazyflie software does not support controlling more than one crazyflie per radio. Putting 49 radios on a PC is possible, but would cause very high latencies because the Universal Serial Bus (USB) operates, as the name suggests, serially in 1 ms intervals. Earlier, we showed that we can share a radio for two Crazyflies by using different addresses, but 25 radios are still too much to be handled on one PC reasonably. We can overcome this issue by reducing the amount of data to be transferred. However, this forces us to increase the autonomy of the Crazyflie. Instead of sending attitude control input for each Crazyflie at a high rate, we move the controller on-board and send high-level trajectory descriptions and external position information at a low-rate. In particular, we need to:
Move the position controller on-board, and
Be able to handle packet losses more gracefully.
i) is relatively easy, apart from the testing and tuning. For ii) we use an Extended Kalman Filter to estimate the state on-board. This state, consisting of the position, angle, and the translational velocities, is estimated by combining the on-board sensors (gyroscope, accelerometer) with external position information. Even if we are not able to send the external position for a while due to packet drops, the on-board sensors will keep the estimated state correct for a while.
Finally, we implemented broadcasts (rather than 1-to-1 communication between PC and each Crazyflie) and used a number of compression tricks in order to limit the required bandwidth further. We are able to broadcast the pose (position and rotation) for all 49 Crazyflies using just three Crazyradios 100 times per second. Each Crazyflie can handle several packet drops in a row before the state estimate becomes too unreliable to fly.
External Position Feedback: The on-board sensors of the Crazyflie are not sufficient to determine its position, so we need some external position feedback. In academia, optical motion capture systems are frequently used. They consist of a number of specialized, synchronized, high-speed infrared cameras. Each object to track is equipped with at least three retroreflective spheres (so-called markers), which reflect infrared light sent out by the IR light sources next to the cameras. If we know the pose of all cameras, we can use triangulation to determine the 3D positions of all retroreflective markers.Traditionally, motion capture systems require that each object has a unique arrangement of markers; this allows to determine each object’s position from a single frame of marker data by searching for its unique pattern. Unfortunately, the Crazyflie is too small to have 49 unique marker arrangements that can be reliably distinguished. To solve that issue, we put the Crazyflies at known positions initially and use their marker arrangement to track their position and pose over time, at 100 Hz. This allows us to use the same marker arrangement for each Crazyflie.
Putting that together (combined with an improved controller), allows us to create nice formations:
So what is next? Eventually, we will integrate our changes into the various projects (including the firmwares and the ROS driver), allowing everyone to work on and with CrazySwarms.
Summertime is a good time to get outside and play :-). For a long time we have been having an assembled Turnigy tylon frame here at the office just lying around and it was time to put a camera on it and test its wings. It is not really a frame built to host a camera, and the least to put a gimbal on it but the size supports it so why not. So that is what I did, which included plenty of tape, zip-ties, drilling etc. Wouldn’t really recommend this frame and maybe that is why they quickly made a new version. I had a really hard time fitting the motors to the mounts which required getting some motor mount adapters and drilling into the aluminium mount to make them fit. To make the gimbal fit I made some wood extensions of the legs, as that was what I could find lying around. Anyway the result wasn’t that bad so I decided to give it a go. The first flight is always a bit nervous and especially with bigger quads so I took a lot of precautions and triple checked important things. The flight went well without any crash and I just used the stock PID settings when building the firmware. I flew it with the python client and a PS3 gamepad as I normally fly the CF2 and a was watching the signal strength carefully when getting far away. It will not survive a drop from 50m as the CF2 might. The basic functionality of the BiqQuad deck works well but I must admit that there are plenty more to implement before it has a rich feature set.