Пример #1
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)
Пример #2
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)
Пример #3
0
def run():
    cf = conf_loader.ConfLoader("testinfo.yaml")
    prms = cf.prms['RoutingRequest_xiongan']
    print(str(prms))

    request = hmi_routing_pb2.RoutingRequest(\
        start=hmi_common_pb2.PolygonPoint(\
            x=prms['start']['x'], y=prms['start']['y'], z=prms['start']['z']),
        end=hmi_common_pb2.PolygonPoint(\
            x=prms['end']['x'], y=prms['end']['y'], z=prms['end']['z']),
        start_quaternion=common_geometry_pb2.Quaternion(\
            qx=prms['start_quaternion']['qx'], qy=prms['start_quaternion']['qy'],\
            qz=prms['start_quaternion']['qz'], qw=prms['start_quaternion']['qw']),
        end_quaternion=common_geometry_pb2.Quaternion(\
            qx=prms['end_quaternion']['qx'], qy=prms['end_quaternion']['qy'],\
            qz=prms['end_quaternion']['qz'], qw=prms['end_quaternion']['qw'])
        )

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

    print("Client request: " + str(request))

    # response = stub.StartRouting(request)

    response = stub.StartRouting(request)
    print("Greeter client received: " + str(response))

    time.sleep(2)
Пример #4
0
 def switch_control_api(self, control_switch):
     request = hmi_car_device_pb2.DeciveControlRequest(
         action=control_switch)
     #request.action.append(control_switch)
     print("Request: " + str(request))
     host_port = "127.0.0.1:" + self.random_port
     channel = grpc.insecure_channel(host_port)
     self.stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)
     time.sleep(1)
     return request
Пример #5
0
 def call_fetch_api(self, fetch_key):
     request = hmi_fetch_msg_pb2.FetchKeys()
     request.keys.append(fetch_key)
     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(5)
     response = stub.FetchSectionMsg(request)
     return response
Пример #6
0
def run_launch():
    request = hmi_launch_pb2.LaunchRequest(header=1.0)
    channel = grpc.insecure_channel("127.0.0.1:8090")
    stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)

    print("Client request: " + str(request))
    response = stub.Launch(request)
    print("Greeter client received: " + str(response))

    time.sleep(2)
Пример #7
0
 def send_ota_msg(self, msg):
     request = hmi_ota_pb2.OtaRequest()
     try:
         request.action = msg
     except Exception as e:
         print(str(e))
     channel = grpc.insecure_channel("127.0.0.1:" + self.random_port)
     stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)
     response = stub.NotiOTAClient(request)
     return response
Пример #8
0
    def test_fetch_no_ultrasonic(self):
        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)

        response = stub.FetchSectionMsg(request)
        print("Response: " + str(response))
        self.assertTrue(response.code == hmi_error_code_pb2.OK, response)
        self.assertFalse(response.HasField('ultrasonic'), response)
Пример #9
0
    def test_emergency_stop(self):
        print("Request: " )
        request = hmi_car_device_pb2.TriggerRequest(header=1.0 ,bool_flag=True)  
        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(5)
	try:
        	response = stub.TriggerEmergencyStop(request)
	except Exception,e:
    		print ('Error: err,str(Exception)',str(e))
Пример #10
0
    def test_fetch_work_state(self):
        request = hmi_fetch_msg_pb2.FetchKeys()
        request.keys.append(hmi_fetch_msg_pb2.WORK_STATE)
        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)
        self.assertTrue(response.HasField('work_state_result'), response)
        self.assertTrue(response.work_state_result.car_work_mode == hmi_collect_data_pb2.OPER_MODE, response)
Пример #11
0
 def class_init(self):
     print('class init')
     if Local_test is True:
         host_port = "127.0.0.1:9898"
     else:
         host_port = "192.168.10.6:8090"
     channel = grpc.insecure_channel(host_port)
     self.request_list = []
     self.response_list = []
     self.semaphore = threading.Semaphore(0)
     self.t_list = []
     self.__class__.stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)
     time.sleep(5)
Пример #12
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)
Пример #13
0
    def test_intervene_error(self):
        request = hmi_driving_control_pb2.InterveneRequest(
            params=global_adc_status_pb2.UserCustomMessage(
                ignore_blocked_obstacle=True))

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

        print("Client request: " + str(request))

        response = stub.Intervene(request)
        print("Client received: " + str(response))
        self.assertTrue(
            response.code == hmi_error_code_pb2.SET_GLOBAL_PARAM_ERROR)
Пример #14
0
def run():
    cf = conf_loader.ConfLoader("testinfo.yaml")
    prms = cf.prms['CalibrationValidityRequest']
    print("CalibrationValidityRequest: " + str(prms))

    request = hmi_world_pb2.CalibrationValidityRequest(type=prms['type'])

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

    print("Client request: " + str(request))

    response = stub.CheckCalibrationValidity(request)
    print("Greeter client received: " + str(response))

    time.sleep(2)
Пример #15
0
    def test_intervene(self):
        env_utils.start_parameter_server()

        request = hmi_driving_control_pb2.InterveneRequest(
            params=global_adc_status_pb2.UserCustomMessage(
                ignore_blocked_obstacle=True))

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

        print("Client request: " + str(request))

        response = stub.Intervene(request)
        print("Client received: " + str(response))
        self.assertTrue(response.code == hmi_error_code_pb2.OK)

        os.system('cyber_param list')
Пример #16
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)
Пример #17
0
    def test_disengage_feedback(self):
        """
        """
        cf = conf_loader.ConfLoader("testinfo.yaml")
        prms = cf.prms['DisengageTypeContent']
        print(str(prms))

        request = hmi_driving_control_pb2.DisengageTypeContent(
            timestamp=prms['timestamp'], type=prms['type'])

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

        print("Client request: " + str(request))

        response = stub.DisengageTypeFeedback(request)
        print("Greeter client received: " + str(response))
        self.assertTrue(response.code == hmi_error_code_pb2.OK)
        self.assertTrue(response.info == 'disengage update!')

        time.sleep(2)
Пример #18
0
def start():
    host_port = "192.168.10.6:8090"
    channel = grpc.insecure_channel(host_port)
    stub = hmi_grpc_api_pb2_grpc.HMIGrpcServiceStub(channel)
    time.sleep(5)
    return stub
Пример #19
0
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__)) + '/../proto')
sys.path.append(os.path.abspath(os.path.dirname(__file__)) + '/../python')

import unittest
import grpc
import hmi_error_code_pb2
import hmi_grpc_api_pb2_grpc
import hmi_system_control_pb2

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


class TestReboot(unittest.TestCase):
    def test_reboot(self):
        res = stub.ShutdownSystem(
            hmi_system_control_pb2.SystemControlRequest(
                type=hmi_system_control_pb2.REBOOT))
        print res
        self.assertTrue(res.code == hmi_error_code_pb2.SYSTEM_CTRL_ERROR)

    def test_shutdown(self):
        res = stub.ShutdownSystem(
            hmi_system_control_pb2.SystemControlRequest(
                type=hmi_system_control_pb2.SHUTDOWN))
        print res
        self.assertTrue(res.code == hmi_error_code_pb2.SYSTEM_CTRL_ERROR)

    def test_poweroff(self):