USC-ACTLab / crazyswarm

A Large Quadcopter Swarm
MIT License
326 stars 319 forks source link

Implementation of another stabilizing controller and navigation layer #114

Closed bconvens closed 5 years ago

bconvens commented 6 years ago

Hi,

I would like to discuss how to start with the development of another stabilizing controller and a navigation layer for the crazyflie 2.0 using the crazyswarm code (with vicon system) to start from. Currently I just focus on 1 cf, but it must be later easily expanded to multiple cfs.

The navigation layer (based on potential fields) takes as input the cf pose set-point [r_x,r_y,r_z,r_yaw] send from the ground PC, cf state measurements of the cf centre of mass [x,y,z,roll,pitch,yaw, dotx,doty,dotz,dotroll,dotpitch,dotyaw] from Vicon/onboard sensors, the 4 motor forces [f1,f2,f3,f4], the state of external possibly moving obstacles measured by vicon [x_obs,y_obs,z_obs,roll_obs,pitch_obs,yaw_obs, dotx_obs,doty_obs,dotz_obs,dotroll_obs,dotpitch_obs,dotyaw_obs] (or any other attitude and rate representation). With this information and some defined navigation parameters/gains, it calculates the position set-point for the cf stabilizing controller, i.e. [v_x,v_y,v_z,v_yaw].

The stabilizing controller is a nonlinear cascade inner-outer loop controller. It basically takes as input [v_x,v_y,v_z,v_yaw] (=output of navigation layer), the cf state measurements [x,y,z,roll,pitch,yaw, dotx,doty,dotz,dotroll,dotpitch,dotyaw] (or any other attitude and rate representation) and calculates based on some controller parameters/gains the 4 motor forces [f1,f2,f3,f4]. The rate of the attitude loop is about 10 times faster than the position loop. The rate of the navigation layer is the same as the position control loop.

I found the existing controllers, estimators and commanders/navigators in this folder .../crazyswarm/crazyflie-firmware/src/modules/src, but I am a bit overwhelmed by the number of files. It is not clear to me which are used in the crazyswarm tutorial and which can be ignored. I am basically searching for an estimator/controller/commander example that already satisfies most of my needs and where I can identify the following variables with the names in the code:

Could you please when answering the above questions make references to the relevant parts of the existing code so it is more clear which of the many files are used and how these variables are called in the existing code, and how the information flow proceeds?

After I changed the code, if I want to compile this new firmware, what should I do so that the firmware upload buttons in the chooser.py gui compile this new firmware (using either option 1 or option 2)?

Is there already implemented a way to save the logged data and convert it to matlab plots or to excel?

Thanks!

whoenig commented 6 years ago

You might get better answers related to the firmware development in the official forum.

Navigation layer: We evaluate trajectories on-board in our "high-level-commander". I think it would be possible to add other commanders. A good starting point is here: https://github.com/bitcraze/crazyflie-firmware/blob/master/src/modules/src/crtp_commander_high_level.c#L210.

Controller: We already have a nonlinear controller, which is here: https://github.com/bitcraze/crazyflie-firmware/blob/master/src/modules/src/controller_mellinger.c. It does output PWM values instead of newtons (although some people have tried to rectify that in the past). The actual output PWM values are computed here: https://github.com/bitcraze/crazyflie-firmware/blob/master/src/modules/src/controller_mellinger.c.

State estimate: The state estimate is with respect to the center of mass. You can find it here: https://github.com/bitcraze/crazyflie-firmware/blob/master/src/modules/src/estimator_kalman.c. For the obstacle, we just send the position of the wand, no higher order states.

I suggest that you try read the code and understand the current implementation using the pointers I provided (rather than me telling you exact variable names).

For flashing, just use make flash in the firmware folder. For logging, I suggest using the uSD-card deck, which has a wiki page explaining how to get and plot the data (in Python, but you could import to matlab if you want to).

whoenig commented 5 years ago

Closing. Please open a new issue if there are additional questions.