Problems with Alititude Hold Program

Firmware/software/electronics/mechanics
Post Reply
woshiwtm
Beginner
Posts: 3
Joined: Sat Mar 07, 2015 10:37 am

Problems with Alititude Hold Program

Post 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!
poizone
Member
Posts: 59
Joined: Thu Feb 05, 2015 3:59 am
Location: Ohio, USA

Re: Problems with Alititude Hold Program

Post 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!
One day our flies will drown out the sun in an autonomous Skynet of whirring motors and blinking lights.
woshiwtm
Beginner
Posts: 3
Joined: Sat Mar 07, 2015 10:37 am

Re: Problems with Alititude Hold Program

Post 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.
poizone
Member
Posts: 59
Joined: Thu Feb 05, 2015 3:59 am
Location: Ohio, USA

Re: Problems with Alititude Hold Program

Post 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.
One day our flies will drown out the sun in an autonomous Skynet of whirring motors and blinking lights.
woshiwtm
Beginner
Posts: 3
Joined: Sat Mar 07, 2015 10:37 am

Re: Problems with Alititude Hold Program

Post 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.
poizone
Member
Posts: 59
Joined: Thu Feb 05, 2015 3:59 am
Location: Ohio, USA

Re: Problems with Alititude Hold Program

Post 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.
One day our flies will drown out the sun in an autonomous Skynet of whirring motors and blinking lights.
Post Reply