0
$\begingroup$

Rosanswers logo

Hello all,

I was wondering how to create a boost::shared_ptr<T> global variable for a tf::TransformListener object? I am encountering the same problem as in this question posted a while ago but I don't know enough about boost::shared_ptr<T>.

Can someone explain how I can declare and initialize boost::shared_ptr<T> with respect to tf::TransformListener? Many thanks in advance.

Kind Regards, Martin


Originally posted by MartinW on ROS Answers with karma: 464 on 2013-03-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi Martin,

boost::shared_ptr<tf::TransformListener> tf_ptr;

...

int main(int argc, const char* argv []) {

  ros::init(argc, argv, "my_node");
  tf_ptr.reset(new tf::TransformListener);

  ... do more stuff here. Use tf_ptr as a regular pointer for the most part ...

  return 0;
}

The comments in this thread also explain the same answer.


Originally posted by piyushk with karma: 2871 on 2013-03-12

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by MartinW on 2013-03-12:
Thanks for the quick reply piyushk! I tried this but now I am back to getting the error: reference to ‘transform’ is ambiguous. candidates are: tf::StampedTransform transform. Do I need to make StampedTransform a shared_ptr too? the variable transform is what I need in my callback

Comment by dornhege on 2013-03-12:
Can you give the code sample producing that.

Comment by MartinW on 2013-03-12:
Hey dornhege, I put the code into another answer (forgetting that I could edit my own question haha)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.