I'm using ROS Melodic with Gazebo 9 in an Ubuntu 18.04.2 LTS.

I'm studying a robotics subject at the university and I have to create a map of a closed room with one obstacle using only odometry. The idea is to know where are the obstacle and the walls to avoid them when the robot navigates to a goal position.

To do that I will do the following:

I will move the robot using the keyboard to map the entire room. I will use the odom topic from a diffdrive controller which its type is nav_msgs/Odometry and store its geometry_msgs/Pose.msg Pose data into a text file. I will store its x and y coordinates. I will filter them, and only store a new location if this new location differs from the previous one with an amount (0.1).

I can make the map autonomously using a bumper and making the robot follows a "snake" pattern. But this is not my big problem. My problem here is that I don't know how to use the map.

I've thought to use A* to move to robot to its goal. To use A* I've thought to create a 2D matrix with all the points in the text file. Each row will be the x location (I will have as many rows as many different x location I have), and the same for the rows (y location). If there is an obstacle, in the cell will be 0, and a 1 is the location is free.

I have a lot of questions but I can only ask one here:

If I want to use A*, is it correct what I did with the map?

NOTE: Beware that I'm not asking about how to do it with ROS, I'm asking if it is correct what I did with the map to allow me to use it with A*.


1 Answer 1


Nope, most of these maps are defined as adjacency matrices not maps describing a physical scene. Moreover, switch the parity of the elements since vanilla A* algorithms on the internet use minimum weight, not maximum weight.

  • $\begingroup$ Thanks for your answer. What do you mean with "minimum weight" and "maximum weigtht"? What do you suggest me? Thanks. $\endgroup$
    – VansFannel
    Apr 25, 2019 at 10:30
  • $\begingroup$ This is a very minor edit and I think you'll see what I'm talking about when you plot the paths on your own. You might see that the paths seem to go towards the obstacles, not around them! In that case, try switching the parity. By minimum weight, I mean that the algorithm looks for the shortest path. How would you define "shortest"? In this case, it happens to be the least edge weights. However, I just realized that these weights don't refer to the edges but rather the nodes, so I would recommend worrying about min vs max weights when you build your adjacency matrix. $\endgroup$
    – Bill Quesy
    Apr 25, 2019 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.