Ejemplo n.º 1
0
    def __init__(self, endpoint, connection):
        """ Initialize the Robot.

            @param endpoint:    Robot Client which is responsible for
                                monitoring the robots in this process.
            @type  endpoint:    rce.robot.RobotClient

            @param connection:  The connection manager for robot namespaces.
            @type  connection:  rce.robot.Connection
        """
        Namespace.__init__(self, endpoint)

        interface_map = {
            Types.encode('PublisherConverter') : PublisherConverter,
            Types.encode('SubscriberConverter') : SubscriberConverter,
            Types.encode('ServiceClientConverter') : ServiceClientConverter,
            Types.encode('ServiceProviderConverter') : ServiceProviderConverter,
            Types.encode('PublisherForwarder') : PublisherForwarder,
            Types.encode('SubscriberForwarder') : SubscriberForwarder,
            Types.encode('ServiceClientForwarder') : ServiceClientForwarder,
            Types.encode('ServiceProviderForwarder') : ServiceProviderForwarder
        }
        self._map.update(interface_map)

        self._connection = connection
Ejemplo n.º 2
0
    def __init__(self, endpoint, connection):
        """ Initialize the Robot.

            @param endpoint:    Robot Client which is responsible for
                                monitoring the robots in this process.
            @type  endpoint:    rce.robot.RobotClient

            @param connection:  The connection manager for robot namespaces.
            @type  connection:  rce.robot.Connection
        """
        Namespace.__init__(self, endpoint)

        interface_map = {
            Types.encode('PublisherConverter'): PublisherConverter,
            Types.encode('SubscriberConverter'): SubscriberConverter,
            Types.encode('ServiceClientConverter'): ServiceClientConverter,
            Types.encode('ServiceProviderConverter'): ServiceProviderConverter,
            Types.encode('PublisherForwarder'): PublisherForwarder,
            Types.encode('SubscriberForwarder'): SubscriberForwarder,
            Types.encode('ServiceClientForwarder'): ServiceClientForwarder,
            Types.encode('ServiceProviderForwarder'): ServiceProviderForwarder
        }
        self._map.update(interface_map)

        self._connection = connection
Ejemplo n.º 3
0
    def __init__(self, endpoint):
        """ Initialize the Environment.

            @param endpoint:    Environment Client which is responsible for
                                monitoring the environment in this process.
            @type  endpoint:    rce.robot.EnvironmentClient
        """
        Namespace.__init__(self, endpoint)

        interface_map = {
            Types.encode('PublisherInterface'): PublisherInterface,
            Types.encode('SubscriberInterface'): SubscriberInterface,
            Types.encode('ServiceClientInterface'): ServiceClientInterface,
            Types.encode('ServiceProviderInterface'): ServiceProviderInterface
        }
        self._map.update(interface_map)

        self._nodes = set()
        self._parameters = set()
Ejemplo n.º 4
0
    def __init__(self, endpoint):
        """ Initialize the Environment.

            @param endpoint:    Environment Client which is responsible for
                                monitoring the environment in this process.
            @type  endpoint:    rce.robot.EnvironmentClient
        """
        Namespace.__init__(self, endpoint)

        interface_map = {
            Types.encode('PublisherInterface') : PublisherInterface,
            Types.encode('SubscriberInterface') : SubscriberInterface,
            Types.encode('ServiceClientInterface') : ServiceClientInterface,
            Types.encode('ServiceProviderInterface') : ServiceProviderInterface
        }
        self._map.update(interface_map)

        self._nodes = set()
        self._parameters = set()
Ejemplo n.º 5
0
    def addInterface(self, iTag, iType, clsName, addr):
        """ Add an interface to the ROS environment inside the container.

            @param iTag:        Tag which is used to identify the interface in
                                subsequent requests.
            @type  iTag:        str

            @param iType:       Type of the interface. The type has to be of
                                the form:
                                    {prefix}Interface
                                whit valid prefixes:
                                    ServiceClient, ServiceProvider,
                                    Publisher, Subscriber
            @type  iType:       str

            @param clsName:     Message type/Service type consisting of the
                                package and the name of the message/service,
                                i.e. 'std_msgs/Int32'.
            @type  clsName:     str

            @param addr:        ROS name/address which the interface should
                                use.
            @type  addr:        str
        """
        try:
            validateName(iTag)
        except IllegalName:
            raise InvalidRequest('Interface tag is not a valid.')

        if iTag in self._interfaces:
            raise InvalidRequest("Can not use the same interface tag '{0}' "
                                 'in the same container twice.'.format(iTag))

        try:
            iType = Types.encode(iType)
        except TypeError:
            raise InvalidRequest('Interface type is invalid (Unknown prefix).')

        interface = self._obj.createInterface(iType, clsName, addr)
        interface = Interface(interface, iType, clsName)
        self._interfaces[iTag] = interface
        interface.notifyOnDeath(self._interfaceDied)
Ejemplo n.º 6
0
    def addInterface(self, iTag, iType, clsName):
        """ Add an interface to the Robot object.

            @param iTag:        Tag which is used to identify the interface in
                                subsequent requests.
            @type  iTag:        str

            @param iType:       Type of the interface. The type consists of a
                                prefix and a suffix.
                                 - Valid prefixes are:
                                     ServiceClient, ServiceProvider,
                                     Publisher, Subscriber
                                 - Valid suffixes are:
                                     Converter, Forwarder
            @type  iType:       str

            @param clsName:     Message type/Service type consisting of the
                                package and the name of the message/service,
                                i.e. 'std_msgs/Int32'.
            @type  clsName:     str
        """

        try:
            validateName(iTag)
        except IllegalName as e:
            raise InvalidRequest('Interface tag is invalid: {0}'.format(e))

        if iTag in self._interfaces:
            raise InvalidRequest("Can not use the same interface tag '{0}' "
                                 'in the same robot twice.'.format(iTag))

        modifier = 4 if iType.endswith('Forwarder') else 0

        try:
            iType = Types.encode(iType)
        except TypeError:
            raise InvalidRequest('Interface type is invalid (Unknown prefix).')

        interface = self._obj.createInterface(iType + modifier, clsName, iTag)
        interface = Interface(interface, iType, clsName)
        self._interfaces[iTag] = interface
        interface.notifyOnDeath(self._interfaceDied)