4 #include <geometry_msgs/TransformStamped.h> 5 #include <turtlesim/Pose.h> 13 geometry_msgs::TransformStamped transformStamped;
16 transformStamped.header.frame_id =
"world";
18 transformStamped.transform.translation.x = msg->x;
19 transformStamped.transform.translation.y = msg->y;
20 transformStamped.transform.translation.z = 0.0;
22 q.
setRPY(0, 0, msg->theta);
23 transformStamped.transform.rotation.x = q.x();
24 transformStamped.transform.rotation.y = q.y();
25 transformStamped.transform.rotation.z = q.z();
26 transformStamped.transform.rotation.w = q.w();
31 int main(
int argc,
char** argv){
32 ros::init(argc, argv,
"my_tf2_broadcaster");
35 if (! private_node.
hasParam(
"turtle"))
37 if (argc != 2){
ROS_ERROR(
"need turtle name as argument");
return -1;};
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
ROSCPP_DECL void spin(Spinner &spinner)
bool getParam(const std::string &key, std::string &s) const
bool hasParam(const std::string &key) const
void poseCallback(const turtlesim::PoseConstPtr &msg)