Efficient way to convert from roll, pitch yaw to geometry_msgs::Quaternion
In order to convert roll, pitch and yaw angles to a geometry_msgs::Quaternion
object, which is appropriate for publishing, I currently do the following:
tf2::Quaternion quaternion_tf2;
quaternion_tf2.setRPY(roll, pitch, yaw);
geometry_msgs::Quaternion quaternion = tf2::toMsg(quaternion_tf2);
However, is there a more efficient way to do this? In particular, is there a way to bypass having to create a tf2::Quaternion
object, and instead simply initialize the geometry_msgs::Quaternion
object with roll, pitch and yaw using something similar to the .setRPY()
function that is available for tf2::Quaternion
?