Conversions Between Common Orientation Representations

이 기사에서는 로봇에 일반적인 방향 표현 간의 변환을 위한 방정식을 제시합니다. 포즈 표현에 대한 자세한 내용은 Position, Orientation and Coordinate Transformations 을 확인하십시오.

Roll-Pitch-Yaw to Rotation Matrix

Roll-pitch-yaw는 방향을 나타내는 일반적인 용어입니다. 각각은 단일 축을 중심으로 한 회전 각도를 나타내며 결합하여 완전한 회전을 나타냅니다. 그러나 정확히 무엇을 나타내는지는 명확하지 않습니다. 다음과 같은 혼란을 겪을 수 있습니다.

  • 각각 어떤 축을 중심으로 회전합니까?

  • 이 축은 고정되어 있습니까, 아니면 이동 중입니까?

  • 회전은 어떤 순서로 정의됩니까(여러 가지 가능성이 있음)?

회전 순서는 종종 x-y-z 또는 z-y'-x'' 로 표시됩니다. 여기서 x, yz 는 회전하는 축을 나타냅니다. ' 는 축의 고정 여부를 나타내는 데 사용됩니다. 고정 축을 중심으로 하는 회전을 extrinsic rotation 이라고 합니다. 움직이는 축을 중심으로 회전하는 것을 intrinsic rotation 이라고 합니다.

다음은 두 가지 다른 예입니다.

x-y-z 또는 z-y'-x'' 의 경우, 롤 ϕ, 피치 θ 및 요 ψ 각도는 다음과 같이 회전 행렬 R 로 변환할 수 있습니다.:

Rxyz=Rzyx=Rz,ϕRy,θRx,ψ=[cosϕsinϕ0sinϕcosϕ0001][cosθ0sinθ010sinθ0cosθ][1000cosψsinψ0sinψcosψ]

z-y-x 또는 x-y'-z'' 의 경우, 롤 ϕ, 피치 θ 및 요 ψ 각도는 다음과 같이 회전 행렬 R 로 변환할 수 있습니다.:

Rzyx=Rxyz=Rx,ϕRy,θRz,ψ=[1000cosϕsinϕ0sinϕcosϕ][cosθ0sinθ010sinθ0cosθ][cosψsinψ0sinψcosψ0001]

참고

두 예에서 각도가 동일하다고 가정하면 동일한 최종 회전 행렬을 나타내지 않습니다.

최종 회전 행렬이 동일하다고 가정하면 두 예제 간에 각도가 동일하지 않습니다.

정의가 도입되었습니다. 롤 각도는 움직이는 축에 대한 첫 번째 회전에 할당되고, 피치는 두 번째, 요는 세 번째 회전에 할당됩니다.

소스로 이동

source

rollPitchYawListToRotationMatrix(rpyList);
소스로 이동

소스

rollPitchYawListToRotationMatrix(rpyList);
소스로 이동

소스

roll_pitch_yaw_to_rotation_matrix(rpy_list)

Rotation Vector to Axis-Angle

회전 벡터 r 는 다음과 같이 축 u 과 각도 θ 로 변환할 수 있습니다.:

θ=rx2+ry2+rz2
u=[rxθryθrzθ]

Axis-Angle to Quaternion

u 과 각도 θ 는 다음과 같이 unit quaternion q 로 변환할 수 있습니다.:

q=[cosθ2uxsinθ2uysinθ2uzsinθ2]

Quaternion to Rotation Matrix

unit quaternion q 는 다음과 같이 회전 행렬 R 로 변환할 수 있습니다.:

R=[12qy22qz22qxqy2qzqw2qxqz2qyqw2qxqy2qzqw12qx22qz22qyqz2qxqw2qxqz2qyqw2qyqz2qxqw12qx22qy2]

quaternion이 (qw+qx+qy+qz=1) 와 같이 정규화되었다고 가정합니다. 그렇지 않은 경우 다음 방정식을 사용하여 변환을 수행하기 전에 정규화해야 합니다.

n=qw2+qc2+qy2+qz2
q=[qwnqxnqynqzn]

소스로 이동

source

