New program to control the crazyflie with your keyboard
Posted: Fri Jan 03, 2014 9:18 pm
Hi list.
Yesterday I wanted to control the crazyflie with my keyboard directly and I did't find anything so I made a python program. it is useful if you just buy it and you still don't have a gamepad, or if you controller is broken or you just forget it at home. If this is your case, don't worry! you can now control your crazyflie with your keyboard and at the same time you have the sensors values on the console. It can be seen as a 'poor man' controller.
It is called keyboard_control.py and you can find it here:
https://bitbucket.org/eldraco2000/crazyflie-programs
The program connects to the first crazyflie that it can find (so you can change the wifi channel without updating your programs) and prints on the console the values of the sensors (roll, pitch, yaw and thrust). Then you can press these letters to control it:
w -> More thrust
s -> Less thrust
d -> Yaw right
a -> Yaw left
i -> More pitch (go ahead)
k -> Less pitch (go back)
l -> Roll to the right
j -> Roll to the left
q -> Stops flying but it does not disconnect from the crazyflie. Just to save the crazyflie when it hits some wall. You can continue flying.
e -> Exit. Stops flying, disconnects from the crazyflie and stops the program.
This resembles the common mode 2 of operation in a gamepad.
Also notice the following functionalities:
- If you keep any of these letters pressed, the corresponding value continues to grow (or decrease), but if you stop pressing it the value goes to 0. For example, the more time you press 'l' to roll right, the more it will roll. But if you stop pressing 'l' the crazyflie stop rolling. It simulates the behavior of going 'back' to the center of the gamepad.
- The thurst does not have this behavior. So if the crazyflie is flying you don't have to press 'w' to keep it on the air. Just take it as high as you want and stop pressing 'w', it will stay there like some cheap 'hovering' mode without using the altimeter.
It takes so time to get used to it and it is perhaps not so easy to fly, but it is possible. I will try to configure the controls better.
I hope you like it and it is useful! In the future I will add:
- Vi mode. Control the crazyflie with vi letters (hjkl) and exit with Esc. Don't know if it is good, but let's try.
- Possibility to trim the control during fly.
see you
sebas
Yesterday I wanted to control the crazyflie with my keyboard directly and I did't find anything so I made a python program. it is useful if you just buy it and you still don't have a gamepad, or if you controller is broken or you just forget it at home. If this is your case, don't worry! you can now control your crazyflie with your keyboard and at the same time you have the sensors values on the console. It can be seen as a 'poor man' controller.
It is called keyboard_control.py and you can find it here:
https://bitbucket.org/eldraco2000/crazyflie-programs
The program connects to the first crazyflie that it can find (so you can change the wifi channel without updating your programs) and prints on the console the values of the sensors (roll, pitch, yaw and thrust). Then you can press these letters to control it:
w -> More thrust
s -> Less thrust
d -> Yaw right
a -> Yaw left
i -> More pitch (go ahead)
k -> Less pitch (go back)
l -> Roll to the right
j -> Roll to the left
q -> Stops flying but it does not disconnect from the crazyflie. Just to save the crazyflie when it hits some wall. You can continue flying.
e -> Exit. Stops flying, disconnects from the crazyflie and stops the program.
This resembles the common mode 2 of operation in a gamepad.
Also notice the following functionalities:
- If you keep any of these letters pressed, the corresponding value continues to grow (or decrease), but if you stop pressing it the value goes to 0. For example, the more time you press 'l' to roll right, the more it will roll. But if you stop pressing 'l' the crazyflie stop rolling. It simulates the behavior of going 'back' to the center of the gamepad.
- The thurst does not have this behavior. So if the crazyflie is flying you don't have to press 'w' to keep it on the air. Just take it as high as you want and stop pressing 'w', it will stay there like some cheap 'hovering' mode without using the altimeter.
It takes so time to get used to it and it is perhaps not so easy to fly, but it is possible. I will try to configure the controls better.
I hope you like it and it is useful! In the future I will add:
- Vi mode. Control the crazyflie with vi letters (hjkl) and exit with Esc. Don't know if it is good, but let's try.
- Possibility to trim the control during fly.
see you
sebas