public void MessageReceived(LCM.LCM.LCM lcm, string channel, LCM.LCM.LCMDataInputStream dins) { Debug.Log("RECV: " + channel); if (channel == "EXAMPLE") { // forseti2.health msg = new forseti2.health(dins); // String output = "CLCM received message of the type forseti2_health:\n"; // output+="msg.header.seq=\t" + msg.header.seq + "\n"; // output+="msg.header.time=\t" + msg.header.time + "\n"; // output+="msg.uptime=\t"+msg.uptime+"\n"; // Debug.Log (output); // // forseti2.health response = new forseti2.health(); // response.header = new forseti2.header(); // response.header.seq = seq++; // TimeSpan span = DateTime.Now - new DateTime(1970, 1, 1); // response.header.time = span.Ticks*100; // response.uptime = Time.realtimeSinceStartup; // lcm.Publish("unity/health", response); exlcm.example_t msg = new exlcm.example_t(dins); String message = "CLCM Received message of the type example_t:\n "; message += String.Format(" timestamp = {0:D}", msg.timestamp); message += String.Format(" position = ({0:N}, {1:N}, {2:N})\n ", msg.position[0], msg.position[1], msg.position[2]); message += String.Format(" orientation = ({0:N}, {1:N}, {2:N}, {3:N})\n", msg.orientation[0], msg.orientation[1], msg.orientation[2], msg.orientation[3]); message += (" ranges = [ "); for (int i = 0; i < msg.num_ranges; i++) { Console.Write(" {0:D}", msg.ranges[i]); if (i < msg.num_ranges - 1) { Console.Write(", "); } } message += (" ]\n"); message += (" name = '" + msg.name + "'\n"); message += (" enabled = '" + msg.enabled + "'\n"); Debug.Log(message); } }
public void MessageReceived(LCM.LCM.LCM lcm, string channel, LCM.LCM.LCMDataInputStream dins) { Debug.Log ("RECV: " + channel); if (channel == "EXAMPLE") { // forseti2.health msg = new forseti2.health(dins); // String output = "CLCM received message of the type forseti2_health:\n"; // output+="msg.header.seq=\t" + msg.header.seq + "\n"; // output+="msg.header.time=\t" + msg.header.time + "\n"; // output+="msg.uptime=\t"+msg.uptime+"\n"; // Debug.Log (output); // // forseti2.health response = new forseti2.health(); // response.header = new forseti2.header(); // response.header.seq = seq++; // TimeSpan span = DateTime.Now - new DateTime(1970, 1, 1); // response.header.time = span.Ticks*100; // response.uptime = Time.realtimeSinceStartup; // lcm.Publish("unity/health", response); exlcm.example_t msg = new exlcm.example_t(dins); String message = "CLCM Received message of the type example_t:\n "; message+=String.Format(" timestamp = {0:D}", msg.timestamp); message+=String.Format(" position = ({0:N}, {1:N}, {2:N})\n ", msg.position[0], msg.position[1], msg.position[2]); message+=String.Format(" orientation = ({0:N}, {1:N}, {2:N}, {3:N})\n", msg.orientation[0], msg.orientation[1], msg.orientation[2], msg.orientation[3]); message+=(" ranges = [ "); for (int i = 0; i < msg.num_ranges; i++){ Console.Write(" {0:D}", msg.ranges[i]); if (i < msg.num_ranges-1) Console.Write(", "); } message+=(" ]\n"); message+=(" name = '" + msg.name + "'\n"); message+=(" enabled = '" + msg.enabled + "'\n"); Debug.Log (message); } }
// Update is called once per frame void Update () { t++; if (t > 60){ exlcm.example_t msg = new exlcm.example_t(); TimeSpan span = DateTime.Now - new DateTime(1970, 1, 1); msg.timestamp = span.Ticks * 100; msg.position = new double[] { 1, 2, 3 }; msg.orientation = new double[] { 1, 0, 0, 0 }; msg.num_ranges = 15; msg.ranges = new short[msg.num_ranges]; for (int i = 0; i < msg.num_ranges; i++) { msg.ranges[i] = (short) i; } msg.name = "example string"; msg.enabled = true; myLCM.Publish("EXAMPLE", msg); Debug.Log("update" + Time.time); t=0; } }
// Update is called once per frame void Update() { t++; if (t > 60) { exlcm.example_t msg = new exlcm.example_t(); //Debug.Log("publish update"); TimeSpan span = DateTime.Now - new DateTime(1970, 1, 1); msg.timestamp = span.Ticks * 100; msg.position = new double[] { 1, 2, 3 }; msg.orientation = new double[] { 1, 0, 0, 0 }; msg.num_ranges = 15; msg.ranges = new short[msg.num_ranges]; for (int i = 0; i < msg.num_ranges; i++) { msg.ranges[i] = (short)i; } msg.name = "example string"; msg.enabled = true; myLCM.Publish("EXAMPLE", msg); t = 0; } }