def speed_from_byte(x, max=64.): #print x & 128 >> 7 sign = -(((x & 128) >> 7) * 2 - 1) if sign == -1: modulo = (~x & 127) + 1 else: modulo = x return sign * modulo * max / 127 if __name__ == "__main__": sender = grsim.grSimSender(('192.168.91.163', 20011)) tr = VIVATxRx() while True: data = tr.receive() #print data if not len(data): continue else: print data packet = sender.new_packet() packet.commands.isteamyellow = True packet.commands.timestamp = time() for i in xrange(6): c = packet.commands.robot_commands.add() c.id = i chip_angle = 45 kick = speed_from_byte(data[3 + 7 * i + 6], 10.)
from roboime.communication.rftransmission.vivatxrx import VIVATxRx if __name__ == "__main__": while True: tr = VIVATxRx() print tr.receive()