Skip to content

HIRo Perception

Minh-Khang Vu edited this page Oct 13, 2019 · 9 revisions

The HIRO Generic Perception Class (hiro_core/GenericPerception.py) is designed to obtain color, depth, and PointCloud data from any type of camera.

Usage

From the list of rostopics for the current camera being used, pick a depth, color, and PointCloud subscriber as parameters for the Perception class.

DepthSubscriber = '/kinect2/sd/image_depth_rect'
ColorSubscriber = '/kinect2/sd/image_color'
PointCloudSubscriber = '/kinect2/sd/points'
perception = GenericPerception(DepthSubscriber, ColorSubscriber, PointCloudSubscriber)

Then run the Perception class method run() to collect and show the color, depth, and PointCloud data.

perception.run()

To get the current snapshot of RGB, depth or pointcloud data, you can use:

# RGB 3D array
perception.rgb_scaled_img
# Depth 2D array
perception.depth_scaled_img
# Point cloud data type (sensor_msgs.msg.PointCloud2)
perception.point_cloud

Implementation and Extension

Please look at the (hiro_core/GenericPerception.py) class to examine its implementation. You can also extend the class as you wish:

from hiro_core.GenericPerception import GenericPerception

class MyPerception(GenericPerception):
    def __init__(self, *args, **kwargs):
        super(MyPerception, self).__init__(*args, **kwargs)

    def myCustomFunction(self):
        # Do Something!
        pass

# Use your custom class
perception = MyPerception(DepthSubscriber, ColorSubscriber, PointCloudSubscriber)
perception.run()