public MainWindow() { InitializeComponent(); ROS.Init(new string[0], "wpf_talker"); nh = new NodeHandle(); pub = nh.advertise<Messages.std_msgs.String>("/chatter", 1, false); pubthread = new Thread(() => { int i = 0; Messages.std_msgs.String msg; while (ROS.ok && !closing) { msg = new Messages.std_msgs.String("foo " + (i++)); pub.publish(msg); Dispatcher.Invoke(new Action(() => { l.Content = "Sending: " + msg.data; }),new TimeSpan(0,0,1)); Thread.Sleep(100); } }); pubthread.Start(); }
public MainWindow() { InitializeComponent(); string[] sParam = new string[1]; //sParam[0] = "__hostname:=192.168.0.8"; sParam[0] = "__master:=http://192.168.1.108:11311"; ROS.Init(sParam, "wpf_talker"); nh = new NodeHandle(); pub = nh.advertise <Messages.std_msgs.String>("/chatter", 1, true); pubthread = new Thread(() => { int i = 0; Messages.std_msgs.String msg; while (ROS.ok && !closing) { msg = new Messages.std_msgs.String("foo " + (i++)); pub.publish(msg); Dispatcher.Invoke(new Action(() => { l.Content = "Sending: " + msg.data; }), new TimeSpan(0, 0, 1)); Thread.Sleep(100); } }); pubthread.Start(); }
public MainWindow() { InitializeComponent(); ROS.Init(new string[0], "wpf_talker"); nh = new NodeHandle(); pub = nh.advertise <Messages.std_msgs.String>("/chatter", 1, false); pubthread = new Thread(() => { int i = 0; Messages.std_msgs.String msg; while (ROS.ok && !closing) { msg = new Messages.std_msgs.String("foo " + (i++)); pub.publish(msg); Dispatcher.Invoke(new Action(() => { l.Content = "Sending: " + msg.data; }), new TimeSpan(0, 0, 1)); Thread.Sleep(100); } }); pubthread.Start(); }
public void subCallback(Messages.std_msgs.String msg) { Dispatcher.Invoke(new Action(() => { l.Content = "Receieved:\n" + msg.data; }), new TimeSpan(0, 0, 1)); }
public void subCallback(Messages.std_msgs.String msg) { Dispatcher.Invoke(new Action(() => { TimeSpan dif = DateTime.Now.Subtract(before); l.Content = "Receieved: " + msg.data + "\n" + Math.Round(dif.TotalMilliseconds, 2) + " ms";; })); before = DateTime.Now; }
public virtual void processResponse(string error, bool success) { String msg = new String(error); msg.Serialize(); byte[] buf = new byte[msg.Serialized.Length + 1]; buf[0] = (byte)(success ? 0x01 : 0x00); msg.Serialized.CopyTo(buf, 1); connection.write(buf, (uint)buf.Length, onResponseWritten, true); }
public virtual void processResponse(string error, bool success) { var msg = new Messages.std_msgs.String(error); msg.Serialized = msg.Serialize(); byte[] buf; if (success) { buf = new byte[msg.Serialized.Length + 1 + 4]; buf[0] = (byte)(success ? 0x01 : 0x00); msg.Serialized.CopyTo(buf, 5); Array.Copy(BitConverter.GetBytes(msg.Serialized.Length), 0, buf, 1, 4); } else { buf = new byte[1 + 4]; buf[0] = (byte)(success ? 0x01 : 0x00); Array.Copy(BitConverter.GetBytes(0), 0, buf, 1, 4); } connection.write(buf, buf.Length, onResponseWritten); }
public virtual async Task ProcessResponse(string error, bool success) { var msg = new Messages.std_msgs.String(error); msg.Serialized = msg.Serialize(); byte[] buf; if (success) { buf = new byte[msg.Serialized.Length + 1 + 4]; buf[0] = (byte)(success ? 0x01 : 0x00); msg.Serialized.CopyTo(buf, 5); Array.Copy(BitConverter.GetBytes(msg.Serialized.Length), 0, buf, 1, 4); } else { buf = new byte[1 + 4]; buf[0] = (byte)(success ? 0x01 : 0x00); Array.Copy(BitConverter.GetBytes(0), 0, buf, 1, 4); } await connection.WriteBlock(buf, 0, buf.Length, cancel); }
public virtual void processResponse(string error, bool success) { String msg = new String(error); msg.Serialize(); byte[] buf = new byte[msg.Serialized.Length + 1]; buf[0] = (byte) (success ? 0x01 : 0x00); msg.Serialized.CopyTo(buf, 1); connection.write(buf, (uint) buf.Length, onResponseWritten, true); }
void testCB(Messages.std_msgs.String str) { print(str.data); }