Exemple #1
0
        public async Task <RosServiceResponse> CallServiceAsync(RosServiceCall service)
        {
            // Put the service into the queue
            var guid = Guid.NewGuid().ToString();

            _callQueue.Add(guid, service);

            // Send the request
            await WebSocket.SendAsync(service.Serialize(guid), WebSocketMessageType.Text, true, CancellationToken.None);

            // Wait for the response to be filled in
            var timeout = 0;

            while (service.Response == null)
            {
                timeout += 10;
                await Task.Delay(10);

                if (timeout >= 3000)
                {
                    return(null);
                }
            }

            return(service.Response);
        }
Exemple #2
0
        public async Task SetParamValueAsync(string paramName, object param)
        {
            var service = new RosServiceCall("/rosapi/set_param")
            {
                Arguments = new Dictionary <string, object> {
                    { "name", paramName }, { "value", "\"" + param + "\"" }
                }
            };

            await CallServiceAsync(service);
        }
Exemple #3
0
        public async Task <object> GetParamValueAsync(string paramName)
        {
            var service = new RosServiceCall("/rosapi/get_param")
            {
                Arguments = new Dictionary <string, object> {
                    { "name", paramName }
                }
            };
            var result = await CallServiceAsync(service);

            return(result.TryGetValuesAsDictionary().FirstOrDefault().Value);
        }