Quaternion๊ณผ Euler(roll, pitch, yaw)์„ ์ƒํ˜ธ ๋ณ€ํ™˜ ํ•ด๋ณด์ž

๊ฐœ์š”

์ขŒํ‘œ๊ณ„๋ฅผ ๋‹ค๋ฃจ๋‹ค ๋ณด๋ฉด ํ•ด๋‹น ๊ฐ๋„ ํ‘œํ˜„์„ ๋งŽ์ด ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ๋‹ค.
์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ๋„ ํ—ท๊ฐˆ๋ ค์„œ ๋ธ”๋กœ๊ทธ์— ๊ธฐ๋กํ•ด๋‘”๋‹ค.

Quaternion โ€“> Euler

#include <tf/tf.h>

// input : ์ฟผํ„ฐ๋‹ˆ์–ธ(quat)
tf::Quaternion q( quat.x,	quat.y,	quat.z,	quat.w);
tf::Matrix3x3 m(q);

double roll, pitch, yaw;
m.getRPY(roll, pitch, yaw);

std::cout << "roll  : " << roll << std::endl;
std::cout << "pitch : " << pitch << std::endl;
std::cout << "yaw   : " << yaw << std::endl;

Euler โ€“> Quaternion

#include <tf2/LinearMath/Quaternion.h>

// input : ์˜ค์ผ๋Ÿฌ ๊ฐ(roll, pitch, yaw)
tf2::Quaternion quat;
quat.setRPY(roll, pitch, yaw);
quat.normalize();

std::cout << "quat.w : " << quat.getW() << std::endl;
std::cout << "quat.x : " << quat.getX() << std::endl;
std::cout << "quat.y : " << quat.getY() << std::endl;
std::cout << "quat.z : " << quat.getZ() << std::endl;

Leave a comment