Ejemplo n.º 1
0
    def test_fetch_device(self):
        env_utils.play_record('chassis.record')
        request = hmi_fetch_msg_pb2.FetchKeys()
        request.keys.append(hmi_fetch_msg_pb2.DEVICE)
        print("Request: " + str(request))

        host_port = "127.0.0.1:" + self.random_port
        channel = grpc.insecure_channel(host_port)
        stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)

        response = stub.FetchSectionMsg(request)
        print("Response: " + str(response))
        self.assertTrue(response.code == hmi_error_code_pb2.OK, response)
        device = response.device
        self.assertTrue(device.HasField('timestamp'), device)
        self.assertTrue(device.HasField('dump_energy'), device)
        self.assertTrue(device.HasField('door'), device)
        self.assertTrue(device.HasField('head_lamp'), device)
        self.assertTrue(device.HasField('front_lamp'), device)
        self.assertTrue(device.HasField('emergency_lamp'), device)
        self.assertTrue(device.HasField('courtesy_lamp'), device)
        self.assertTrue(device.HasField('air_condition'), device)
        self.assertTrue(device.HasField('driving_range'), device)
        self.assertTrue(device.HasField('server_init_timestamp'), device)
        self.assertTrue(device.HasField('vin'), device)
        self.assertTrue(device.HasField('charge_state'), device)
        self.assertTrue(device.HasField('parking_brake'), device)
        self.assertTrue(device.HasField('carid'), device)
        self.assertTrue(device.HasField('gear_location'), device)
Ejemplo n.º 2
0
 def test_fetch_low_illumination(self):
     env_utils.play_record('perception_obstacles.record')
     # env_utils.play_record('ultrasonic.record')
     request = hmi_fetch_msg_pb2.FetchKeys()
     request.keys.append(hmi_fetch_msg_pb2.OBSTACLES)
     print("Request: " + str(request))
     host_port = "127.0.0.1:" + self.random_port
     channel = grpc.insecure_channel(host_port)
     stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)
     time.sleep(15)
     response = stub.FetchSectionMsg(request)
     # print("Response: " + str(response))
     self.assertTrue(response.code == hmi_error_code_pb2.OK, response)
     self.assertTrue(response.HasField('obstacles'), response)
     word_obstacles = response.obstacles
     self.assertTrue(word_obstacles.HasField('low_illumination'), word_obstacles)
     self.assertTrue(word_obstacles.HasField('timestamp'), word_obstacles)
     print("low_illumination: " + str(word_obstacles.low_illumination))
     obstacles_list = word_obstacles.obstacles
     obstacle = obstacles_list[0]
     self.assertTrue(obstacle.HasField('id'), obstacle)
     self.assertTrue(obstacle.HasField('type'), obstacle)
     self.assertTrue(obstacle.HasField('heading'), obstacle)
     self.assertTrue(obstacle.HasField('position'), obstacle)
     self.assertTrue(obstacle.HasField('length'), obstacle)
     self.assertTrue(obstacle.HasField('width'), obstacle)
     self.assertTrue(obstacle.HasField('height'), obstacle)
Ejemplo n.º 3
0
 def setUp(self):
     self.random_port = str(random.randint(8000,9000))
     flags = {
         'hmi_server_host': '127.0.0.1',
         'hmi_server_port': self.random_port,
         'hmi_camera_params_path': os.path.abspath(os.path.dirname(__file__)) + '/params',
     }
     env_utils.start_hmi_server(flags)
     env_utils.play_record('channel_test.record')
Ejemplo n.º 4
0
    def test_fetch_ultrasonic(self):
        env_utils.play_record('ultrasonic.record')
        request = hmi_fetch_msg_pb2.FetchKeys()
        request.keys.append(hmi_fetch_msg_pb2.ULTRASONIC)
        print("Request: " + str(request))

        channel = grpc.insecure_channel("127.0.0.1:8090")
        stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)

        response = stub.FetchSectionMsg(request)
        print("Response: " + str(response))
        self.assertTrue(response.code == hmi_error_code_pb2.OK, response)
        self.assertFalse(response.HasField('ultrasonic'), response)
Ejemplo n.º 5
0
    def test_fetch_ultrasonic(self):
        env_utils.play_record('ultrasonic.record')
        request = hmi_fetch_msg_pb2.FetchKeys()
        request.keys.append(hmi_fetch_msg_pb2.ULTRASONIC)
        print("Request: " + str(request))
        host_port = "127.0.0.1:" + self.random_port
        channel = grpc.insecure_channel(host_port)
        stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)

        try:
            response = stub.FetchSectionMsg(request)
        except Exception as e:
            print(str(e))
        print("Response: " + str(response))

        self.assertTrue(response.code == hmi_error_code_pb2.OK, response)
        self.assertTrue(response.HasField('ultrasonic'), response)
        self.assertTrue(len(response.ultrasonic.ranges) == 16, response)