コード例 #1
0
 public void AddPublisher(IRosClient publisher)
 {
     if (Status == Status.Connected)
     {
         publisher.OnRosConnected();
     }
     Publishers.Add(publisher);
 }
コード例 #2
0
ファイル: RosChannelReader.cs プロジェクト: KIT-ISAS/iviz
        public static async ValueTask <RosChannelReader> CreateReaderAsync(this IRosClient client, string topic,
                                                                           CancellationToken token = default)
        {
            var writer = new RosChannelReader();
            await writer.StartAsync(client, topic, token);

            return(writer);
        }
コード例 #3
0
ファイル: RosChannelReader.cs プロジェクト: KIT-ISAS/iviz
        public static async ValueTask <RosChannelReader <T> > CreateReaderAsync <T>(this IRosClient client, string topic,
                                                                                    CancellationToken token = default)
            where T : IMessage, IDeserializable <T>, new()
        {
            var writer = new RosChannelReader <T>();
            await writer.StartAsync(client, topic, token);

            return(writer);
        }
コード例 #4
0
ファイル: RosChannelReader.cs プロジェクト: KIT-ISAS/iviz
        public override void Start(IRosClient client, string topic)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            subscriberId    = client.Subscribe(topic, Callback, out subscriber);
            subscriberToken = subscriber.CancellationToken.Register(OnSubscriberDisposed);
        }
コード例 #5
0
        public RosTopic(IRosClient rosClient, string topic, string messageType)
        {
            _rosClient = rosClient;
            _guid      = Guid.NewGuid().ToString();

            Topic       = topic;
            MessageType = messageType;

            Subscribe().Wait();
        }
コード例 #6
0
ファイル: WillyMonitorService.cs プロジェクト: Stevenvdv/WTGD
        public WillyRosService(IConfiguration configuration, IRosClient rosClient, IHubContext <GpsHub> gpsHubContext, IHubContext <SonarHub> sonarHubContext)
        {
            RosClient = rosClient;

            _configuration   = configuration;
            _gpsHubContext   = gpsHubContext;
            _sonarHubContext = sonarHubContext;
            _running         = true;

            // A continuous task keeps the ROS connection in a good state
            Task.Run(ClientStateTask);
        }
コード例 #7
0
ファイル: RosChannelReader.cs プロジェクト: KIT-ISAS/iviz
        public override async Task StartAsync(IRosClient client, string topic, CancellationToken token = default)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (subscriber != null)
            {
                throw new InvalidOperationException("Channel has already been started!");
            }

            var(newId, newSubscriber) = await client.SubscribeAsync <T>(topic, Callback, token : token);

            subscriberId    = newId;
            subscriber      = newSubscriber;
            subscriberToken = subscriber.CancellationToken.Register(OnSubscriberDisposed);
        }
コード例 #8
0
ファイル: RosChannelReader.cs プロジェクト: KIT-ISAS/iviz
 /// <summary>
 /// Initializes the channel, and calls <see cref="Start"/> with the arguments.
 /// </summary>
 /// <param name="client">A connected IRosClient</param>
 /// <param name="topic">The topic to listen to</param>
 public RosChannelReader(IRosClient client, string topic)
 {
     Start(client, topic);
 }
コード例 #9
0
ファイル: RosChannelReader.cs プロジェクト: KIT-ISAS/iviz
 /// <summary>
 /// Creates a channel reader for the given topic and message type.
 /// </summary>
 /// <param name="client">The ROS client</param>
 /// <param name="topic">The topic name</param>
 /// <typeparam name="T">The message type</typeparam>
 /// <returns>The channel reader</returns>
 public static RosChannelReader <T> CreateReader <T>(this IRosClient client, string topic)
     where T : IMessage, IDeserializable <T>, new()
 {
     return(new RosChannelReader <T>(client, topic));
 }
コード例 #10
0
ファイル: RosChannelReader.cs プロジェクト: KIT-ISAS/iviz
 /// <summary>
 /// Creates a channel reader for the given topic. Returns whatever message type is published there.
 /// </summary>
 /// <param name="client">The ROS client</param>
 /// <param name="topic">The topic name</param>
 /// <returns>The channel reader</returns>
 public static RosChannelReader CreateReader(this IRosClient client, string topic)
 {
     return(new RosChannelReader(client, topic));
 }