private void Window_Loaded(object sender, RoutedEventArgs e) { ROS.Init(new string[0], NODE_NAME); nodeHandle = new NodeHandle(); server = nodeHandle.advertiseService<TwoInts.Request, TwoInts.Response>("/add_two_ints", addition); }
/// <summary> /// Advertises a ServiceServer with specified OPTIONS /// </summary> /// <typeparam name="MReq">Request sub-srv type</typeparam> /// <typeparam name="MRes">Response sub-srv type</typeparam> /// <param name="ops">isn't it obvious?</param> /// <returns>The ServiceServer that will call the ServiceFunction on behalf of ServiceClients</returns> public ServiceServer advertiseService <MReq, MRes>(AdvertiseServiceOptions <MReq, MRes> ops) where MReq : IRosMessage, new() where MRes : IRosMessage, new() { ops.service = resolveName(ops.service); if (ops.callback_queue == null) { ops.callback_queue = Callback ?? ROS.GlobalCallbackQueue; } if (ServiceManager.Instance.advertiseService(ops)) { ServiceServer srv = new ServiceServer(ops.service, this); lock (collection.mutex) { collection.serviceservers.Add(srv); } return(srv); } throw new Exception("Something ain't right with this advertisement."); }
public void Dispose() { if (_cli != null) { _cli.shutdown(); _cli = null; } if (setServer != null) { setServer.shutdown(); setServer = null; } }
public void AdvertiseReconfigureService() { if (timeout == 0) { try { Service.waitForService(set_service_name, 1); } catch { Service.waitForService(set_service_name, timeout); } } else { Service.waitForService(set_service_name, timeout); } setServer = nh.advertiseService(set_service_name, (Reconfigure.Request req, ref Reconfigure.Request res) => { res.config = req.config; return true; }); }