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

Visualization in RVIZ

asked 2018-10-15 03:36:15 -0600

KinWah gravatar image

updated 2018-10-27 03:21:14 -0600

Good day, I am new to ROS Answer and beginner of ROS.

Referred to the title above, this Image A below illustrates the desired goal I would like to achieve. It is done in LabVIEW and right now, I would like to achieve the similar result by using RVIZ. It is doing Hector Mapping and Sensor value mapping simultaneously in real time.

Image A

Figure : Image A (Source: Integrating SLAM And Gas Distribution Mapping SLAM GDM For Real Time Gas Source Localization (Kamarulzaman Kamarudin))

Currently, I have successfully implement Hector SLAM and Image B below shows the result of my Hector SLAM implementation.

Image B

Figure : Image B

My question is, which type of message should my data published as so it can be visualized as Image A in RVIZ? For example, should my data publish as:

  1. visualization_msgs/Marker
  2. visualization_msgs/MarkerArray
  3. nav_msgs
  4. sensor_msgs
  5. Costmap2D
  6. grid_map

I am new to this and I do not know which approach is the best method to be used so I can achieve result similar to Image A..

Advice and recommendation are very welcome.

Thank you for the assist !

Special thanks to @gvdhoorn for willingly providing me sufficient karma so that I can display those images.

edit retag flag offensive close merge delete

Comments

Hi, could I please ask you to attach your images directly to your question? I've given you sufficient karma for that.

Thanks.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-15 05:08:16 -0600 )edit

@gvdhoorn, thank you so much for providing me with sufficient karma. May God bless your kindness.

KinWah gravatar image KinWah  ( 2018-10-15 11:17:19 -0600 )edit

No need to thank me. They're just imaginary internet points.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-15 11:39:43 -0600 )edit

It is still a great help for a newbie. Thanks again. Hopefully, someone may lend me a hand on this topic ^_^

KinWah gravatar image KinWah  ( 2018-10-15 12:16:30 -0600 )edit
1
Humpelstilzchen gravatar image Humpelstilzchen  ( 2018-10-17 13:01:34 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-10-17 05:20:55 -0600

KinWah gravatar image

updated 2018-10-27 03:54:14 -0600

Hi. I have solved this problem with two possible methods. One is by using pointcloud2 and the second is by using visualizer msgs : marker. Images below show my desired goal and solutions obtained by using pointcloud2 and marker. Matplotlib_RVIZ The left image is generated by using matplotlib while the center is by using PointCloud2 and right is by using marker. There is not obvious different between PointCloud2 and Marker from the aspect of display. I cant generate the exact similar image as matplotlib (the yellow region) due to my lack of knowledge. Recommendation and suggestion on how to achieve that is very welcome. Back to the topic. Although PC2 and marker version does not have the yellowish region as matplotlib, however it has slightly lighter region at the similar location is satisfy for me. I have attached part of my codes for PC2 and Marker at here as references for beginner like me.

For PointCloud2 :

# PointCloud2 is working
# PointCloud2 : The following part is to gdm_data X, Y and mean/var
gdm_X = X.flatten()
gdm_Y = Y.flatten()
gdm_Z = numpy.zeros_like(gdm_X)
gdm_Mean = mean_map.flatten()
gdm_data = numpy.column_stack((gdm_X,gdm_Y,gdm_Z,gdm_Mean))
# PointCloud2 : The following algo is for visualize pointcloud2
header = std_msgs.msg.Header()
header.stamp = rospy.Time.now()
header.frame_id = 'map'
field=[PointField(name='x', offset=0, datatype=PointField.FLOAT32, count=1),PointField(name='y', offset=4, datatype=PointField.FLOAT32, count=1),PointField(name='z', offset=8, datatype=PointField.FLOAT32, count=1),PointField(name='rgb', offset=12, datatype=PointField.UINT32, count=1)]
gdm_data = pcl2.create_cloud(header, field, gdm_data)
pc2_Testing.publish(gdm_data)

For Marker :

# MarkerArray is Working
gdm_X = X.flatten()
gdm_Y = Y.flatten()
gdm_Z = numpy.zeros_like(gdm_X)
gdm_Mean = mean_map.flatten()
gdm_Mean = numpy.interp(gdm_Mean,[min(gdm_Mean),max(gdm_Mean)],[0.0,1.0])
gdm_data = numpy.column_stack((gdm_X,gdm_Y,gdm_Z,gdm_Mean))
triplePoints = []
colorsGroup = []
markerArray = MarkerArray()
for (x,y,z,a) in gdm_data:
    p = Point() 
    p.x = x
    p.y = y
    p.z = 0
    marker = Marker()
    marker.header.frame_id = "/map"
    marker.type = marker.POINTS
    marker.action = marker.ADD
    marker.scale.x = 0.2
    marker.scale.y = 0.2
    marker.scale.z = 0.2
    colorsGroup.append(ColorRGBA(0,0,a,1))
    marker.pose.orientation.w = 1.0
    t = rospy.Duration()
    marker.lifetime = t
    triplePoints.append(p)
marker.points = triplePoints
marker.colors = colorsGroup
markerArray.markers.append(marker)
marker_pub.publish(markerArray)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-10-15 03:36:15 -0600

Seen: 1,280 times

Last updated: Oct 27 '18