I have following Python code:

# Define rotation matrix from body frame to NED frame
R = np.array([[1, 0, 0], [0, -1, 0], [0, 0, -1]])

# Extract angular velocity and acceleration columns
angular_velocity = df[[8, 9,10]].values
acceleration = df[[5, 6, 7]].values

# Convert angular velocity and acceleration to NED frame
angular_velocity_ned = np.dot(angular_velocity, R.T)
acceleration_ned = np.dot(acceleration, R.T)

This code is trying to convert coordinates from body frame to NED frame by taking dot product with rotation matrix R. I do not get why it has chosen this specific matrix value for R (that is [[1, 0, 0], [0, -1, 0], [0, 0, -1]]). I understand it is essentially trying to flip y and z coordinates, while leaving x coordinates untouched. In other words, it's trying to do a 180 degree rotation around the X-axis. But how does it result in a transformation from body frame to NED frame?

To clarify, the code seems to work but I don't know the source of the code. I found this in a codebase that I inherited from someone who used to work on the project. He has left the project already and I have no documentation as such. I want explanation as to how/why the code works.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.