#functions to be used in class def word(l, h): """ Given a low and high bit, converts the number back into a word. """ return (h << 8) + l #checksum method, receives array def checksum(arr): return 255 - ((sum(arr)) % 256) #little-endian method def le(h): h &= 0xffff return [h & 0xff, h >> 8] #example code if __name__ == "__main__": from std_msgs import String from uros import NodeHandle msg = String() msg.data = 'HiItsMeMario' node = NodeHandle(2, 115200) while True: node.publish('greet', msg)
from std_msgs import String from uros import NodeHandle import time def cb(msg): print(msg.data) node = NodeHandle(2, 57600) node.subscribe('chatter', String, cb) node.subscribe('greet', String, cb)
from std_msgs import String from uros import NodeHandle import time def cb(msg): print(msg.data) msgp = String() msgp.data = "ItsMeLuigi" node = NodeHandle(2, 57600) node.subscribe("chatter", String, cb) while True: node.publish("groop", msgp) time.sleep(1)
# functions to be used in class def word(l, h): """ Given a low and high bit, converts the number back into a word. """ return (h << 8) + l # checksum method, receives array def checksum(arr): return 255 - ((sum(arr)) % 256) # little-endian method def le(h): h &= 0xFFFF return [h & 0xFF, h >> 8] # example code if __name__ == "__main__": from std_msgs import String from uros import NodeHandle msg = String() msg.data = "HiItsMeMario" node = NodeHandle(2, 115200) while True: node.publish("greet", msg)
from std_msgs import String from uros import NodeHandle import time def cb(msg): print(msg.data) node = NodeHandle(2, 57600) node.subscribe("chatter", String, cb) node.subscribe("greet", String, cb)
from std_msgs import String from uros import NodeHandle import time def cb(msg): print(msg.data) msgp = String() msgp.data = 'ItsMeLuigi' node = NodeHandle(2, 57600) node.subscribe('chatter', String, cb) while True: node.publish('groop', msgp) time.sleep(1)