public Publisher <T> CreatePublisher <T>(string topic, QualityOfServiceProfile qos = null) where T : Message, new() { Publisher <T> publisher = new Publisher <T>(topic, this, qos); publishers.Add(publisher); return(publisher); }
public Publisher(string topic, Node node, QualityOfServiceProfile qos = null) { nodeHandle = node.handle; handle = NativeMethods.rcl_get_zero_initialized_publisher(); IntPtr publisherOptions = NativeMethods.rclcs_publisher_create_default_options(); int qosProfileRmw = qos == null ? (int)QosProfiles.DEFAULT : (int)qos.Profile; NativeMethods.rclcs_publisher_set_qos_profile(publisherOptions, qosProfileRmw); //TODO(samiam): Figure out why System.Reflection is not available //when building with colcon/xtool on ubuntu 18.04 and mono 4.5 //MethodInfo m = typeof(T).GetTypeInfo().GetDeclaredMethod("_GET_TYPE_SUPPORT"); //IntPtr typeSupportHandle = (IntPtr)m.Invoke(null, new object[] { }); IMessageInternals msg = new T(); IntPtr typeSupportHandle = msg.TypeSupportHandle; Utils.CheckReturnEnum(NativeMethods.rcl_publisher_init( ref handle, ref nodeHandle, typeSupportHandle, topic, publisherOptions)); }
public Subscription <T> CreateSubscription <T>(string topic, Action <T> callback, QualityOfServiceProfile qos = null) where T : Message, new() { if (qos == null) { qos = new QualityOfServiceProfile(QosProfiles.DEFAULT); } Subscription <T> subscription = new Subscription <T>(topic, this, callback, qos); subscriptions.Add(subscription); return(subscription); }
public Subscription(string topic, Node node, Action <T> callback, QualityOfServiceProfile qualityOfServiceProfile = null) { this.callback = callback; nodeHandle = node.handle; handle = NativeMethods.rcl_get_zero_initialized_subscription(); subscriptionOptions = NativeMethods.rclcs_subscription_create_default_options(); if (qualityOfServiceProfile == null) { this.qualityOfServiceProfile = new QualityOfServiceProfile(QosProfiles.DEFAULT); } else { this.qualityOfServiceProfile = qualityOfServiceProfile; } //FIXME(sam): was not able to use a c# struct as qos profile, figure out why and replace the following hack... NativeMethods.rclcs_subscription_set_qos_profile(subscriptionOptions, (int)qualityOfServiceProfile.Profile); //TODO(sam): Figure out why System.Reflection is not available //when building with colcon/xtool on ubuntu 18.04 and mono 4.5 //MethodInfo m = typeof(T).GetTypeInfo().GetDeclaredMethod("_GET_TYPE_SUPPORT"); //IntPtr typeSupportHandle = (IntPtr)m.Invoke(null, new object[] { }); IMessageInternals msg = new T(); IntPtr typeSupportHandle = msg.TypeSupportHandle; msg.Dispose(); Utils.CheckReturnEnum(NativeMethods.rcl_subscription_init( ref handle, ref nodeHandle, typeSupportHandle, topic, subscriptionOptions)); }