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)); }
/// <summary> /// Initializes a new instance of the <see cref="rclcs.rcl_publisher"/> class. /// </summary> /// <param name="_node">Node.</param> /// <param name="_type_support">Type support.</param> /// <param name="_topic_name">Topic name.</param> /// <param name="_options">Options.</param> public rcl_publisher(Node _node, rosidl_message_type_support_t _type_support, string _topic_name, rcl_publisher_options_t _options) { this.native_node = _node.NativeNode; this.topic_name = _topic_name; this.type_support = _type_support; this.options = _options; native_handle = rcl_get_zero_initialized_publisher(); rcl_publisher_init(ref native_handle, ref native_node, ref type_support, topic_name, ref options); }
public Publisher(string topic, Node node) { nodeHandle = node.handle; handle = NativeMethods.rcl_get_zero_initialized_publisher(); rcl_publisher_options_t publisherOptions = NativeMethods.rcl_publisher_get_default_options(); //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[] { }); IRclcsMessage msg = new T(); IntPtr typeSupportHandle = msg.TypeSupportHandle; Utils.CheckReturnEnum(NativeMethods.rcl_publisher_init( ref handle, ref nodeHandle, typeSupportHandle, topic, ref publisherOptions)); }
extern static int rcl_publisher_fini(ref rcl_publisher_t publisher, ref rcl_node_t node);
extern static int rcl_publisher_init(ref rcl_publisher_t publisher, ref rcl_node_t node, ref rosidl_message_type_support_t type_support, string topic_name, ref rcl_publisher_options_t options);
extern static rcl_publisher_options_t rcl_publisher_get_options(ref rcl_publisher_t publisher);
extern static string rcl_publisher_get_topic_name(ref rcl_publisher_t publisher);
extern static int rcl_publish(ref rcl_publisher_t publisher, [In] ValueType ros_message);