Autonomous CrazyFlie Hover

Discussions and questions about the Crazyflie Nano Quadcopter
Post Reply
dronefacination
Beginner
Posts: 1
Joined: Tue Mar 01, 2016 3:12 am

Autonomous CrazyFlie Hover

Post by dronefacination »

I recently (feb 2016) purchased crazyflie. I have seen many posts on hovering but no clear solution or code that shows its solved. I am sure I am missing something as I have seen some hovering on youtube by folks.

What am i looking to do: I have a raspberry pi controlling the drone through crazyradio. I run version of the ramp.py script to have the drone take off but am not able to keep the crazyflie to hover. There are following things i have come across
a) self._cf.commander.send_setpoint()
b) cf.param.set_value("flightmode.althold", "True")
c) also the concept of PID

But not sure how to put them together to do the following
a) read the current thrust (height) of crazyflie along with the yaw, pitch and roll values
b) subtract or add to the thrust I want it to be so that crazyflie can hover

Assuming this is already solved, can someone point me to the solution?

Thanks.
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: Autonomous CrazyFlie Hover

Post by chad »

Congratulations on your Crazyflie 2 purchase. Insofar as hovering is concerned, how to do it depends on what you want. Hovering is a little more complicated than simply setting a specific thrust and maintaining it. Minor fluctuations in ambient temperature, air pressure, and air currents as well as variability in the platform itself - propeller balance, motor balance, battery position, etc... can cause changes in altitude and attitude which then require correction. In addition to this, even with all the sensors the Crazyflie 2 has, it doesn't have a GPS so it doesn't "know" where in space it is. Also, altitude is monitored by a barometer which is not incredibly precise and can be fooled by things like direct sunlight and fluctuating air pressure. The point here being that precise altitude and attitude hold is not really possible without the aid of an external system to allow for more inputs and autonomous flight.

All that said, you can achieve a rough "hover" using the altitude hold functionality but it will not account for attitude, thus your Crazyflie 2 will move about the room a bit in a front-back, side-to-side manner which you will have to correct for. Also, altitude will be variable with a few feet simply because of the precision of the barometer. You can try the altitude hold feature with a controller first to get an idea of how it works. If it suits your purpose, you can implement in code with item 'b' you listed in your post. Of course, you will need to reach the desire altitude first before you turn the hold feature on. Also, have a look at the altitude hold page on the wiki if you haven't seen it yet.

If it turns out that you need more control for your particular application, you might want to look into the autonomous systems that are becoming more accessible. The local positioning system (LPS) from Bitcraze is in its alpha stage, and others have used depth-sensing cameras like Xbox Kinect and even an iMac camera for more autonomous control. What you use will depend on your needs.

Have fun and let the community know how you solved your needs!

BTW: I moved this thread to the Crazyflie->General sub-forum for better visibility.
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
Post Reply