public void AddPublisher(IRosClient publisher) { if (Status == Status.Connected) { publisher.OnRosConnected(); } Publishers.Add(publisher); }
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); }
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); }
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); }
public RosTopic(IRosClient rosClient, string topic, string messageType) { _rosClient = rosClient; _guid = Guid.NewGuid().ToString(); Topic = topic; MessageType = messageType; Subscribe().Wait(); }
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); }
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); }
/// <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); }
/// <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)); }
/// <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)); }