help for project on Crazyflie 2.0

Discussions about all things Bitcraze
Post Reply
matthieuleonie
Beginner
Posts: 20
Joined: Mon Nov 13, 2017 11:54 am

help for project on Crazyflie 2.0

Post by matthieuleonie » Mon Nov 13, 2017 11:59 am

Hi! We are working on a project on Crazyflie 2.0. We would like to make it land when we want it to. The altitude of the drone would be calculated by an altimeter that we would add to it (ultrasonic sensor) and we want to write a code that would start the landing process when we want it to. In order to do that we need to know how the engines work and how they are controlled. We have read the documents we found on the wiki about experiments on engines for calculating the rpm, however we need to understand the link between thrust and altitude.
Can anyone help us please ?

Thanks a lot 😊



kristoffer
Bitcraze
Posts: 109
Joined: Tue Jun 30, 2015 7:47 am

Re: help for project on Crazyflie 2.0

Post by kristoffer » Mon Nov 13, 2017 2:21 pm

This sounds like an exciting project!

You might want to take a look at the code for the z-ranger deck, even if you want to implement your own altimeter you can maybe get some ideas from how the it is designed.

The z-ranger is measuring the distance to the ground and is keeping the Crazyflie at a constant altitude in altitude hold mode. This is almost what you want to do except that you want to reduce the target height over time. This functionality is using the position controller to indirectly control the motors instead of changing the motor power directly.

There is a related post (viewtopic.php?f=6&t=2675&p=13535&hilit=setpoint#p13535) regarding setpoints and controllers that you might find interesting as well. The overall control loop is outlined there and it should hopefully give you some hints on where to look.

matthieuleonie
Beginner
Posts: 20
Joined: Mon Nov 13, 2017 11:54 am

Re: help for project on Crazyflie 2.0

Post by matthieuleonie » Thu Nov 16, 2017 10:21 am

Hi! Thank you for your help and your answer.

We would like to know where we can find the part of the code which controls the motors. We have seen the code for the Z-Ranger (zranger.c) which reads data from the sensor.
But we would like to know how these data are used by the drone and how the thrust is changed (exactly what is the command that goes into the motors).

Thanks

tobias
Bitcraze
Posts: 1910
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: help for project on Crazyflie 2.0

Post by tobias » Thu Nov 16, 2017 1:38 pm

I suggest have a look in stabilizer.c and power_distribution_stock.c

matthieuleonie
Beginner
Posts: 20
Joined: Mon Nov 13, 2017 11:54 am

Re: help for project on Crazyflie 2.0

Post by matthieuleonie » Tue Dec 12, 2017 5:31 pm

Hi,

As we already told you, we have an ultrasonic sensor which will calculate the current altitude of the drone as it will be the feedback loop. We are wondering how to bring the information from the ultrasonic sensor back to the drone.
Since the drone and the computer communicate through radio, can we send the data from the sensor through radio (the sensor will be plugged in the breakout deck)? What kind of radio signal is sent by the transmitter on the drone?
We have the same question about the z-ranger : where is the information from the optic sensor collected ? How does the z-ranger control the motors? (which part of the code collect the information given by the sensor and then use it to control the motors?)

Thank you for your help :)

tobias
Bitcraze
Posts: 1910
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: help for project on Crazyflie 2.0

Post by tobias » Wed Dec 13, 2017 9:34 pm

That was a lot of questions in a few sentences :D.

Sending information to the PC is quite simple by using the log framework.

The z-ranger only measures the height and feeds this information into the controllers. You could do exactly the same thing with the ultrasonic distance by replacing this line with an equivalent function that is using the ultrasonic sensor.

matthieuleonie
Beginner
Posts: 20
Joined: Mon Nov 13, 2017 11:54 am

Re: help for project on Crazyflie 2.0

Post by matthieuleonie » Sat Dec 16, 2017 11:32 am

Hi,
We are sorry to ask you so many questions but I tried to be as clear as possible ^^'
The z-ranger only measures the height and feeds this information into the controllers.
Where can we find this controller? Because we search it but we didn't find it... Is this controller using the data from the z-ranger and then control the motors adequately?

Thank you for your help :)

tobias
Bitcraze
Posts: 1910
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: help for project on Crazyflie 2.0

Post by tobias » Mon Dec 18, 2017 12:03 pm

Where can we find this controller?
You will find it from the main stabilization loop here.
Is this controller using the data from the z-ranger and then control the motors adequately
Yes so by replacing it with your ultrasonic distance it should pretty much work straight away.

Post Reply