Problems modeling Crazyflie controller in Matlab

Firmware/software/electronics/mechanics
Post Reply
jmj6160
Beginner
Posts: 2
Joined: Fri Jan 26, 2018 4:26 pm

Problems modeling Crazyflie controller in Matlab

Post by jmj6160 »

Hi,

I am working on a school project and I am having difficulty creating a simulation for controlling a crazyflie in Matlab. I have been looking over the firmware but I am having trouble understanding it. I am pretty sure that the correct body frame orientation is X: forward, Y: left, Z: up. When I look at power_distribution_stock.c (https://github.com/bitcraze/crazyflie-f ... on_stock.c), based off lines 76-91, it looks like the body frame is instead X: forward, Y: right, Z:down. I'm assuming this is because of signs changes in other places of the firmware.

I believe my biggest issue is trying to accurately modeling the attitude/rate controllers used in the firmware. I am using the PID values stated in the firmware, but when I try to track an x or y position, the system becomes unstable. On the other hand I can track a desired altitude and yaw.

Any help would be appreciated,
Thanks!
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Problems modeling Crazyflie controller in Matlab

Post by arnaud »

Hi,

The Crazyflie roll/pitch/yaw commands are setup the same way as it is defined on a plane (https://en.wikipedia.org/wiki/Aircraft_principal_axes). So you observation is right, the output of the velocity loop is setup to follow this orientation.

What mechanical model are you using to simulate the Crazyflie?
jmj6160
Beginner
Posts: 2
Joined: Fri Jan 26, 2018 4:26 pm

Re: Problems modeling Crazyflie controller in Matlab

Post by jmj6160 »

I am using Newton-Euler model to calculate the dynamics with X pointing forward and Z up. Just to clarify, the correct body frame orientation is the NED frame shown in the link you posted?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Problems modeling Crazyflie controller in Matlab

Post by arnaud »

roll/pitch/yaw angles are defined as in the wikipedia link I sent. The translation frame has X pointing forward and Z pointing up https://www.bitcraze.io/getting-started ... tion-hold/
Post Reply