restructure prepare_coordinates, added median aggregation function, tried SMA on roll,pitch