Indoor position controller tuning

Hi, I’m using a motion capture system and mavros to send position to arducopter as discussed here Indoor flight with external navigation data.

I’m trying to have copter motion as smooth as possible, like @chobitsfan in his cool video.

I have already tried to tune EKF2 and PSC parameters and surely I’ll continue to, but I wanted to share my results, maybe someone has the same problems or knows how to deal with them…

Here’s a simple graph of a loiter with position and target position on x axis (NKF1.PN and PSC.TPX) and yaw (NKF1.Yaw)


I can see two problems:

  • in the first half there are oscillations due to overshoot, is it related to the PID I term?
  • in the second half I see a strange behaviour, when the copter is turned on the yaw axis it flies in the opposite direction and then comes back in position, can this be related to some kind of sensor offset?

Here’s my PSC params:
PSC_ACC_XY_FILT,2
PSC_POSZ_P,1
PSC_VELZ_P,5
PSC_ACCZ_P,0.5
PSC_ACCZ_I,1
PSC_ACCZ_D,0
PSC_ACCZ_IMAX,800
PSC_ACCZ_FILT,20
PSC_ACCZ_FF,0
PSC_POSXY_P,1
PSC_VELXY_P,2
PSC_VELXY_I,0.1
PSC_VELXY_IMAX,1000
PSC_VELXY_FILT,5
PSC_VELXY_D,0.01
PSC_VELXY_D_FILT,5
PSC_ANGLE_MAX,0

Here’s the log file.

Here’s a video of another flight showing the yaw causing oscillation, also you can see that when it comes back in position it is not very steady.

drone

The firmware is the ardupilot master of a couple months ago, I’ll update that for next test.

1 Like

sorry, but I can not playback video? maybe link is broken?

in the second half I see a strange behaviour, when the copter is turned on the yaw axis it flies in the opposite direction and then comes back in position, can this be related to some kind of sensor offset?

maybe mis-alignment between motion capture system coordinate and ardupilot NED coordinate?

I’ve updated the post adding the direct link to the video.
Let me know if you can open it
https://drive.google.com/file/d/1L0lyn9VHo3pjdLCbbQ2yMx6cxnW01djn/view

I’m converting the original coordinates from the motion capture system which are in ENU, I’ll double check that but I suppose that’s not the problem. Maybe the orientation is not converted well…

It’s probably important to determine if it’s a control issue or an estimation issue.

Even if it is a control issue, normally the PSC_ parameters don’t need to be changed. To make copter fly well, it’s normally the roll, pitch and yaw rate parameters that need tuning. I.e. parameters that start with ATC_.

I suspect Chobitsfan is correct that the issue is the yaw estimate is off.

Thank you Randy, the ATC_ PIDs are tuned pretty well for this small copter, I think, after various autotunes (indoor) thanks to @Leonardthall help. It flies very well in stabilize.

Apart from the yaw problem (I’ll investigate on the estimation), which parameters I have to tune to reduce the following loiter movement overshoot?

It seems an integral term, isn’t it?

I’ve done multiple tests, but never got rid of overshoot and oscillations. Only reducing PSC_POS_XY_P led to fewer oscillations, but obviously making the copter less albe to reach its PSC target.

Here’s PX and VX with a very low PSC_POS_XY_P = 0.1


I’ll reset PSC and try with the NEW LOITER parameters as stated in this thread by @Leonardthall

I’ll report here if that affects the loiter performance, i hope! :slightly_smiling_face:


For the yaw problem I’ve opened another dedicated thread with another specific video and log

This appears to be caused by the copter not being levelled correctly.

The loiter controller see’s the error in level as an external force and the I term builds up to hold against that force. However when the aircraft heading moves the loiter controller continues to lean against what it believes to be an external force. Because this force is not external but an internal level offset that moves with the heading of the aircraft the I term buildup is now incorrect and must adjust to the new orientation of the offset.

1 Like

Many thanks @Leonardthall!

I’ve replied about the yaw (or maybe we can say attitude) problem in the dedicated thread:

Here I’m trying to understand which parameters I have to tune to have a fast controller response without overshoot and oscillations. I’m curious to see if resolving the attitude problems also fixes the oscillations on the target position. I’ll get back with new results here if someone encounters the same problem.

Hey @guglie, I have a similar problem if not exactly same. I am using Aruco markers for indoor positioning. I take off in ALT_HOLD mode and switch to LOITER and take my hands off the RC controller. Ideally it should hold position but actually it is able to hold only height and yaw while Roll and Pitch (hence X-Y) oscillate. As seen in the following graphs:

As seen in the plots, the controller is able to follow the desired roll and pitch but I don’t understand why the desired roll and pitch is oscillatory when they should be actually zero.

I will be glad if someone can help me figure this out. Here is the BIN file https://drive.google.com/file/d/1vYIrUhr6WEvkhkm1LWVbr8cdfu4z5cDP/view?usp=sharing

Hi @Subodh_Mishra, does it flies well in stabilize?

Can you plot also PSC.TPX and PSC.PX?

I’ll post soon new test results without the yaw problem, hoping in a more stable behaviour.

@guglie, I appreciate you for taking time to go through my comment.

I haven’t tried flying with STABILIZE. I have just tried LOITER. Here are the plots you asked for, both X and Y:

I think the kink in between was due to temporary loss wifi connectivity.

Clearly the controller is not tracking the target position. But the target velocity and accelerations are tracked pretty well!!. I wonder why the target velocity and accelerations are not Zero! Because the drone is in LOITER mode and the sticks are released. So, it should hold position with minimal change in X-Y-Z-Yaw. Z and Yaw look good but X-Y are messed up. Attached below are the plots for velocity and acceleration (for both X and Y):


Should I tune the position controller or the attitude controller? @rmackay9, @priseborough, any idea?

In the attached plot you can see Target Position and Target Velocity, I don’t understand why they don’t agree to each other. Shouldn’t target velocity be zero is target position is constant?

Here’s a new log. I see a lot of oscillations, the positions seems not converging to the target position.

Here’s the complete log

Hi aIl,
If you see oscillation in position hold modes then try:
PSC_POSXY_P = 0.5
PSC_VELXY_P = 1
PSC_VELXY_I = 0.5
PSC_VELXY_D = 0.25

I suspect there may be some additional latency with this setup.

1 Like

hi @Leonardthall
Thank you very much for advice. I will try it

Hello, did you get any progress on this @Subodh_Mishra? I am having similar issues with 2D Cartographer Slam.