Robot rotates around a point instead of navigating to Goal Position when using the navigation stack

asked 2017-11-13 16:32:30 -0600

nemesis gravatar image

updated 2017-11-13 16:43:18 -0600


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