rst-tu-dortmund / teb_local_planner_tutorials

This package contains supplementary material and examples for teb_local_planner tutorials.
167 stars 98 forks source link

failed to lookup transform: "base_laser_link" passed to lookupTransform argument target_frame does not exist. #6

Closed shanpenghui closed 3 years ago

shanpenghui commented 5 years ago

Hi, i try to get the laser raw data and transform it into map coordinates. So my thought is to get the tf relationship between laser and map. First, I launch the robot_diff_drive.launch in tutorials. I see the ROBOT->TF->TREE in RVIZ, it shows the map -> odom -> base_footprint -> base_link -> base_laser_link. Have i must to get all the tfs in the tree when i transform laser data into map coordinates? When i get the tf, it show error that: [ WARN] [1559374574.328688493, 2885.400000000]: failed to lookup transform: "base_laser_link" passed to lookupTransform argument target_frame does not exist.

Main function of my source code is: int main(int argc, char **argv) { ros::init(argc, argv, "demo"); ros::NodeHandle nh; ros::Rate loop_rate(20); while (ros::ok()) { ros::spinOnce(); loop_rate.sleep(); tf2_ros::Buffer tfBuffer; try { geometry_msgs::TransformStamped transform = tfBuffer.lookupTransform("base_laser_link", "base_link", ros::Time(0)); } catch(tf2::LookupException& lE){ ROS_WARN("failed to lookup transform: %s", lE.what()); } } return 0; } I enter the cmd "rostopic echo /tf" in terminal it show that: `

---

transforms:

And i run the cmd "rosrun tf tf_echo base_laser_link base_link" ,the result is : ` sph@sph-ThinkPad-W530:~$ rosrun tf tf_echo base_laser_link base_link At time 5266.900

Can someone explain why tf have the frame_id but in C++ code it can't detect the frame_id? Do i make mistake or error setting?

shanpenghui commented 5 years ago

Finally, i guess i unterstand the reason is tf need some time to fill the buffer. See:https://github.com/atenpas/handle_detector/issues/7#issuecomment-498157395

amrita9suresh commented 3 years ago

I have the same problem now. @shanpenghui The link you shared no longer has the answer. Could you please explain the answer to this issue? Thanks a ton!

kvnptl commented 3 years ago

I also faced the same error.

I ran below two commands: 1) roslaunch my_robot world.launch

2) rosrun gmapping slam_gmapping Error: [ WARN] Failed to compute laser pose, aborting initialization ("base_link" passed to lookupTransform argument target_frame does not exist. )

How I solved:

I created my own gmapping lanch file instead using default one.

These two lines are important. Check your output scantopic and robot base frame.

<arg name="scan_topic" default="/scan" />
<arg name="base_frame" default="robot_footprint" />

Below is my gmapping.launch file:

<?xml version="1.0" encoding="UTF-8"?>

<!--slam_gmapping-->
<launch>
  <arg name="scan_topic" default="/scan" />
  <arg name="base_frame" default="robot_footprint" />

  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen" clear_params="true">
    <param name ="base_frame" value="$(arg base_frame)" />
    <param name="map_update_interval" value="30.0"/>

    <!-- Set maxUrange < actual maximum range of the Laser -->
    <param name="maxRange" value="5.0"/>
    <param name="maxUrange" value="4.5"/>
    <param name="sigma" value="0.05"/>
    <param name="kernelSize" value="1"/>
    <param name="lstep" value="0.05"/>
    <param name="astep" value="0.05"/>
    <param name="iterations" value="5"/>
    <param name="lsigma" value="0.075"/>
    <param name="ogain" value="3.0"/>
    <param name="lskip" value="0"/>
    <param name="srr" value="0.01"/>
    <param name="srt" value="0.02"/>
    <param name="str" value="0.01"/>
    <param name="stt" value="0.02"/>
    <param name="linearUpdate" value="0.5"/>
    <param name="angularUpdate" value="0.436"/>
    <param name="temporalUpdate" value="-1.0"/>
    <param name="resampleThreshold" value="0.5"/>
    <param name="particles" value="80"/>

    <param name="xmin" value="-1.0"/>
    <param name="ymin" value="-1.0"/>
    <param name="xmax" value="1.0"/>
    <param name="ymax" value="1.0"/>

    <param name="delta" value="0.05"/>
    <param name="llsamplerange" value="0.01"/>
    <param name="llsamplestep" value="0.01"/>
    <param name="lasamplerange" value="0.005"/>
    <param name="lasamplestep" value="0.005"/>
    <remap from="scan" to="$(arg scan_topic)"/>
  </node>
