Example #1
0
 public rcl_client_base(rcl_node_t _node, rosidl_service_type_support_t _typesupport, string _service_name, rcl_client_options_t _options)
 {
     this.native_node  = _node;
     this.service_name = _service_name;
     this.options      = _options;
     this.typesupport  = _typesupport;
 }
Example #2
0
        public rcl_service_linux(rcl_node_t _node, rosidl_service_type_support_t typesupport, string service_name, rcl_service_options_t options) : base(_node, typesupport, service_name, options)
        {
            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();

            case RCLReturnValues.RCL_RET_INVALID_ARGUMENT:
                throw new RCLInvalidArgumentException();

            case RCLReturnValues.RCL_RET_SERVICE_INVALID:
                throw new RCLServiceInvalidException();

            case RCLReturnValues.RCL_RET_BAD_ALLOC:
                throw new RCLBadAllocException();

            case RCLReturnValues.RCL_RET_ERROR:

                break;

            default:
                break;
            }
        }
Example #3
0
        public rcl_client(rcl_node_t _node, rosidl_service_type_support_t _typesupport, string _service_name, rcl_client_options_t _options)
        {
            this.native_node  = _node;
            this.service_name = _service_name;
            this.options      = _options;
            this.typesupport  = _typesupport;

            native_handle = rcl_get_zero_initialized_client();
            rcl_client_init(ref native_handle, ref native_node, ref typesupport, service_name, ref options);
        }
Example #4
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");
     }
 }
Example #5
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);
        }
Example #6
0
        public Client(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);
                    }
                }
            }
            foreach (var item in ServiceType.GetMethods())
            {
                if (item.IsStatic)
                {
                    if (item.Name.Contains("rosidl_typesupport_introspection_c_get_message"))
                    {
                        TypeSupport = (rosidl_service_type_support_t)Marshal.PtrToStructure((IntPtr)item.Invoke(null, null), typeof(rosidl_service_type_support_t));
                    }
                }
            }
            if (TypeSupport.data == IntPtr.Zero)
            {
                throw new Exception("Couldn't get typesupport");
            }
            ClientOptions     = rcl_client.get_default_options();
            ClientOptions.qos = QOSProfile;
            InternalClient    = new rcl_client(RosNode.NativeNode, TypeSupport, ServiceName, ClientOptions);
        }
Example #7
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;
 }
Example #8
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);
Example #9
0
 extern static int rcl_client_init(ref rcl_client_t client, ref rcl_node_t node, ref rosidl_service_type_support_t type_support, string service_name, ref rcl_client_options_t options);
Example #10
0
 public rcl_client_linux(rcl_node_t _node, rosidl_service_type_support_t _typesupport, string _service_name, rcl_client_options_t _options) : base(_node, _typesupport, _service_name, _options)
 {
     native_handle = rcl_get_zero_initialized_client();
     rcl_client_init(ref native_handle, ref native_node, ref typesupport, service_name, ref options);
 }