# Transform from base_link to odom failed on Stage [closed]

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
ros::Rate loop_rate(10);

while (ros::ok()) {

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
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 ...
edit retag reopen merge delete
{"ft_lang_label":"__label__en","ft_lang_prob":0.5560995,"math_prob":0.5563587,"size":3661,"snap":"2019-35-2019-39","text_gpt3_token_len":1029,"char_repetition_ratio":0.15449822,"word_repetition_ratio":0.00968523,"special_character_ratio":0.29472822,"punctuation_ratio":0.21585903,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9554026,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-16T06:07:25Z\",\"WARC-Record-ID\":\"<urn:uuid:3d3aa5e0-65f0-42bf-8235-a9e048c577d4>\",\"Content-Length\":\"54839\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e0041896-814e-4772-99da-272494a14202>\",\"WARC-Concurrent-To\":\"<urn:uuid:fc81489a-3eaf-4692-be34-fe5bb759b38e>\",\"WARC-IP-Address\":\"140.211.15.248\",\"WARC-Target-URI\":\"https://answers.ros.org/question/65186/transform-from-base_link-to-odom-failed-on-stage/\",\"WARC-Payload-Digest\":\"sha1:EQ2ZELUQED3ROFXOUEU7XN5VF6VPOMTC\",\"WARC-Block-Digest\":\"sha1:7TBMSC773CB77RYXFSJGMW5EYZQDTBFD\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514572491.38_warc_CC-MAIN-20190916060046-20190916082046-00514.warc.gz\"}"}