Robot rotates around a point instead of navigating to Goal Position when working with amcl
Hello,
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");
ac.waitForServer(ros::Duration(5));
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;
ac.sendGoal(goal);
// Wait for the action to return
ac.waitForResult();
if (ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
ROS_INFO("You have reached the goal!");
else
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.
Asked by nemesis on 2017-11-20 20:46:37 UTC
Comments
This is not related to
amcl
, which provides localization. I guess this has something to do with how you setupmove_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 ofwaitForServer
to see if ...Asked by mgruhler on 2017-11-23 02:09:57 UTC
... 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...Asked by mgruhler on 2017-11-23 02:11:07 UTC
@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.
Asked by nemesis on 2017-11-30 01:22:57 UTC
@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
Asked by Hamza Khalid on 2018-12-08 07:40:14 UTC