Esempio n. 1
0
        public bool applyExtrinsics(ExtrinsicsParameters extrinsics)
        {
            if (extrinsics == null)
            {
                return(false);
            }
            Matrix4x4?transRot = new Matrix4x4();

            transRot = Utils.FloatArrayToMatrix4x4(extrinsics.matrix);
            if (transRot == null)
            {
                return(false);
            }

            // Units convertion from militers (Natar) to meter (Unity)
            Matrix4x4 scale = Matrix4x4.Scale(new Vector3(0.001f, 0.001f, 0.001f));

            if (ReverseYAxis)
            {
                scale = Matrix4x4.Scale(new Vector3(0.001f, -0.001f, 0.001f));
            }
            ;

            transRot = scale * transRot;

            transform.localPosition = Utils.ExtractTranslation((Matrix4x4)transRot);
            transform.localRotation = Utils.ExtractRotation((Matrix4x4)transRot);
            this.currentTR          = (Matrix4x4)transRot;
            return(true);
        }
Esempio n. 2
0
 public void init()
 {
     if (LiveUpdate)
     {
         if (redisSubscriber != null)
         {
             redisSubscriber.Unsubscribe(Key, "unsub");
         }
         redisSubscriber = new Subscriber(redis);
         redisSubscriber.Subscribe(OnExtrinsicsReceived, Key, "unsub");
         this.state = ServiceStatus.WORKING;
     }
     else
     {
         eParameters = load();
         if (applyExtrinsics(eParameters))
         {
             this.state = ServiceStatus.WORKING;
         }
         else
         {
             this.state = ServiceStatus.CONNECTED;
         }
     }
 }
Esempio n. 3
0
        private void OnExtrinsicsReceived(string channelName, byte[] message)
        {
            if (channelName == "unsub")
            {
                redisSubscriber.Unsubscribe(Key, "unsub");
            }

            string extrinsics = Utils.ByteToString(message);

            if (extrinsics == "")
            {
                return;
            }
            eParameters           = Utils.JSONTo <ExtrinsicsParameters>(extrinsics);
            extrinsicsNeedsUpdate = true;
            //applyExtrinsics(parameters);
        }