vertical control

Firmware/software/electronics/mechanics
Post Reply
nagaban2
Beginner
Posts: 5
Joined: Fri Nov 07, 2014 4:21 pm

vertical control

Post by nagaban2 »

I'm working with crazyflies in a motion capture area, and I've implemented both
-PID control to travel to waypoints, as well as
-trajectory tracking to travel in certain paths.

However, I'm having trouble getting the vertical stability. Currently, my trajectory tracking deals with x/y (pitch/roll) commands, and the z (thrust) commands are done using PID control to stay at a certain height. I have tried tuning my parameters a lot, but I cannot get rid of small oscillations (I'd like it to be very smooth). I'm wondering if anyone has an idea (instead of PID control) for the height control, or suggestions for improving the PID control. I think I cannot fine-tune it due to delays. For example, the delay in between my controller sending the command and the crazyflie actually executing that command, etc... I'm also unsure of the rate at which the crazyflie actually executes its commands?

Thanks in advance for any thoughts!
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: vertical control

Post by whoenig »

How bad are your oscillations?
What motion capture system are you using (update rate)?

I use a PID controller for height stabilization myself and it seems to work pretty well. However, I did not measure the oscillations yet. From just looking at it I would assume it is within a few centimeters. I use a Vicon motion capture system with 100Hz update rate.

The update rate shouldn't be a (big) issue. The latency between crazyflie and PC is around 3ms. I believe the outer loop on the flie runs at 250Hz. So you could send an updated thrust value every 10ms (MoCap is not faster anyways) and it would be executed before you get the next MoCap reading.

How are you running the software? Make sure that you don't run it in a VM - that adds a fair amount (up to 10ms) additional latency. I use ROS directly installed on a machine with Ubuntu Linux with the package here: http://wiki.ros.org/crazyflie. If you use an older PC, it might be interesting to use one of the available C++ drivers instead of the official python version.
nagaban2
Beginner
Posts: 5
Joined: Fri Nov 07, 2014 4:21 pm

Re: vertical control

Post by nagaban2 »

My oscillations seem to be around 4 cm, which isn't a big number, but it's not smooth flight at all. (attached plot of the vertical position over time, with the desired position being at .4)

I use an OptiTrack system with 120 Hz update rate, and I am also using ROS directly installed on a machine with Ubuntu Linux with the crazyflie packages.
My nodes are written in python, and they just output a twist velocity command (this controller loop is running at 100Hz), which is what is expected.

In this video, for example, the crazyflie exhibits smooth position control with no oscillations
https://www.youtube.com/watch?v=QjxF9zUlIx0

Image
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: vertical control

Post by whoenig »

My oscillations have a smaller amplitude and lower frequency (see below).
My ROS node is written in Python as well, running at 100Hz update rate.

It is not typical that you don't oscillate around the target value. It looks like your thrust is not high enough. What are your gains? I had to use a pretty high I-gain in order to compensate for the battery discharge over time.
I use Kp=15000 Kd=3000.0 Ki=1500.0. Additionally, during take-off I initialize the I-gain with the current thrust value.

I plan to post my code as part of the crazyflie ROS stack once it is ready, however I am not there yet. Send me a PM if you need the current code.
figure_1.png
nagaban2
Beginner
Posts: 5
Joined: Fri Nov 07, 2014 4:21 pm

Re: vertical control

Post by nagaban2 »

My gains are very different than yours, but that is because I have 2 different nodes that handle the command-- the first one limits the thrust between some minimum (currently .7) and max (1), and the second one turns that into a number between 10,000 and 60,000 for the thrust command

I would love to take a look at your current code, so I can compare our methods of PID control and see if there's anything else going on aside from gains (as well as the gains too, actually).
I'm unable to send you a PM for some reason, but hopefully you can PM me with the code

Thanks!
formica
Beginner
Posts: 11
Joined: Tue Apr 28, 2015 2:30 pm

Re: vertical control

Post by formica »

I'm trying to use the whoenig code on github (with an optitrack mocap at 200fps) and can't control properly the copter.
The PID parameters are 4000, 3000, 2000.

Any idea?
Post Reply