00001 #include "ros/ros.h" 00002 #include "geometry_msgs/Pose.h" 00003 #include "tf/transform_datatypes.h" 00004 00005 00006 class MoveBase { 00007 public: 00008 MoveBase(ros::NodeHandle _nh) : nh(_nh), 00009 pub(nh.advertise<geometry_msgs::Pose>("/mobile_base/commands/position", 10)) { } 00010 void move_to(float x, float y, float z, float yaw) { 00011 geometry_msgs::Pose p; 00012 p.position.x = x; 00013 p.position.y = y; 00014 p.position.z = z; 00015 tf::Quaternion q = tf::createQuaternionFromYaw(yaw); 00016 p.orientation.x = q.x(); 00017 p.orientation.y = q.y(); 00018 p.orientation.z = q.z(); 00019 p.orientation.w = q.w(); 00020 00021 pub.publish(p); 00022 } 00023 00024 void move_to(geometry_msgs::Pose &p) { 00025 pub.publish(p); 00026 } 00027 00028 private: 00029 ros::NodeHandle nh; 00030 ros::Publisher pub; 00031 };