Esempio n. 1
0
    def get_servers_input(self):
        '''Server's input is stored in a ServerState object'''
        if not self.so: return
        sockdata = str()
        n_try = 0
        while True:
            try:
                # Receive server data
                sockdata, addr = self.so.recvfrom(data_size)
                try:
                    sockdata = zlib.decompress(sockdata)
                except zlib.error as e:
                    print(e)
                    continue
                try:
                    state = car_state_pb2.CarState()
                    state.ParseFromString(sockdata)
                    self.S.d = state
                    break
                except ProtoBufDecodeError as e:
                    #print len(sockdata), e
                    sockdata = sockdata.decode('utf-8')
            except socket.error as emsg:
                print('.')
            if n_try >= 10:
                n_try = 0
                print("Error count exeeded. Restarted the race on %d." %
                      self.port)
                self.shutdown()
                return False
                #print "Waiting for data on %d.............." % self.port
            if '***identified***' in sockdata:
                print("Client connected on %d.............." % self.port)
                continue
            elif '***shutdown***' in sockdata:
                print((("Server has stopped the race on %d. " +
                        "You were in %d place.") %
                       (self.port, self.S.d['racePos'])))
                self.shutdown()
                return False
            elif '***restart***' in sockdata:
                # What do I do here?
                print("Server has restarted the race on %d." % self.port)
                # I haven't actually caught the server doing this.
                self.shutdown()
                return
            elif not sockdata:  # Empty?
                n_try += 1
                continue  # Try again.

        return True
Esempio n. 2
0
sys.path.append('/opt/ros/kinetic/lib/python2.7/dist-packages')

# import rospy
import rosbag
import matplotlib.pyplot as plt

sys.path.append('/opt/deeproute/control/lib/control_common_tmp/')
sys.path.append('/opt/deeproute/planner/lib/planner_common_tmp/')
sys.path.append('/opt/deeproute/sensors/lib/sensors')
sys.path.append('/opt/deeproute/sensors/lib/python2.7/dist-packages/sensors')
import car_state_pb2
import path_pb2
import car_info_pb2
import control_command_pb2

car_state = car_state_pb2.CarState()
path = path_pb2.Path()
car_info = car_info_pb2.CarInfo()
steer_report = car_info_pb2.SteerReport()
control_command = control_command_pb2.ControlCommand()

# *********************************************************
# *********************************************************
import os

# *********************************************************
# *********************************************************
# bag = rosbag.Bag('/home/dr/data/0712_test_chongqing/down1.bag')
for filename in os.listdir('/home/dr/license_data/intersection_right_turn'):
    print filename
    out_str = filename.split(".", 1)