ROS RPY(euler) to orientation

korkhg15·2022년 5월 16일
0

ROS

목록 보기
5/6
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <geometry_msgs/Quaternion.h>

double roll = 0.0, pitch = 0.0, yaw = 0.0; //you can set roll pitch yaw
tf2::Quaternion quat_tf2, my_quaternion; //quaternion
geometry_msgs::Quaternion quat_msg;

my_quaternion.setRPY(roll, pitch, yaw);
my_quaternion = quat_tf2.normalize();

//tf2 quaternion to ros_msg quaternion
quat_msg = tf2::toMsg(quat_tf2);

//or ros_msg to tf2
tf2::convert(quat_msg, quat_tf2);
tf2::fromMsg(quat_msg, quat_tf2);

0개의 댓글