Exemplo n.º 1
0
# make a new zcm object and launch the handle thread
zcm = ZCM()
if not zcm.good():
    print "Unable to initialize zcm"
    exit()

# declare a new msg and populate it
msg = example_t()
msg.timestamp = 10

# set up a subscription on channel "TEST"
subs = zcm.subscribe("TEST", example_t, handler)

# publish a message
zcm.publish("TEST", msg)

# wait a second
time.sleep(1)

# publish another
zcm.publish("TEST", msg)

# handle incoming message
zcm.handle()

# clean up
zcm.unsubscribe(subs)

# notify user of success
print success
Exemplo n.º 2
0
# make a new zcm object and launch the handle thread
zcm = ZCM("ipc")
if not zcm.good():
    print "Unable to initialize zcm"
    exit()

# declare a new msg and populate it
msg = example_t()
msg.timestamp = 10

# set up a subscription on channel "TEST"
subs = zcm.subscribe("TEST", example_t, handler)

# publish a message
zcm.publish("TEST", msg)

# wait a second
time.sleep(1)

# publish another
zcm.publish("TEST", msg)

# handle incoming message
zcm.handle()

# clean up
zcm.unsubscribe(subs)

# notify user of success
print success
Exemplo n.º 3
0

def handler(channel, msg):
    print "Received message on channel: " + channel
    assert msg.pod == "Cornell"


# create UDP zcm
zcm = ZCM("udpm://10.0.0.4:7777?ttl=64")

if not zcm.good():
    print "Unable to initialize zcm"
    exit()

# declare a new msg and populate it
msg = pto_t()
msg.state = 0

# set up a subscription on channel "TEST"
subs = zcm.subscribe("TEST", otp_t(), handler)

# create pub and sub threads
sub = subThread()
pub = pubThread()

# start pub and sub threads
sub.start()
pub.start()

zcm.unsubscribe()