What is the best possible way to track the orientation invariant path of an inertial unit.
For example, I have an inertial unit in my palm and if I want to use it as a pen to write something (say an alphabet 'A' in the air). I use a machine learning model and train in by writing 'A' in the air for say 30 times and 'B' for 30 times. The model learns it and classifies if it is an A or B when I give it a new input. This is all fine. But here arises the actual question. I train the model by writing 'A' and 'B' in the air and the model only learns it in the particular orientation I hold the inertial unit. When I provide the trained model a new input 'A' holding the inertial unit say tilted slightly different from the orientation of the sensor that was held during training, the model gets confused.
So, is there a way how I can use the inertial sensor to cancel out the orientation and just track the position of the sensor in the space and use this trajectory to train the model?
I learnt that I can find the position of the inertial sensor by double integrating the acceleration values I get. But then, it turns out to be a tedious and unreliable process for my application. Anything using quaternions? I partially understand that I need to transform the sensor frame to the world frame to achieve what I want but I feel its too complicated or am I just complicating it too much for myself?