ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Hi, I am trying to write a code, which uses nav_msgs's OccupancyGrid

asked 2017-11-14 01:03:31 -0500

Shu gravatar image

updated 2017-11-14 02:04:49 -0500

gvdhoorn gravatar image

Hi, I am trying to write a code, which uses nav_msgs's OccupancyGrid, to visualize the grid map like a potential field.

I'm inserting the probability of where an obstacle might move next into OccupancyGrid.data[]. data[] was declared as Int8 so I am inserting numbers from 0 to 100. I'm pretty sure that rviz should show each sell white or gray or black, but in my code some parts become red.

I want to add up the inserted data each time so that when multiple objects collide, the data[] becomes 100 and shows a black area. At the end of the program, I wrote a for loop so that when the value of data[] is over 100, that value becomes exactly 100.

Here's the part of the code where I'm having trouble with...

map.data[p + q_] += (int)(100 * (1 - sqrt((x-X)*(x-X) + (y-Y)*(y-Y))/R_d));

And to finalize the map.data[] I defined a global variable _LETHAL 100 and inserted it like below

if(map.data[i]>_LETHAL) map.data[i] = _LETHAL;

I apologize for making this confusing, it seems that I'm not able to upload my program or any image because I just registered today...

But will very appreciate for any help...! Thank you.

edit retag flag offensive close merge delete

Comments

Welcome! Code you please copy and paste your code here? It's actually better to do that vs. attaching it as a file.

jayess gravatar image jayess  ( 2017-11-14 01:28:47 -0500 )edit

Also, no need to use <br> tags, you can just hit Enter to move to a new line. To enable syntax highlighting just copy & paste the code, highlight it, then click the 101010 (Preformatted Text) button.

jayess gravatar image jayess  ( 2017-11-14 01:30:27 -0500 )edit

Hi jayess. Thank you so much for the advice! I'll keep them in mind when I ask another question here. I apparently figured it out! It seems that nav_msgs::OccupancyGrid's data value only receives up to 100. If it goes over that amount, it pushes out an error and I get weird visualized points.

Shu gravatar image Shu  ( 2017-11-14 21:50:16 -0500 )edit

Thanks again for the support!

Shu gravatar image Shu  ( 2017-11-14 21:50:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-11-14 21:51:07 -0500

Shu gravatar image

I apparently figured it out! It seems that nav_msgs::OccupancyGrid's data value only receives up to 100. If it goes over that amount, it pushes out an error and I get weird visualized points.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-11-14 01:03:31 -0500

Seen: 619 times

Last updated: Nov 14 '17