Esempio n. 1
0
        public Service(Node _Node, string _ServiceName, rmw_qos_profile_t _QOS)
        {
            QOSProfile  = _QOS;
            RosNode     = _Node;
            ServiceName = _ServiceName;
            Type ServiceType = typeof(T);
            Type wrapperType = typeof(T);

            foreach (var item in wrapperType.GetMethods())
            {
                if (item.IsStatic)
                {
                    if (item.Name.Contains("GetMessageType"))
                    {
                        ServiceType = (Type)item.Invoke(null, null);
                    }
                }
            }
            bool foundMethod = false;

            foreach (var item in ServiceType.GetMethods())
            {
                if (item.IsStatic)
                {
                    if (item.Name.Contains("rosidl_typesupport_introspection_c__get_service_type_support_handle__"))
                    {
                        foundMethod = true;
                        TypeSupport = (rosidl_service_type_support_t)Marshal.PtrToStructure((IntPtr)item.Invoke(null, null), typeof(rosidl_service_type_support_t));
                    }
                }
            }
            if (!foundMethod)
            {
                throw new MissingMethodException("Could not find typesupport method");
            }
            if (TypeSupport.data == IntPtr.Zero)
            {
                throw new Exception("Couldn't get typesupport");
            }
            ServiceOptions     = rcl_service.get_default_options();
            ServiceOptions.qos = QOSProfile;
            InternalService    = new rcl_service(RosNode.NativeNode, TypeSupport, ServiceName, ServiceOptions);
        }
Esempio n. 2
0
 public rcl_service(rcl_node_t _node, rosidl_service_type_support_t typesupport, string service_name, rcl_service_options_t options)
 {
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         //TODO codepath for windows
     }
     else if (Environment.OSVersion.Platform == PlatformID.Unix)
     {
         Impl = new rcl_service_linux(_node, typesupport, service_name, options);
     }
     else
     {
         throw new Exception("Operating system: " + Environment.OSVersion.Platform.ToString() + " not supported");
     }
 }
Esempio n. 3
0
 public rcl_service_base(rcl_node_t _node, rosidl_service_type_support_t typesupport, string service_name, rcl_service_options_t options)
 {
     this.native_node     = _node;
     this.service_options = options;
 }
Esempio n. 4
0
 extern static int rcl_service_init(ref rcl_service_t service, ref rcl_node_t node, ref rosidl_service_type_support_t type_support, string topic_name, ref rcl_service_options_t options);
Esempio n. 5
0
        public rcl_service(rcl_node_t _node, rosidl_service_type_support_t typesupport, string service_name, rcl_service_options_t options)
        {
            native_node   = _node;
            native_handle = rcl_get_zero_initialized_service();
            int             ret    = rcl_service_init(ref native_handle, ref native_node, ref typesupport, service_name, ref options);
            RCLReturnValues retVal = (RCLReturnValues)ret;

            switch (retVal)
            {
            case RCLReturnValues.RCL_RET_OK:

                break;

            case RCLReturnValues.RCL_RET_NODE_INVALID:
                throw new RCLNodeInvalidException();
                break;

            case RCLReturnValues.RCL_RET_INVALID_ARGUMENT:
                throw new RCLInvalidArgumentException();
                break;

            case RCLReturnValues.RCL_RET_SERVICE_INVALID:
                throw new RCLServiceInvalidException();
                break;

            case RCLReturnValues.RCL_RET_BAD_ALLOC:
                throw new RCLBadAllocException();
                break;

            case RCLReturnValues.RCL_RET_ERROR:

                break;

            default:
                break;
            }
        }