I'm trying to send a transformation from "world" to "base_link" based on coordinates I get from a different node. The node is actually running, and it is reaching the ROS_INFO() right before the broadcaster.sendTransform(transformStamped);
(so the other node is working, and the tf2 broadcaster node gets the data and the callback is called repeatedly), but when I run rosrun tf tf_monitor
to see what I get, it's empty:
RESULTS: for all Frames
Frames:
All Broadcasters:
I've been trying to find the mistake for 2 days now and I don't see what I'm doing wrong. Any advise?
#include <ros/ros.h>
#include <tf2_ros/transform_broadcaster.h>
#include <geometry_msgs/TransformStamped.h>
#include <cstdio>
#include "geometry_msgs/PoseStamped.h"
void posCallback(const geometry_msgs::PoseStamped& msg){
tf2_ros::TransformBroadcaster broadcaster;
geometry_msgs::TransformStamped transformStamped;
transformStamped.header.stamp = ros::Time::now();
transformStamped.header.frame_id = "world";
transformStamped.child_frame_id = "base_link";
transformStamped.transform.translation.x = msg.pose.position.x;
transformStamped.transform.translation.y = msg.pose.position.y;
transformStamped.transform.translation.z = msg.pose.position.z;
transformStamped.transform.rotation.x = msg.pose.orientation.x;
transformStamped.transform.rotation.y = msg.pose.orientation.y;
transformStamped.transform.rotation.z = msg.pose.orientation.z;
transformStamped.transform.rotation.w = msg.pose.orientation.w;
ROS_INFO("broadcast");
broadcaster.sendTransform(transformStamped);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "base_link_broadcaster");
ros::NodeHandle node;
ros::Subscriber sub = node.subscribe("positioning", 1000, posCallback);
ros::spin();
return 0;
}
Originally posted by 256shadesofgrey on ROS Answers with karma: 1 on 2019-05-07
Post score: 0