Should I keep my rotations as quaternions to modify and combine them?

Hello,

I am using several Bosch BNO055 IMUs.

First I need to apply simple, static rotations (π or π/2 radians) to the quaternions provided by the sensors. Then I need to combine the orientations with fixed-lengths vectors to calculate positions in a 3D space.

Should I keep the orientation data as quaternions for these operations or should I rather convert them into rotation matrices or another form first (with the idea of still being able to avoid the gimbal lock) ? I guess that for the combination of the orientations with 3D vectors, final conversion to Euler angles will be the best form?

Thank you in advance.

(with the idea of still being able to avoid the gimbal lock)

You can't. 3D angular transformations cannot be uniquely defined.

Rotations using quaternions are straightforward, if a bit more complicated than using 3x3 matrices derived from angles.