60 #if defined __ROS_VERSION && __ROS_VERSION == 1
62 void process_pose_msg(
const ros_geometry_msgs::Pose2D::ConstPtr& pose2d_msg)
64 ROS_INFO_STREAM(
"pose2d_to_odom_converter: Pose2D message received, x = " << pose2d_msg->x <<
"m, y = " << pose2d_msg->y <<
" m, theta=" << (180.0 * pose2d_msg->theta /M_PI) <<
" deg");
69 theta_quaternion.
setRPY(0, 0, pose2d_msg->theta);
71 odom_msg.header.frame_id =
"map";
72 odom_msg.child_frame_id =
"laser";
73 odom_msg.pose.pose.position.x = pose2d_msg->x;
74 odom_msg.pose.pose.position.y = pose2d_msg->y;
75 odom_msg.pose.pose.position.z = 0;
76 odom_msg.pose.pose.orientation.x = theta_quaternion.getX();
77 odom_msg.pose.pose.orientation.y = theta_quaternion.getY();
78 odom_msg.pose.pose.orientation.z = theta_quaternion.getZ();
79 odom_msg.pose.pose.orientation.w = theta_quaternion.
getW();
80 odom_msg.pose.covariance = {0};
81 odom_msg.twist.twist.linear.x = 0;
82 odom_msg.twist.twist.linear.y = 0;
83 odom_msg.twist.twist.linear.z = 0;
84 odom_msg.twist.twist.angular.x = 0;
85 odom_msg.twist.twist.angular.y = 0;
86 odom_msg.twist.twist.angular.z = 0;
87 odom_msg.twist.covariance = {0};
88 nav_odom_publisher.
publish(odom_msg);
89 ROS_INFO_STREAM(
"pose2d_to_odom_converter: Odometry message published, x = " << odom_msg.pose.pose.position.x <<
"m, y = " << odom_msg.pose.pose.position.y <<
" m, yaw = " << (180.0 * pose2d_msg->theta /M_PI) <<
" deg, frame_id = " << odom_msg.header.frame_id <<
", child_frame_id = " << odom_msg.child_frame_id);
91 #endif // __ROS_VERSION == 1
94 int main(
int argc,
char** argv)
96 #if defined __ROS_VERSION && __ROS_VERSION == 1
97 ros::init(argc, argv,
"pose2d_to_odom_converter");
108 #endif // __ROS_VERSION == 1