How to create a new controller for the crazyflie?
How to create a new controller for the crazyflie?
Recently, I'm wondering to control crazyflie by leapmotion controller
I have found that someone has done it , and the best way to control crazyflie is creating a new controller in the client.
So, do you have any suggestion or experience for how to create a new controller for crazyflie?
BTW, could you tell me the exact file of controllers?I don't find the wondering file...
Thank you a lot!
Yixiong Xu
I have found that someone has done it , and the best way to control crazyflie is creating a new controller in the client.
So, do you have any suggestion or experience for how to create a new controller for crazyflie?
BTW, could you tell me the exact file of controllers?I don't find the wondering file...
Thank you a lot!
Yixiong Xu
Re: How to create a new controller for the crazyflie?
You can find the leapmotion controller as part of the official source tree, just in another branch: https://github.com/bitcraze/crazyflie-c ... leapmotion
To figure out how they did it, you can compare the branch to the master branch: https://github.com/bitcraze/crazyflie-c ... leapmotion
To figure out how they did it, you can compare the branch to the master branch: https://github.com/bitcraze/crazyflie-c ... leapmotion
Re: How to create a new controller for the crazyflie?
Thank you!whoenig wrote:You can find the leapmotion controller as part of the official source tree, just in another branch: https://github.com/bitcraze/crazyflie-c ... leapmotion
To figure out how they did it, you can compare the branch to the master branch: https://github.com/bitcraze/crazyflie-c ... leapmotion
I still have a question:
What is the purpose of using pygame?
In my opinion, I think the pygame is used to send the cotrol messages to the crazyflie. Am I right?
Re: How to create a new controller for the crazyflie?
The control messages are send using pyusb. Pygame is used for the joystick support (at least on Windows and Mac; Linux seems to have a custom implementation) and I believe the widget which shows you the current orientation of the crazyflie is done using pygame as well.
Re: How to create a new controller for the crazyflie?
Thank you a lot.whoenig wrote:The control messages are send using pyusb. Pygame is used for the joystick support (at least on Windows and Mac; Linux seems to have a custom implementation) and I believe the widget which shows you the current orientation of the crazyflie is done using pygame as well.
The pygame is used to support leapmotion for data reading, am I right?
Re: How to create a new controller for the crazyflie?
It uses the official Leap Motion SDK to read the data from leap motion (see http://wiki.bitcraze.se/projects:crazyf ... leapmotion). I didn't look into Bitcraze code into much detail, but it would surprise me if pygame is required just for accessing the leap motion controller.
Re: How to create a new controller for the crazyflie?
I run the dev-leapmotion clients and it is really hard to control the crazyflie.whoenig wrote:It uses the official Leap Motion SDK to read the data from leap motion (see http://wiki.bitcraze.se/projects:crazyf ... leapmotion). I didn't look into Bitcraze code into much detail, but it would surprise me if pygame is required just for accessing the leap motion controller.
Also,I have a question.
Code: Select all
# Pich and roll are mixed up...
roll = -direction.pitch * Leap.RAD_TO_DEG / 30.0
pitch = -normal.roll * Leap.RAD_TO_DEG / 30.0
yaw = direction.yaw * Leap.RAD_TO_DEG / 30.0
thrust = (hand.palm_position[1] - 80)/150.0
When I remove the 30,the angle would be incredible large...
Re: How to create a new controller for the crazyflie?
I guess that is an arbitrary choice. The leap motion SDK gives you back angles in degrees. The crazyflie itself takes numbers from -30 to 30 for roll/pitch, which somehow map to the angle (not sure how exactly - would need to look in the firmware code). The yaw is the angular rate between -200 and 200. Hence, I would expect that those values were empirically determined.
Re: How to create a new controller for the crazyflie?
Yeah,I think you are right.whoenig wrote:I guess that is an arbitrary choice. The leap motion SDK gives you back angles in degrees. The crazyflie itself takes numbers from -30 to 30 for roll/pitch, which somehow map to the angle (not sure how exactly - would need to look in the firmware code). The yaw is the angular rate between -200 and 200. Hence, I would expect that those values were empirically determined.
In ADVANCED Flight mode,
The Max angle/rate and Max Yaw angle/rate default numbers are 30 and 200
In the input.py, the raw pitch and raw angles are multiplied by Max angle/rate;the yaw angles are multiplied by Max Yaw angle/rate.
The purpose of divided by 30 may be use the leapmotion raw data as the input data.
I set the Max angle/rate and Max Yaw angle/rate as 1,and use the raw data from leapmotion without any operation.
It seems work!~
Thanks a lot!