Skip to content

Available Modules

common.py

Contains common functions like get_grpc_channel() and some functions for passing into boltons.iterutils.remap.

The source is located here.

fb_helper.py

This is a module provided through the seerep_grpc package. It provides functions to construct a subset of the SEEREP flatbuffers message in one function call. Most of the functions only return the component for further composition into another datatype. If the component itself should be serialized builder.Finish() as well as builder.Output() need to be called, on the from the function retrieved value.

The source is located here.

service_manager.py

Contains a class ServiceManager which when instantiated can be used to instantly call the services with the return values of the fb_helper.py functions, i.e. the builder.Finish() and builder.Output() calls are done in the ServiceManager methods. Example usage can be found in msg_abs/msgs.py , e.g.:

        @classmethod
        def datauuid(cls, builder: Builder, channel: Channel) -> List[int]:
            query_fb = FbQuery(channel).datatype_instance
            serv_man = ServiceManager(channel)
            images = serv_man.call_get_images_fb(builder, query_fb)
            points = serv_man.call_get_points_fb(builder, query_fb)
            pcl2s = serv_man.call_get_pointcloud2_fb(builder, query_fb)

            image_uuids = sorted(
                [image.Header().UuidMsgs().decode() for image in images]
            )
            point_uuids = sorted(
                [point.Header().UuidMsgs().decode() for point in points]
            )
            pcl2_uuids = sorted(
                [pcl.Header().UuidMsgs().decode() for pcl in pcl2s]
            )

            # debugging
            # print("images: " + str(image_uuids))
            # print("points: " + str(point_uuids))
            # print("pcls: " + str(pcl2_uuids))

            # fill up return list with every second uuid
            ret_lst = [
                builder.CreateString(image_uuids[i])
                for i in range(0, len(image_uuids), 2)
            ]
            ret_lst += [
                builder.CreateString(point_uuids[i])
                for i in range(0, len(point_uuids), 2)
            ]
            ret_lst += [
                builder.CreateString(pcl2_uuids[i])
                for i in range(0, len(pcl2_uuids), 2)
            ]

The source is located here.

Note: This module is currently incomplete and contains only a subset of the available service calls.

fb_to_dict.py

fb_flatc_dict()

The fb_flatc_dict function can be used to convert serialized flatbuffers objects to a python dictionary. More information can be found by looking at the docstring:

    Converts a binary flatbuffers object to a python dictionary using it's IDL
    file.

    This function should only be used for debugging or testing purposes, as it
    alleviates the advantage of flatbuffers lessening the amount of copied data.

    This implementation uses temporary files in /tmp for conversion.

    Args:
        fb_obj: The bytearray object as returned by builder.Output().
        schema_file_name: The to `fb_obj` corresponding datatype in the
        `SchemaFileNames` format

    Returns:
        A python dictionary containing the objects attribute information.

catkin_find_schema_dir()

Looking at the docstring should reveal everything to know about this function:

    Tries to find the schema directory on the system using `catkin locate`.

    Args:
        ros_pkg_name: The name of the ros package containing the relevant
        schema files
        sub_dir: The name of the subdir of the package dir containing the
        relevant schema files

    Returns:
        The schema directory on the system if found.

    Raises:
        FileNotFoundError: If the path on the system is not present.
        ChildProcessError: If `catkin locate` returns something on stderr
        or failed otherwise

SchemaFileNames

A enum type class, to map the available flatbuffers type schema file names. Only used as a type specifier for fb_flatc_dict.