# Resampling attitude states (quaternions, rotation matrix) in a Particle Filter

Suppose I have a particle filter which contains an attitude state (we'll use a unit quaternion from the body to the earth frame for this discussion) $\mathbf{q}_b^e$.

What methods should or should not be used for resampling? Many resampling schemes (e.g. this paper) seem to require the variance to be calculated at some stage, which is not trivial for $SO\{3\}$. Or, the variance is required when performing roughening.

Are there any good papers on resampling attitude states? Especially those that re-sample complete poses (e.g. position and attitude)?

Most particle filter implementations will use some kind of importance sampling, which does not require you to make an assumption on the underlying distribution. This is one of the main reasons for using a particle filter in the first place. Importance sampling does not sample from the estimated distribution, but from your set of weighted samples.

This includes the ones in your linked paper. All the references to variance in there speak of the variance which is introduced by that particular re-sampling scheme. It is a measure on the quality of the re-sampling, since you do not want to introduce unnecessary uncertainty in your estimate of the true distribution by the particles. You do not need to calculate the variances of your particles for the re-sampling.

On the question which one work best? Your paper has some of the answers. I also made a post on the subject using less maths. In most cases some form of stratified resampling will be better than the multinomial scheme.

The only case I could think of where you would need to calculate the variance of your SO(3) distribution as well would be when you wanted to verify the variance your resampling introduces. In that case, what I would do is to calculate the mean of the orientation (as you said, not trivial), and then use the variance of differences to the mean as scaled axis of rotation representation. But as I said. I don't think you need this.

One word of caution: sampling over the full 6D pose is in most cases not recommended. You need a serious amount of particles for this. Even if you needed only 10 particles per dimension to represent your distribution appropriately - which often is not enough - this could mean that you need up to one million particles in 6D. Lots of memory and processing power...