Transform from base_link to odom failed on Stage [closed]

asked 2013-06-14 07:33:31 -0500

Zayin gravatar image

updated 2014-01-28 17:16:54 -0500

ngrennan gravatar image

I am starting to learn how to program a robot controller on C++. For now, I just want my robot to repetitively travel 1m straight until it runs into an obstacle. When I run my program on Stage, the robot moves 2-3 times, then I receive a Transform from base_link to odom failed error message. After that, the robot rotates then go straight 1m for a few times, then rotates, etc. I think a rotation occurs every time the transform fails. Unless this is related to the local planner?

I don't understand how the transform would sometimes work and sometimes not. Here is my code:

#include <ros/ros.h>
#include <move_base_msgs/MoveBaseAction.h>
#include <actionlib/client/simple_action_client.h>
#include <nav_msgs/GetMap.h>
#include <costmap_2d/costmap_2d_ros.h>
#include <costmap_2d/costmap_2d.h>
#include <navfn/navfn_ros.h>

using namespace navfn;
typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;

int main(int argc, char** argv){

  ros::init(argc, argv, "compare");

  //tell the action client that we want to spin a thread by default
  MoveBaseClient client("move_base", true);

  //wait for the action server to come up
  while(!client.waitForServer(ros::Duration(5.0)) && ros::ok()){
    ROS_INFO("Waiting for the move_base action server to come up");
  }

  move_base_msgs::MoveBaseGoal goal;

  //we'll send a goal to the robot to move 1 meter forward
  goal.target_pose.header.frame_id = "base_link";
  ros::Rate loop_rate(10);

  while (ros::ok()) {

    goal.target_pose.header.stamp = ros::Time::now();
    goal.target_pose.pose.position.x = 1.0;
    goal.target_pose.pose.orientation.w = 1.0;

    ROS_INFO("Sending goal");
    client.sendGoal(goal);

    client.waitForResult();

    if(client.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
      ROS_INFO("Hooray, the base moved 1 meter forward");
    else
      ROS_INFO("The base failed to move forward 1 meter for some reason");

    ros::spinOnce();
    loop_rate.sleep();  

  }

  return 0;
}

Here is my launch file:

<launch>
  <master auto="start"/>
  <param name="/use_sim_time" value="true"/>
  <node pkg="stage" type="stageros" name="stage" args="/home/bennie/fuerte_workspace/worlds/test.world" respawn="false" output="screen"/> 


  <arg name="scan_topic" default="base_scan" />

  <node pkg="gmapping" type="slam_gmapping" name="gmapping" output="screen">
    <remap from="scan" to="base_scan" /> 
    <param name="odom_frame" value="odom"/>
    <param name="inverted_laser" value="false" />
    <param name="maxUrange" value="30.0" />
    <param name="particles" value="30" />
    <param name="delta" value="0.10" />
    <param name="xmin" value="-15.0" />
    <param name="xmax" value="15.0" />
    <param name="ymin" value="-15.0" />
    <param name="ymax" value="15.0" />
    <param name="angularUpdate" value="0.5" />
    <param name="linearUpdate" value="1.0" />
    <param name="map_update_interval" value="1.0" />
    <param name="resampleThreshold" value="0.3" />
    <param name="llsamplerange" value ="0.05" />
    <param name="llsamplestep" value ="0.05" />
    <param name="lasamplerange" value ="0.05" />
    <param name="lasamplestep" value ="0.05" />
  </node>


  <include file="$(find map_compare)/compare.xml" />
  <include file="$(find map_compare)/move.xml" />

</launch>

Compare.xml and move.xml call .yaml files:.

compare_costmap:
  global_frame: /map
  robot_base_frame: base_link
  update_frequency: 1.0
  publish_frequency: 0.0
  raytrace_range: 5.0
  obstacle_range: 5.0
  static_map: true
  rolling_window: false
  width: 60.0
  height: 60.0
  resolution: 0.2
  origin_x: 0.0
  origin_y: 0.0
  track_unknown_space: true
  publish_voxel_map ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Zayin
close date 2013-08-29 18:55:14

Comments

Well I gave up on that and tried something more simple that doesn't rely on costmaps, but I get the same error. See my other topic.

Zayin gravatar imageZayin ( 2013-08-29 18:54:59 -0500 )edit