how to convert from probabilty to occupancy grid message
Dears
i am trying to create an occupancy grid message, so for that i have some float data represent the probability,
I used std_msgs::Float32MultiArray
with data[]
field =
[1.0, 10.0, 0.10000000149011612, 3.0, 9.0, 0.20000000298023224, 3.0, 10.0, 0.1666666716337204, 4.0, 9.0, 0.23333333432674408, 6.0, 8.0, 0.2666666805744171, 6.0, 9.0, 0.03333333507180214]
as an example to represent that probability,where the first value "1.0"
represent the height, the second value "10"
represent the width and the third value represent the probability at that (1.0,10) cell, and so on for other values,
i publish this message and in another node i create nav_msgs::OccupancyGrid grid_message
with these info
grid_message.info.height = 20;
grid_message.info.width = 20;
grid_message.info.resolution = 0.2;
and i use msg->data[y]*width + msg->data[x]
to fill the data
field of the occupancyGrid message
,
for example, at cell(1,10) the corresponding nav_msgs::OccupancyGrid.data
index is (10*20+1) and in this index i store 0.10000000149011612
when i listen to the occupancyGrid message
the data in nav_msgs::OccupancyGrid.data
look like
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 11, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ...
Without the code it might be hard to say.