1 year ago
#299124
The Newb Programmer
ROS Python Code to select a Map Cell in a SLAM system
I am having trouble with this part of code for a robotics challenge for SLAM. The function can be found below and it is supposed to execute like this:
- Get all the map cells that is either empty(0) or unoccupied(1)
- Pick a cell and scan around the cells to determine if it is something good. If a score of 5 is summed up, it is a "good" point.
- Go to that cell via a function that sends the message
However, on my RVIZ screen when I execute this code, the turtlebot will just keep spinning instead of moving as you can see here:
def get_valid_cells(self, height, gridmap, width):
# Get Number of Explored Cells
cells_explored = np.count_nonzero(gridmap > -1)
rospy.loginfo("Cells Explored %i", cells_explored)
# Create an Array with Cells to Pick
cells = 0
score = 0
cells_to_pick = np.zeros((cells_explored, 2))
for y in xrange(0, height):
for x in xrange(0, width):
idx = x + y * width
if gridmap[idx] > -1:
for y2 in xrange(y-1, y+2):
for x2 in xrange(x-1, x+2):
if gridmap[idx] > -1:
score =+ score
if score > 5:
cells_to_pick[cells][0] = x2
cells_to_pick[cells][1] = y2
cells = cells + 1
return cells_to_pick
I have tried changing the code but I don't understand it enough to modify it to display a pose goal on the screen. Please help.
python
ros
robotics
slam
0 Answers
Your Answer