0
$\begingroup$

Rosanswers logo

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.


Originally posted by Jeff on ROS Answers with karma: 16 on 2017-06-10

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

It's funny. I figured it out.

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


Originally posted by Jeff with karma: 16 on 2017-06-10

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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