DLu / navigation_layers

156 stars 136 forks source link

tf_->transform(in, out, global_frame_); #53

Closed kadn closed 5 years ago

kadn commented 5 years ago

when I use this code in ubuntu16.04, I found it has an error when being compiled.

error: ‘class tf::TransformListener’ has no member named ‘transform’
       tf_->transform(pt, opt, global_frame);

There seems no version of ROS Kinetic, and when I try ROS indigo, there is no error. Is indigo suitable for Ubuntu 16.04?

DLu commented 5 years ago

There are binaries for indigo, kinetic and melodic. Which branch are you trying to compile?

starRureole commented 5 years ago

I'd like to use the kinetic version

DLu commented 5 years ago

@StarsFu Are you having trouble compiling the kinetic version?

Kin-Zhang commented 5 years ago

yes... me too. I use the kinetic version. and here is the error:

/home/ramlab/kintest_ws/src/range_sensor_layer/src/range_sensor_layer.cpp: In member function ‘void range_sensor_layer::RangeSensorLayer::updateCostmap(sensor_msgs::Range&, bool)’:
/home/ramlab/kintest_ws/src/range_sensor_layer/src/range_sensor_layer.cpp:253:96: error: no matching function for call to ‘tf::TransformListener::canTransform(std::__cxx11::string&, std_msgs::Header_<std::allocator<void> >::_frame_id_type&, std_msgs::Header_<std::allocator<void> >::_stamp_type&, ros::Duration)’
   if (!tf_->canTransform(global_frame_, in.header.frame_id, in.header.stamp, ros::Duration(0.1)))

/home/ramlab/kintest_ws/src/range_sensor_layer/src/range_sensor_layer.cpp:261:8: error: ‘class tf::TransformListener’ has no member named ‘transform’
   tf_->transform(in, out, global_frame_);
DLu commented 5 years ago

@qingwenZhang Please post what branch of the repository you are using

DLu commented 5 years ago

That did not answer my question. Please run the following:

roscd range_sensor_layer
git status

And paste the output back here.

Kin-Zhang commented 5 years ago

@DLu

Located in the branch melodic
Your branch is consistent with the upstream branch 'origin/melodic'.
No files to submit, clean workspace

Is this git clone just for melodic? But with binary package, I will get this error that why I download again. https://answers.ros.org/question/325716/error-with-range_sensor_layer-move_base-node-dies-when-a-sensor_msgsrange-is-published/

Kin-Zhang commented 5 years ago

I know what happened here, and fix it. In kinetic version,these code (tf_->canTransform) need to modify to the indigo version's like:

if(!tf_->waitForTransform(global_frame_, in.header.frame_id, in.header.stamp, ros::Duration(0.1)) )
  {
    ROS_ERROR_THROTTLE(1.0, "Range sensor layer can't transform from %s to %s at %f",
        global_frame_.c_str(), in.header.frame_id.c_str(),
        in.header.stamp.toSec());
    return;
  }

  tf_->transformPoint (global_frame_, in, out);

  double ox = out.point.x, oy = out.point.y;

  in.point.x = range_message.range;

  tf_->transformPoint(global_frame_, in, out);

I hope this comment can help other people who meet this error:

error: ‘class tf::TransformListener’ has no member named ‘transform’
       tf_->transform(pt, opt, global_frame);

(but it seems that I have the sanor_layer but not in costmap_2d as obstacle) and Thanks for your patient to help us~ DLu

DLu commented 5 years ago

For ROS versions indigo, jade, kinetic and lunar, please use the indigo branch.