1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
import lcm.lcm.*;
import java.io.*;
import lcmtypes.*;
public class TemperatureDisplay implements LCMSubscriber
{
public void messageReceived(LCM lcm, String channel, LCMDataInputStream ins)
{
try {
temperature_t temp = new temperature_t(ins);
System.out.println("The temperature is: "+temp.deg_celsius);
} catch (IOException ex) {
System.out.println("Error decoding temperature message: "+ex);
}
}
public static void main(String args[])
{
LCM myLCM = LCM.getSingleton();
myLCM.subscribe("HALLWAY_TEMPERATURE", new TemperatureDisplay());
// Sleep forever: if we quit, so will the LCM thread.
while (true)
{
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
}
}
}
|