Ask Your Question
0

Please help me with Tf2 problem

asked 2017-06-10 10:21:06 -0500

Jeff gravatar image

I am working on the ETH ROS online course exercise 3 but I cannot get the transform part working. My tfbuffer cannot get filled and my lookuptransform ends up with "target frame does not exist".

I have verified that the frames do exist and my ros rate is correct. So I think the problem is in the C++ class programming .But I don't know how to deal with it

I have three main files in the system: 1. husky_highlevel_controller_node.cpp 2. husky_highlevel_controller.cpp 3. husky_highlevel_controller.hpp

Bascially the node file has the main function and declares a husky_controller object. Then all the actual code are in the constructor of the object. This is the node.cpp file:

int main(int argc, char **argv) { ros::init(argc, argv, "husky_highlevel_controller");

// create a private namespace nodeHandle ros::NodeHandle nodeHandle;

ros::Rate rate(1.0); husky_highlevel_controller::HuskyHighlevelController huskyHighlevelController(nodeHandle);

ros::spin(); return 0; }

Then, I put tf2_ros::Buffer tfBuffer; tf2_ros::TransformListener tfListener(tf2_ros::Buffer tfBuffer);

in the private section of the class in the .hpp file.

Lastly, in the husky_highlevel_controller.cpp namespace constructor file, I put

tf2_ros::TransformListener tfListener(tfBuffer);

if (tfBuffer.canTransform("odom","base_laser",ros::Time(0))){

ROS_INFO("Cantransform"); } else { ROS_INFO("Cannot transform"); }

I just keep getting "Cannot transform") no matter what I do. It seems that tfBuffer is not even filled.

Please help ! Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-06-10 10:27:28 -0500

Jeff gravatar image

It's funny. I figured it out.

Basically, you need to put your listener declaration inside the callback function. Otherwise it wont work

edit flag offensive delete link more

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

Stats

Asked: 2017-06-10 10:18:34 -0500

Seen: 435 times

Last updated: Jun 10 '17