ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

no match for call to ‘(ros::Publisher) (geometry_msgs::TransformStamped&)’

asked 2014-09-26 13:18:01 -0500

choog gravatar image

Hello, I am getting this error:

In function ‘int main(int, char**)’: /home/turtlebot/catkin_ws/src/turtlebot_formation/src/readTFframe.cpp:70:24: error: no match for call to ‘(ros::Publisher) (geometry_msgs::TransformStamped&)’

I can clear see that the two types are compatible but for some reason cmake is telling me that no match all to (geometry_msgs::TransformStamped&) exists. If anyone can help me solve this issue it would be greatly appreciated.

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <geometry_msgs/TransformStamped.h>
#include <tf/transform_listener.h>
#include <tf/transform_broadcaster.h>
#include <tf/transform_broadcaster.h>

using namespace std;

int main(int argc, char** argv) {
    ros::init(argc, argv, "readTFframe");
    ros::NodeHandle nh;
        tf::Transform leader_base_link;
    tf::Quaternion q;
    tf::Vector3 v;  
    tf::TransformListener listener;
    geometry_msgs::TransformStamped transformConverter;

    ros::Time current_time, last_time;
        current_time = ros::Time::now();
        last_time = ros::Time::now();

    ros::Publisher pub = nh.advertise<geometry_msgs::TransformStamped>("/leader/tf", 1000); //error because of this

    static tf::TransformBroadcaster br;

    double yaw; 

ros::Rate loopRate(10);
    tf::StampedTransform transform;
    current_time = ros::Time::now();

    try {
                        listener.waitForTransform("base_link", "base_footprint", ros::Time(0), ros::Duration(10.0));
            listener.lookupTransform("base_link", "base_footprint", ros::Time(0), transform);
        catch (tf::TransformException &ex) {
    yaw =   tf::getYaw(transform.getRotation()); 
        v.setValue(transform.getOrigin().x() , transform.getOrigin().y() , transform.getOrigin().z());

    q.setRPY(0.0, 0.0, yaw);
    leader_base_link.setRotation(q );
    br.sendTransform(tf::StampedTransform(leader_base_link,     ros::Time::now(), "base_footprint", "leader_base_link"));

    double th = yaw;
    geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th);
    transformConverter.header.stamp = current_time; 
    transformConverter.header.frame_id = "base_footprint";
        transformConverter.child_frame_id = "base_link";
    transformConverter.transform.translation.x = transform.getOrigin().x();
    transformConverter.transform.translation.y = transform.getOrigin().y();
    transformConverter.transform.translation.z = transform.getOrigin().z();
    transformConverter.transform.rotation = odom_quat;
    ROS_INFO_STREAM("X pose " <<  transformConverter.transform.translation.x );
    ROS_INFO_STREAM("Y pose " << transformConverter.transform.translation.y);
    ROS_INFO_STREAM("Z pose " << transformConverter.transform.translation.z );
    ROS_INFO_STREAM("Yaw "<< yaw );
    pub(transformConverter);  //error here

    return 0;
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2014-09-26 13:53:40 -0500

paulbovbel gravatar image

updated 2014-09-26 13:54:07 -0500

pub(transformConverter); //error here

It's looking for a publisher constructor that takes TransformStamped as a parameter. Correct API is


edit flag offensive delete link more


Thank you!!

choog gravatar image choog  ( 2014-09-26 14:13:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-09-26 13:18:01 -0500

Seen: 1,506 times

Last updated: Sep 26 '14