</launch>

Reference: Link

shanpenghui commented 3 years ago

I have the same problem now. @shanpenghui The link you shared no longer has the answer. Could you please explain the answer to this issue? Thanks a ton!

Sry for that, I forgot the method, maybe you can take reference of the example by @kvnptl

shanpenghui commented 3 years ago

I have the same problem now. @shanpenghui The link you shared no longer has the answer. Could you please explain the answer to this issue? Thanks a ton!

@amrita9suresh The method is add code in transformGlobalPlan function:

      // wait for tf to be ready
      while (!tf_->canTransform(global_frame, plan_pose.header.frame_id, global_pose.header.stamp))
      {
          std::this_thread::sleep_for(std::chrono::milliseconds(2));
      }
fpassold commented 3 years ago

Thanks a lot " @kvnptl (commented on 13 Feb)". Your suggestions solved my problem. I added the following lines to my file "gmapping_demo.launch":

<launch>
  <arg name="scan_topic" default="/scan" />
  <arg name="base_frame" default="robot_footprint" />
  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen"  clear_params="true" >
    <param name ="base_frame"         value="$(arg base_frame)" />
    <param name="map_update_interval" value="30.0"/>
    <!-- continues with more lines and parameter adjustment -->
     ...

and ROS stopped annoying me with gmapping error!

fpassold@ubuntu1:~/ws_project_7/catkin_ws$ roslaunch my_robot gmapping_demo.launch
... logging to /home/fpassold/.ros/log/44d25490-b7eb-11eb-a738-902b34f42166/roslaunch-ubuntu1-12017.log<launch>
  <arg name="scan_topic" default="/scan" />
  <arg name="base_frame" default="robot_footprint" />
  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen"  clear_params="true" >
    <param name =
...
NODES
  /
    slam_gmapping (gmapping/slam_gmapping)

ROS_MASTER_URI=http://localhost:11311

process[slam_gmapping-1]: started with pid [12039]
[ INFO] [1621354279.730626800, 5301.379000000]: Laser is mounted upwards.
 -maxUrange 5 -maxUrange 10 -sigma     0.05 -kernelSize 1 -lstep 0.05 -lobsGain 3 -astep 0.05
 -srr 0.01 -srt 0.02 -str 0.01 -stt 0.02
 -linearUpdate 0.1 -angularUpdate 0.05 -resampleThreshold 0.5
 -xmin -10 -xmax 10 -ymin -10 -ymax 10 -delta 0.02 -particles 10
[ INFO] [1621354279.733941225, 5301.382000000]: Initialization complete
update frame 0
update ld=0 ad=0
Laser Pose= 0.128205 0.15004 1.58577
m_count 0
Registering First Scan
...
Mo-Elshamy commented 1 year ago

i was having this issue and nothing work from the above. but i finally fixed it by editing the slam_gmapping.cpp file

this is the original code:

  // Parameters used by our GMapping wrapper
  if(!private_nh_.getParam("throttle_scans", throttle_scans_))
    throttle_scans_ = 1;
  if(!private_nh_.getParam("base_frame", base_frame_))
    base_frame_ = "base_frame";
  if(!private_nh_.getParam("map_frame", map_frame_))
    map_frame_ = "map";
  if(!private_nh_.getParam("odom_frame", odom_frame_))
    odom_frame_ = "odom";

  private_nh_.param("transform_publish_period", transform_publish_period_, 0.05);

  double tmp;
  if(!private_nh_.getParam("map_update_interval", tmp))
    tmp = 5.0;
  map_update_interval_.fromSec(tmp);

i changed the base_frame_ = "base_frame"; to base_frame_ = "base"; as my base frame named by "base"

i dont know why the cpp file dosent detect it so i changed it manually