Example #1
0
def send_distance():
    while True:
        distance = (int(pi2go.getDistance() * 10)) / 10.0
        communication.send_udp_unicast_message("127.0.0.1", 38235,
                                               str(distance))
        print "Sent distance: " + str(distance) + " at: %f " % time.time()
        time.sleep(0.1)
Example #2
0
#!/usr/bin/python

# import socket
# import subprocess
import constants as c
# import time
import communication as com


com_set = [108, 111, 110, 102, 113]
auto_set = [112, 107, 104, 109, 102]


def get_addr(id):
    return '192.168.178.' + str(id)

for id in com_set:
    print(get_addr(id))
    com.send_udp_unicast_message(get_addr(id), c.PORT, c.COMMAND_TYPE + " " + c.VALUE_TYPE_COM)

for id in auto_set:
    com.send_udp_unicast_message(get_addr(id), c.PORT, c.COMMAND_TYPE + " " + c.VALUE_TYPE_AUTO)
Example #3
0
        if message == '':
            print bcolors.FAIL + 'No message sent so far!' + bcolors.ENDC
        else:
            # everything should be valid...
            # to all...
            if last_receiver == 'all':
                com.send_broadcast_message(c.PORT, message)

            # to all communicating bots
            elif last_receiver == 'com_bots':
                for target_id in range(len(bot_type)):
                    # print str(target_id) + " " + str(bot_type[target_id])
                    if bot_type[target_id] == c.VALUE_TYPE_COM:
                        target_ip = c.SUBNET_IP + str(c.TEAM_START + target_id)
                        # print "actually sending sth.! to " + target_ip
                        com.send_udp_unicast_message(target_ip, c.PORT,
                                                     message)

            # to all autonomous bots
            elif last_receiver == 'auto_bots':
                for target_id in range(len(bot_type)):
                    if bot_type[target_id] == c.VALUE_TYPE_AUTO:
                        target_ip = c.SUBNET_IP + str(c.TEAM_START + target_id)
                        # print "actually sending sth.! to " + target_ip
                        com.send_udp_unicast_message(target_ip, c.PORT,
                                                     message)
                        time.sleep(c.WAIT_SEND)

            # to one bot
            else:
                target_ip = c.SUBNET_IP + last_receiver
                com.send_udp_unicast_message(target_ip, c.PORT, message)
def send_distance():
	while True:
		distance = (int(pi2go.getDistance()*10))/10.0
		communication.send_udp_unicast_message("127.0.0.1", 38235, str(distance))
		print "Sent distance: " + str(distance) + " at: %f " %time.time()
		time.sleep(0.1)
Example #5
0
 if message == '':
     print bcolors.FAIL + 'No message sent so far!' + bcolors.ENDC
 else:
     # everything should be valid...
     # to all...
     if last_receiver == 'all':
         com.send_broadcast_message(c.PORT, message)
         
     # to all communicating bots
     elif last_receiver == 'com_bots':
         for target_id in range(len(bot_type)):
             # print str(target_id) + " " + str(bot_type[target_id])
             if bot_type[target_id] == c.VALUE_TYPE_COM:
                 target_ip = c.SUBNET_IP + str(c.TEAM_START + target_id)
                 # print "actually sending sth.! to " + target_ip
                 com.send_udp_unicast_message(target_ip, c.PORT, message)
                 
     # to all autonomous bots            
     elif last_receiver == 'auto_bots':
         for target_id in range(len(bot_type)):
             if bot_type[target_id] == c.VALUE_TYPE_AUTO:
                 target_ip = c.SUBNET_IP + str(c.TEAM_START + target_id)
                 # print "actually sending sth.! to " + target_ip
                 com.send_udp_unicast_message(target_ip, c.PORT, message)
                 time.sleep(c.WAIT_SEND)
                 
     # to one bot
     else:
         target_ip = c.SUBNET_IP + last_receiver
         com.send_udp_unicast_message(target_ip, c.PORT, message)
     # just for making the output a bit prettier