Robot rotates around a point instead of navigating to Goal Position when working with amcl

asked 2017-11-20 19:46:37 -0600

nemesis gravatar image


I have a custom robot with 2 wheels, a camera, and a laser rangefinder. I am trying to localize the robot using amcl.

I had everything set up. When rviz was launched I would define the initial 2D pose estimate and the used to define the 2d Nav Goal in RViz as well.

However, I implemented a basic node to publish to the topic so that I could have the robot move to the goal directly. When I run that node, RViz displays the correct path to the goal. But the robot starts moving forward and after a while (usually around the same spot) it starts to rotate around a single point for some reason.

I am not sure why that's the case. It works fine when I try to run it via RViz but not via the node. The code I am working with for the node -

    #include <ros/ros.h>
#include <move_base_msgs/MoveBaseAction.h>
#include <actionlib/client/simple_action_client.h>
#include <tf/transform_datatypes.h>

typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;

int main(int argc, char** argv) {
    ros::init(argc, argv, node_name);

    // create the action client
    // true causes the client to spin its own thread
    MoveBaseClient ac("move_base", true);

    // Wait 60 seconds for the action server to become available
    ROS_INFO("Waiting for the move_base action server");

    ROS_INFO("Connected to move base server");

    // Send a goal to move_base
    move_base_msgs::MoveBaseGoal goal;
    goal.target_pose.header.frame_id = "map";
    goal.target_pose.header.stamp = ros::Time::now();

    goal.target_pose.pose.position.x = 0.995;
    goal.target_pose.pose.position.y = -2.996;
    goal.target_pose.pose.orientation.w = 1;


    // Wait for the action to return

    if (ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
        ROS_INFO("You have reached the goal!");
        ROS_INFO("The base failed for some reason");

    return 0;

I run the above using rosrun package_name node_name

This is what it looks like right now. The robot started to rotate instead of following the green path.

image description

edit retag flag offensive close merge delete


This is not related to amcl, which provides localization. I guess this has something to do with how you setup move_base and the respective planners. I don't see anything wrong in particular with you code, so IMO this should work. You could check the return value of waitForServer to see if ...

mgruhler gravatar image mgruhler  ( 2017-11-23 01:09:57 -0600 )edit

... you are actually connected, but if the Robot starts to drive, all should be fine.

Maybe Elaborate on the Problem, does the localization get lost (i.e. real/simulated Position vs. Position in rviz), what is your move_base configuration...

mgruhler gravatar image mgruhler  ( 2017-11-23 01:11:07 -0600 )edit

@mig Thanks for the reply. As of now, it was because of either an additional planner or a planner parameter added by mistake that was causing this. It's been working since I removed that. I will go through some tests to confirm and then add an answer.

nemesis gravatar image nemesis  ( 2017-11-30 00:22:57 -0600 )edit

@nemesis Sir Kindly help me, i'm also facing the same problem since a month.Kindly provide me the solution. it would be a great help. Thanks

Hamza Khalid gravatar image Hamza Khalid  ( 2018-12-08 06:40:14 -0600 )edit