Пример #1
0
    def get_object_type(self, object_type):
        """

        Args:
            object_type:

        @type object_type: str

        Returns: getObjectTypeResponse

        """
        req = getObjectTypeRequest()
        req.name = object_type
        resp = self.get_object_type_srv.call(
            req)  # type: getObjectTypeResponse
        return resp.object_type
Пример #2
0
    def callback(self, detected_object):
        """
        :type detected_object: InstancesArray
        :return:
        """

        objects = []
        for obj in detected_object.instances:
            '''to_json = {'name': obj.object_id, 'pose': {'position': {'x': obj.pose.position.x,
                                                                         'y': obj.pose.position.y,
                                                                         'z': obj.pose.position.z},
                                                            'orientation': {'x': obj.pose.orientation.x,
                                                                            'y': obj.pose.orientation.y,
                                                                            'z': obj.pose.orientation.z,
                                                                            'w': obj.pose.orientation.w}}}'''
            req = getObjectTypeRequest()
            req.name = obj.object_type
            resp = self.get_object_type_srv.call(req)
            if not resp.success:
                rospy.logwarn("Object type " + str(req.name) +
                              " not in DB, skipping")
                continue
            # TODO publikuje se automaticky Z poloha na 0.023 .. opravit
            to_json = {
                'name': obj.object_id,
                'type': obj.object_type,
                'position': {
                    'x': obj.pose.position.x,  # in meters
                    'y': obj.pose.position.y,
                    'z': obj.pose.position.z
                },
                'orientation': {
                    'x': obj.pose.orientation.x,
                    'y': obj.pose.orientation.y,
                    'z': obj.pose.orientation.z,
                    'w': obj.pose.orientation.w
                },
                'bbox': {
                    'x': resp.object_type.bbox.dimensions[0],
                    'y': resp.object_type.bbox.dimensions[1],
                    'z': resp.object_type.bbox.dimensions[2]
                }
            }
            objects.append(to_json)
        self.pub.publish(jsonpickle.encode(objects))