Tuesday, 15 July 2014

smoothing RC control

I'm not actually flying trunk Marco, I'm still flying a branch based on my initial implementation.  I think nobody else "found" the problem because they actually like how it flies now.  Actually, that is not looking too bad to me Marco.  You're inputting REALLY sharp stick inputs.  You're asking a lot from it.

The idea for the angular rate accel damping, was that copters which are tuned with really aggressive PIDs for good attitude accuracy in winds, were much too sensitive to really minor stick inputs.  Just the jitter on the sticks, which all humans have, was enough to get the motors jerking the copter around.  This is really bad for video work, as I'm sure know.  It's also the cause of the "bounce back" that you get in acro modes.  

So I was trying to fix all that.  The bounce-back in acro mode happens because you moved the stick faster than the copter can possibly accelerate the pitch or roll.  So an error builds up, and after the motion stops, the controller fixes the error.  With the way I had done it, you could tune the acceleration rate to something quite high.  It would still feel crisp, but you wouldn't be capable of asking the copter to do something it couldn't do.

Here's a video of from when I started all this.  In the video, the code is active on the roll axis, but not pitch.  And I didn't learn until recently, that there was a bug which meant it was only *decelerating* at about half the rate it should, so the stops were a bit softer.  Anyway, you can see the copter still responds sharply.  And you can hear the difference in the sound of the motors on the pitch axis.  They are too sharp.  It's very jumpy and hard to control pitch smoothly like that, but it fights winds really well.  The roll axis has the same PID gains, but is much easier to control.


This also helped smooth out Stabilize mode.  If you have a camera ship, you could lower the accel rates to smooth out the motions of the copter.  You could run very high PID's to fight winds aggressively, but it would prevent you from jerking the copter too hard, upsetting the gimbal.  However, using low values, would lead to a lag if you input sharp inputs.  But really, this is up to the user to tune these.  If you want smooth for a really big octo carrying a big camera, you use 360 deg/sec/sec.  If you want sharp, you could use 1080 deg/sec/sec, which is about as much as any multi-copter can do anyway.  Heck, you could set it to 2000 deg/sec/sec if you wanted, which is 3D Helicopter territory.  The algorithm couldn't *make* the copter do what you ask, but it would make it *try*. 

About the same time, Jason came up with a different concept, which I believe was simply a low-pass filter on the RC Input to smooth the pilot's commands.  This can also create a lag.  I don't know what his filter frequencies were.

Then, Leonard combined both ideas into a single implementation, and that is what you are flying.  I don't think it's "crap", but might just need to have it's parameters set to something you like.  Maybe RC Feel of "100", whatever that is, is not high enough for you.  For sure, you should try increasing the acceleration rate to 108000 from 54000.

Back in February, I forwarded some comments to Randy and Leonard from when I reviewed their code.  Among them was:

2) Get_Smoothing_Gain can only be between 2 and 12, based on rc_feel of 0-100.  Smoothing_Gain seems to be expected to be between 1 and 50 in angle_ef_roll_pitch_rate_ef_yaw_smooth().  Not a big deal as it's dimensionless, but just sayin.

Leonard responded that he thought 12 would be enough, and even that 8 would be as much as most people would want.  I can't really comment, as I haven't flown it, and the numbers are dimensionless.

In addition to changing the accel rate to 108000 (1080 deg/sec/sec), you might also try increasing RC_Feel.  It looks to me like you might be able to push it as high as 480, before the constrain in angle_ef_roll_pitch_rate_ef_yaw_smoth() will limit it.  RC_Feel of 480 will give you the Get_Smooth_Gain of 50, there's a constrain on that above 50.

But I caution, I have no idea how the rest of that function works, I can't follow it.  Something else might break down and fail if you go that high, so proceed with caution.

If you wanted to try my original implementation which has a accel limiting, but no filtering, I sent you that info way back in February, but I never heard anything back from anybody.

Rob