Page 1 of 1

Problems with Alititude Hold Program

Posted: Sun Mar 08, 2015 5:52 am
by woshiwtm
Hi all,

I'm doing a project using crazyflie 1.0 nano quadcopter(10DOF). However, I have met some problems recently that I couldn't figure out myself, so I'm wondering if you could give me some technical help about this.

What I am doing is to realize a function in Python that the crazyflie could enter the altitude hold mode by pressing and holding a button on the gamepad, and then it can land automatically. I'm using crazyflie-firmware-2015.1, this firmware can let the crazyflie realize altitude hold through cfclient currently.

My problems are as follows:

1. There is a function in crazyflie-firmware-2015.1/modules/src/stabilizer.c

// Get altitude hold commands from pilot
commanderGetAltHold(&altHold, &setAltHold, &altHoldChange);


This program gets the information on the gamepad, but how can I change it to altHoldChange to realize auto landing? Can I reduce it gradually? What is the range of this variable?

2. I know there is a function which could enable Altitude Hold Mode in Python:

crazyflie.param.set_value("flightmode.althold", "True")

However, This seemed doesn't work when I tested it. So I wonder if it should be put in a loop to execute, if so, what value should the frequency be?

3. If we really modify the stabilizer.c to realize the auto landing, then could it work by only using crazyflie.param.set_value("flightmode.althold", "True") in Python? Do we need other program instructions?

Thanks!

Re: Problems with Alititude Hold Program

Posted: Mon Mar 09, 2015 7:32 pm
by poizone
Altitude hold uses the barometer currently. Autoland would use a linear decrease in the barometer altitude setpoint until decreasing thrust is forced to 0 without altitude changing. Happy coding!

Re: Problems with Alititude Hold Program

Posted: Mon Mar 09, 2015 11:30 pm
by woshiwtm
Thanks poizone,

But I'm really a beginner of crazyflie, so could you please tell me where can I decrease the barometer altitude linearly, and do you know how to realize altitude hold mode in Python? crazyflie.param.set_value("flightmode.althold", "True") seems not work.

Re: Problems with Alititude Hold Program

Posted: Tue Mar 10, 2015 3:47 am
by poizone
You're going to need to delve into the code and roll your own solution for what you want. You have to continually send the hold command because it has a failsafe against radio loss from what I've seen. A simple loop that calls the altitude hold function should work for you.

Re: Problems with Alititude Hold Program

Posted: Thu Mar 12, 2015 9:50 am
by woshiwtm
poizone,

I have set a while loop to continually send the hold command, the quadcopter would stay working, but the thrust of it seems really low so that it even cannot fly. Do you have any idea how that happen? Thanks.

Re: Problems with Alititude Hold Program

Posted: Mon Mar 16, 2015 6:13 am
by poizone
This thread seems to have an answer. http://forum.bitcraze.se/viewtopic.php?f=6&t=883

When working in the altitude hold mode, the altitude is defined by thrust with the setpoint being (0, 0, 0, 32767). Send that command to start, and slowly decrease the setpoint to (0, 0, 0, 0). I'm talking aim for a couple minutes to start, so you can try to assure it doesn't just drop out of the air the first few times.

I can't test any of this myself, but the knowledge is definitely out there or in the code.