private void Run() { _ws = new WebSocket(_host + ":" + _port); _ws.OnMessage += (sender, e) => OnMessage(e.Data); _ws.Connect(); foreach (var p in _subscribers) { _ws.Send(ROSBridgeMsg.Subscribe(GetMessageTopic(p), GetMessageType(p))); Debug.Log("Sending " + ROSBridgeMsg.Subscribe(GetMessageTopic(p), GetMessageType(p))); } foreach (var p in _publishers) { _ws.Send(ROSBridgeMsg.Advertise(GetMessageTopic(p), GetMessageType(p))); Debug.Log("Sending " + ROSBridgeMsg.Advertise(GetMessageTopic(p), GetMessageType(p))); } while (true) { Thread.Sleep(10000); } }
public void CallService(string service, string args) { if (_ws != null) { var s = ROSBridgeMsg.CallService(service, args); Debug.Log("Sending " + s); _ws.Send(s); } }
public void Publish(string topic, ROSBridgeMsg msg) { if (_ws != null) { var s = ROSBridgeMsg.Publish(topic, msg.ToYAMLString()); //Debug.Log ("Sending " + s); _ws.Send(s); } }
/** * Disconnect from the remote ros environment. */ public void Disconnect() { _myThread.Abort(); foreach (var p in _subscribers) { _ws.Send(ROSBridgeMsg.UnSubscribe(GetMessageTopic(p))); } //Debug.Log ("Sending " + ROSBridgePacket.unSubscribe(getMessageTopic(p))); foreach (var p in _publishers) { _ws.Send(ROSBridgeMsg.UnAdvertise(GetMessageTopic(p))); } //Debug.Log ("Sending " + ROSBridgePacket.unAdvertise (getMessageTopic(p))); _ws.Close(); }
public static void callBack(ROSBridgeMsg msg) { }
private static void Update(Type t, ROSBridgeMsg msg) { t.GetMethod("CallBack", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Invoke(null, new object[] { msg }); }
public RenderTask(Type subscriber, string topic, ROSBridgeMsg msg) { _subscriber = subscriber; _topic = topic; _msg = msg; }