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
#include
#include
#include
#include
#include
#include
using namespace navfn;
typedef actionlib::SimpleActionClient 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:
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: true
unknown_cost_value: 255
transform_tolerance: 0.5
map_type: costmap
transform_tolerance: 0.5
obstacle_range: 2.5
max_obstacle_height: 2.0
raytrace_range: 3.0
inscribed_radius: 0.35
circumscribed_radius: 0.4
inflation_radius: 0.6
cost_scaling_factor: 15.0
lethal_cost_threshold: 100
observation_sources: base_scan
base_scan: {sensor_frame: /base_laser_link, data_type: LaserScan, expected_update_rate: 0.0,
observation_persistance: 0.0, marking: true, clearing: true}
#Independent settings for the planner's costmap
global_costmap:
global_frame: /map
robot_base_frame: /base_link
update_frequency: 1.0
publish_frequency: 0.5
raytrace_range: 30.0
obstacle_range: 5.0
static_map: false
rolling_window: false
width: 60.0
height: 60.0
resolution: 0.05
origin_x: -30.0
origin_y: -30.0
#Independent settings for the local planner's costmap
local_costmap:
global_frame: /odom
robot_base_frame: /base_link
update_frequency: 1.0
publish_frequency: 5.0
static_map: false
rolling_window: true
width: 3.0
height: 5.0
resolution: 0.05
origin_x: 0.0
origin_y: 0.0
What is wrong here?
↧