def do_load(self, clear_first): if clear_first: self.match_list_box.Clear() msg = Forseti.ScheduleLoadCommand() msg.clear_first = clear_first print('Requesting load') self.lc.publish('Schedule/Load', msg.encode())
def send_schedule(self): schedule = Forseti.Schedule() for idx, match in self.matches.items(): out_match = Forseti.Match() i = 0 for alliance in [u'alliance1', u'alliance2']: for team in [u'team1', u'team2']: print(match[alliance]) out_match.team_numbers[i] = match[alliance][team] out_match.team_names[i] = \ match[alliance].get(u'{}_name'.format(team), 'Unknown Team') i += 1 out_match.match_number = idx; schedule.matches.append(out_match) schedule.num_matches = len(schedule.matches) self.lc.publish('Schedule/Schedule', schedule.encode())
def send(self, piemos_num, team): #print('Sending') msg = Forseti.ControlData() msg.TeleopEnabled = self.match.stage in ['Teleop', 'Paused'] msg.HaltRadio = False msg.AutonomousEnabled = self.match.stage == 'Autonomous' msg.RobotEnabled = self.timer.match_timer.running msg.Stage = self.match.stage msg.Time = self.match.time self.lc.publish('PiEMOS{}/Control'.format(piemos_num), msg.encode())
def get_match(self): match = Forseti.Match() self._set_match_panel(match, 0, 0) self._set_match_panel(match, 1, 2) self._set_match_panel(match, 2, 1) self._set_match_panel(match, 3, 3) try: match.match_number = int(self.match_num_ctrl.GetValue()) except ValueError: match.match_number = random.getrandbits(31) return match
def run(self): while self.stage_index < len(self.stages): time.sleep(0.3) self.check_for_stage_change() self.match.time = int(self.match_timer.time()) msg = Forseti.Time() msg.game_time_so_far = self.match_timer.time() msg.stage_time_so_far = self.stage_timer.time() msg.total_stage_time = self.current_stage().length msg.stage_name = self.current_stage().name self.lc.publish('Timer/Time', msg.encode())
def __init__(self, lcm): self.lcm = lcm subscription = self.lcm.subscribe("Match/Init", self.msg_handler) self._read_thread = threading.Thread(target=self._read_loop) self._read_thread.daemon = True self._write_thread = threading.Thread(target=self._write_loop) self._write_thread.daemon = True self._health_thread = threading.Thread(target=self._health_loop) self._health_thread.daemon = True self.startTime = time.time() self.versus_text_lock = threading.Lock() self.versusText = Forseti.VideoVersusText() self.boxvalsToFlagPos = {0:0, 1:1, 2:-1}
#!/usr/bin/env python2.7 import lcm import time #from exlcm import example_t import Forseti from httplib2 import Http import json lc = lcm.LCM("udpm://239.255.76.67:7667?ttl=1") msg = Forseti.Score() msg.gold_finalscore = -5 msg.blue_finalscore = 10 lc.publish('ScoreKeeper/Score', msg.encode()) ''' http = Http() resp = http.request('https://pioneers.berkeley.edu/match_schedule/api/match/6/', 'POST', body=json.dumps({"alliance1": {"number":1, "autonomous":0, "bonus":2, "manual":2, "penalty":0, "team1":{"number":13, "disqualifed":False}, "team2":{"number":12, "disqualified":False}},
def do_time_ctrl(self, command): msg = Forseti.TimeControl() msg.command_name = command self.lc.publish('Timer/Control', msg.encode())
def send(self, command): print('Sending', command) msg = Forseti.TimeControl() msg.command_name = command self.lc.publish('Timer/Control', msg.encode())
def _health_loop(self): while True: msg = Forseti.Health() msg.uptime = time.time() - self.startTime self.lcm.publish("VersusWriter/Health", msg.encode()) time.sleep(0.25)