const Eigen::Matrix3f rotationMatrixFromQuaternion = quaternion.toRotationMatrix();
std::cout << "Rotation Matrix from Quaternion:\n"
          << rotationMatrixFromQuaternion.format(matrixFormatRules) << std::endl;
소스로 이동

소스

var rotationMatrixFromQuaternion = quaternionToRotationMatrix(quaternion);
Console.WriteLine("Rotation Matrix from Quaternion:\n" + matrixToString(rotationMatrixFromQuaternion));
소스로 이동

소스

rotation_matrix_from_quaternion = quaternion_to_rotation_matrix(quaternion)
print(f"Rotation Matrix from Quaternion:\n{rotation_matrix_from_quaternion}")

Rotation Matrix to Quaternion

회전 행렬 R 을 다음과 같이 unit quaternion q 으로 변환할 수 있습니다.:

qw=1+r11+r22+r332
q=[qwr32r234qwr13r314qwr21r124qw]

소스로 이동

source

const Eigen::Quaternionf quaternion(rotationMatrix);
std::cout << "Quaternion:\n" << quaternion.coeffs().format(vectorFormatRules) << std::endl;
소스로 이동

소스

var quaternion = rotationMatrixToQuaternion(rotationMatrix);
Console.WriteLine("Quaternion:\n" + matrixToString(quaternion.Transpose()));
소스로 이동

소스

quaternion = rotation_matrix_to_quaternion(rotation_matrix)
print(f"Quaternion:\n{quaternion}")

Quaternion to Axis-Angle

unit quaternion q 는 다음과 같이 축 u 과 각도 θ 로 변환할 수 있습니다.:

θ=2cos1qw
u=[qx1qw2qy1qw2qz1qw2]

이것은 회전 행렬에서 축 각도로 변환하는 데 유용합니다. 아래 코드 샘플 구현을 참조하십시오.

소스로 이동

source

const Eigen::AngleAxisf axisAngle(rotationMatrix);
std::cout << "AxisAngle:\n"
          << axisAngle.axis().format(vectorFormatRules) << ", " << axisAngle.angle() << std::endl;
소스로 이동

소스

var axisAngle = rotationMatrixToAxisAngle(rotationMatrix);
Console.WriteLine("AxisAngle:\n" + matrixToString(axisAngle.Axis.Transpose()) + ", " + String.Format(" {0:G4} ", axisAngle.Angle));
소스로 이동

소스

axis_angle = rotation_matrix_to_axis_angle(rotation_matrix)
print(f"AxisAngle:\n{axis_angle.axis}, {axis_angle.angle:.4f}")

Axis-Angle to Rotation Vector

u 과 각도 θ 는 다음과 같이 회전 벡터 r 로 변환할 수 있습니다.:

r=[uxθuyθuzθ]

이것은 회전 행렬을 회전 벡터로 변환하는 데 유용합니다. 아래 코드 샘플 구현을 참조하십시오.

소스로 이동

source

const Eigen::Vector3f rotationVector = rotationMatrixToRotationVector(rotationMatrix);
std::cout << "Rotation Vector:\n" << rotationVector.format(vectorFormatRules) << std::endl;
소스로 이동

소스

var rotationVector = axisAngle.Axis * axisAngle.Angle;
Console.WriteLine("Rotation Vector:\n" + matrixToString(rotationVector.Transpose()));
소스로 이동

소스

rotation_vector = rotation_matrix_to_rotation_vector(rotation_matrix)
print(f"Rotation Vector:\n{rotation_vector}")

Rotation Matrix to Roll-Pitch-Yaw

회전 매트릭스에서 롤, 피치, 요 각도를 결정하는 것은 간단하지 않습니다. 여러 가지, 때로는 무한한 솔루션이 있을 수도 있습니다. 이를 위해서는 몇 가지 기준에 따라 여러 솔루션 중 하나를 선택할 수 있는 알고리즘이 필요합니다.

소스로 이동

source

const auto rpyList = rotationMatrixToRollPitchYawList(rotationMatrix);
소스로 이동

소스

var rpyList = rotationMatrixToRollPitchYawList(rotationMatrix);
소스로 이동

소스

rpy_list = rotation_matrix_to_roll_pitch_yaw(rotation_matrix)