コード例 #1
0
    // 发送数据
    void EmitTelemetry(SocketIOEvent obj, LiDarData hitPoint)
    {
        //UnityMainThreadDispatcher.Instance().Enqueue(() =>
        //{
        print("Attempting to Send...");
        // send only if it's not being manually driven
        // 手动模式下
        if ((Input.GetKey(KeyCode.W)) || (Input.GetKey(KeyCode.S)))
        {
            // _socket.Emit("telemetry", new JSONObject());
        }
        else
        {
            // Collect Data from the Car
            // 从车上收集信息
            Dictionary <string, string> data = new Dictionary <string, string>();
            // json数据
            // 角度
            // 图像bytes转base64字符串
            // data["image"] = Convert.ToBase64String(CameraHelper.CaptureFrame(FrontFacingCamera));
            // 添加点云数据
            // float 转 bytes
            data["Velodyne"] = Convert.ToBase64String(hitPoint.ToByteArray());

            _socket.Emit("telemetry", new JSONObject(data));
        }
        //});
    }
コード例 #2
0
    // 发送数据
    void EmitTelemetry(SocketIOEvent obj, LiDarData hitPoint)
    {
        UnityMainThreadDispatcher.Instance().Enqueue(() =>
        {
            print("Attempting to Send...");
            // send only if it's not being manually driven
            // 手动模式下
            if ((Input.GetKey(KeyCode.W)) || (Input.GetKey(KeyCode.S)))
            {
                _socket.Emit("telemetry", new JSONObject());
            }
            else
            {
                // Collect Data from the Car
                // 从车上收集信息
                Dictionary <string, string> data = new Dictionary <string, string>();
                // json数据
                // 角度
                data["steering_angle"] = _carController.CurrentSteerAngle.ToString("N4");
                data["throttle"]       = _carController.AccelInput.ToString("N4");
                data["speed"]          = _carController.CurrentSpeed.ToString("N4");

                data["Velodyne"] = Convert.ToBase64String(hitPoint.ToByteArray());

                _socket.Emit("telemetry", new JSONObject(data));
            }
        });
    }