Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running the neural networks on Crazyflies #48

Open
sAz-G opened this issue Dec 14, 2023 · 3 comments
Open

Running the neural networks on Crazyflies #48

sAz-G opened this issue Dec 14, 2023 · 3 comments

Comments

@sAz-G
Copy link

sAz-G commented Dec 14, 2023

I trained a small (deepsets) neural network as suggested in this paper, and implemented the c code for calculating the output for a given input. The code should run on a Crazyflie.

I first try a simple scenario with a single drone, where I hard-code the values of the neighbor observations. The velocity of each neighbor is 0 and the neighbors are on the ground, where only the y-position varies with 1.5m jumps. In other words Vk = (0,0,0), P1 = (9.5, 0, 0), P2 = (9.5, 1.5, 0), P3 = (9.5, 3, 0)... P6 = (9.5, 7.5, 0), for k=6 neighbors. The target position of the drone is Pt = (x=0,y=0,z=1). The drone reacts to the output of the neural netwrork however it fails to fly.

When I plot the output values using the cfclient, I can see that the output of the network changes when I change the self observation values (for example if I change the yaw angle or if I change the angular velocity by moving the drone manually).

On top of debugging the code I would like to make sure that I use the output and input of the neural network properly.

Do I have to normalize the input before feeding it to the network?

What is the representation of the rotation matrix? I am currently getting the roll pitch and yaw angles from the state at the stabilizer and from these angles I calculate the rotation matrix according to the General 3D rotations equation. Where alpha is yaw, beta is pitch and gamma is the roll angle. Then I insert the entries of the rotation matrix row by row.

In which order do I have to enter the angular velocity? Currently I use this order: wx,wy,wz.

I tried to figure out the answer to each of these questions in this page.

I modified the power distribution function such that I set

motorThrustUncapped->motors.m1 = f1;
motorThrustUncapped->motors.m2 = f2;
motorThrustUncapped->motors.m3 = f3;
motorThrustUncapped->motors.m4 = f4;

fk = 0.5*(clip(ak, -1, 1) + 1), where ak is the kth output of the network.

@sAz-G
Copy link
Author

sAz-G commented Dec 19, 2023

I could find the answer for the input space here (I guess). I am still not sure where in the crazyflie firmware to insert the network output

@AI4IS
Copy link

AI4IS commented May 13, 2024

Hi, I also have this confusion. Do you work it out? I have trained a control model. However, I have no ideas on how to run this model on a real hardware. Are there any ways to help me overcome this problem? Thanks!

@sAz-G
Copy link
Author

sAz-G commented Nov 26, 2024

yes, I got something running but it was not 100% stable. I could let the drone hover and fly to a given set-point. However, often the drone would fly a jerky trajectory or would sometimes crash.

Did you get something working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants