Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="rclcs.Subscription`1"/> class. With a custom qos profile
        /// </summary>
        /// <param name="_node">Node.</param>
        /// <param name="_topicName">Topic name.</param>
        /// <param name="_QOS">QO.</param>
        public Subscription(Node _node, string _topicName, rmw_qos_profile_t _QOS)
        {
            QOSProfile = _QOS;
            RosNode    = _node;
            TopicName  = _topicName;

            Type wrapperType = typeof(T);
            Type messageType = typeof(T);

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

            foreach (var item in messageType.GetMethods())
            {
                if (item.IsStatic)
                {
                    if (item.Name.Contains("rosidl_typesupport_introspection_c__get_message_type_support_handle"))
                    {
                        foundMethod = true;
                        TypeSupport = (rosidl_message_type_support_t)Marshal.PtrToStructure((IntPtr)item.Invoke(null, null), typeof(rosidl_message_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");
            }
            SubscriptionOptions     = rcl_subscription.get_default_options();
            SubscriptionOptions.qos = QOSProfile;
            InternalSubscription    = new rcl_subscription(RosNode, TypeSupport, TopicName, SubscriptionOptions);
        }
Exemplo n.º 2
0
        public rcl_subscription_linux(Node _node, rosidl_message_type_support_t _type_support, string _topic_name, rcl_subscription_options_t _options) : base(_node, _type_support, _topic_name, _options)
        {
            subscription = rcl_get_zero_initialized_subscription();

            rcl_subscription_init(ref subscription, ref native_node, ref _type_support, _topic_name, ref _options);
        }
Exemplo n.º 3
0
 extern static int rcl_subscription_init(ref rcl_subscription_t subscription, ref rcl_node_t node, ref rosidl_message_type_support_t typesupport, string topic_name, ref rcl_subscription_options_t options);
Exemplo n.º 4
0
 public rcl_subscription(Node _node, rosidl_message_type_support_t _type_support, string _topic_name, rcl_subscription_options_t _options)
 {
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         Impl = new rcl_subscription_windows(_node, _type_support, _topic_name, _options);
     }
     else if (Environment.OSVersion.Platform == PlatformID.Unix)
     {
         Impl = new rcl_subscription_linux(_node, _type_support, _topic_name, _options);
     }
     else
     {
         throw new Exception("Operating system: " + Environment.OSVersion.Platform.ToString() + " not supported");
     }
 }
Exemplo n.º 5
0
 public rcl_subscription_base(Node _node, rosidl_message_type_support_t _type_support, string _topic_name, rcl_subscription_options_t _options)
 {
     native_node = _node.NativeNode;
 }