Go to the documentation of this file.00001 #include <sstream>
00002
00003 #include <ros/ros.h>
00004 #include <geometry_msgs/PoseWithCovarianceStamped.h>
00005
00006 using namespace std;
00007
00008 class InitialStatusSender {
00009 public:
00010 InitialStatusSender()
00011 {
00012 _pub = _nh.advertise < geometry_msgs::PoseWithCovarianceStamped > ("initialpose", 1, true);
00013 }
00014
00015 void publishInitialPose()
00016 {
00017 stringstream param_basename;
00018
00019 param_basename << "initialpose";
00020
00021 geometry_msgs::PoseWithCovarianceStamped initialpose;
00022
00023 double x, y, th, cov_x, cov_y, cov_th;
00024
00025 _nh.getParam(param_basename.str() + "/x", x);
00026 _nh.getParam(param_basename.str() + "/y", y);
00027 _nh.getParam(param_basename.str() + "/th", th);
00028 _nh.getParam(param_basename.str() + "/cov_x", cov_x);
00029 _nh.getParam(param_basename.str() + "/cov_y", cov_y);
00030 _nh.getParam(param_basename.str() + "/cov_th", cov_th);
00031
00032 initialpose.header.frame_id = "/map";
00033
00034 initialpose.pose.pose.position.x = (float) x;
00035 initialpose.pose.pose.position.y = (float) y;
00036 initialpose.pose.pose.position.z = 0.0;
00037
00038 initialpose.pose.covariance[0] = cov_x;
00039 initialpose.pose.covariance[7] = cov_y;
00040 initialpose.pose.covariance[35] = cov_th;
00041
00042 initialpose.pose.pose.orientation.w = cos(th / 2.0);
00043 initialpose.pose.pose.orientation.z = sin(th / 2.0);
00044 initialpose.pose.pose.orientation.x = 0.0;
00045 initialpose.pose.pose.orientation.y = 0.0;
00046
00047 _pub.publish(initialpose);
00048 }
00049
00050 private:
00051
00052 ros::NodeHandle _nh;
00053
00054
00055 ros::Publisher _pub;
00056 };
00057
00058 int main(int argc, char** argv)
00059 {
00060 ros::init(argc, argv, "initial_pose_sender");
00061
00062 InitialStatusSender ips;
00063
00064 ips.publishInitialPose();
00065
00066 ros::spinOnce();
00067
00068 return 0;
00069 }