Ejemplo n.º 1
0
        public MAvatarDescription SetupRetargeting(MAvatarPosture globalTarget)
        {
            Console.WriteLine("\nSetting up retargeting");
            string id = globalTarget.AvatarID;
            Dictionary <MJointType, string> joint_map = new Dictionary <MJointType, string>();
            Dictionary <string, string>     _children = new Dictionary <string, string>();

            foreach (MJoint j in globalTarget.Joints)
            {
                if (j.Type != MJointType.Undefined)
                {
                    joint_map.Add(j.Type, j.ID);
                }
                if (j.Parent != null && j.Parent != "")
                {
                    if (_children.ContainsKey(j.Parent))
                    {
                        // parent has multiple children and thus cannot be auto - aligned
                        _children[j.Parent] = "";
                    }
                    else
                    {
                        _children.Add(j.Parent, j.ID);
                    }
                }
            }
            this.children.Add(id, _children);
            if (joint_mappings.ContainsKey(id))
            {
                Console.WriteLine("Warning: Skeleton alread existing under ID " + id);
                this.joint_mappings[id] = joint_map;
            }
            else
            {
                this.joint_mappings.Add(id, joint_map);
            }
            if (basePostures.ContainsKey(id))
            {
                this.basePostures[id] = globalTarget;
            }
            else
            {
                this.basePostures.Add(id, globalTarget);
            }
            MAvatarDescription desc = IntermediateSkeleton.GenerateFromDescriptionFile(id);

            this.skeleton.InitializeAnthropometry(desc);

            Console.WriteLine("Scaling Skeleton");
            ((RJoint)this.skeleton.GetRoot(id)).ScaleSkeleton(globalTarget, joint_map);
            Console.WriteLine("Initializing Zero Posture");
            this.skeleton.GetRoot(id).SetAvatarPostureValues(null);
            Console.WriteLine("Setting Base Reference");
            ((RJoint)this.skeleton.GetRoot(id)).SetBaseReference(globalTarget);


            Console.WriteLine("Retargeting Successfully set up");

            return(desc);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Basic initialization methid
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            //Execute instructions on main thread
            this.ExecuteOnMainThread(() =>
            {
                //Call the base class initialization -> Retargeting is also set up in there
                base.Initialize(avatarDescription, properties);

                this.MotionType = "idle";
                this.animator   = this.GetComponent <Animator>();

                //Set animation mode to always animate (even if not visible)
                this.animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                this.animator.enabled     = false;
                this.Name = "UnityIdleMMU";


                //Get the initial posture
                this.animator.Update(0.01f);

                //Get the initial posture
                this.initialPosture = this.GetZeroPosture();
            });
            return(new MBoolResponse(true));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to setup the actual retargeting
        /// </summary>
        protected virtual void SetupRetargeting()
        {
            //Only do the retargeting setup if not happened in before
            if (!setupRetargeting)
            {
                setupRetargeting = true;
                // find and load retargeting configuration file
                //Create a unique id for the avatar (only valid in the current session -> otherwise UUID required)
                string id = UnitySceneAccess.CreateAvatarID();

                //Only load the configuration if defined
                if (LoadRetargetingConfiguration)
                {
                    if (!System.IO.File.Exists(Application.dataPath + "/" + this.ConfigurationFilePath))
                    {
                        Debug.LogError($"Problem setting up retargeting: The required file: {Application.dataPath + "/" + this.ConfigurationFilePath} is not available");
                        return;
                    }

                    string skelConf = System.IO.File.ReadAllText(Application.dataPath + "/" + this.ConfigurationFilePath);



                    MAvatarPosture p = MMICSharp.Common.Communication.Serialization.FromJsonString <MAvatarPosture>(skelConf);//JsonConvert.DeserializeObject<MAvatarPosture>(skelConf);
                    p.AvatarID = id;

                    this.SetupRetargeting(id, p);
                    this.AssignPostureValues(retargetingService.RetargetToIntermediate(p));
                }

                //If not defined use the global posture
                else
                {
                    this.SetupRetargeting(id);
                }

                MAvatarDescription avatarDescription = this.GetSkeletonAccess().GetAvatarDescription(id);

                //Create a new MAvatar (the representation within MMI framework)
                MAvatarPostureValues zeroPosture = this.GetSkeletonAccess().GetCurrentPostureValues(id);

                //Create the avatar
                this.MAvatar = new MAvatar()
                {
                    Name          = this.name,
                    ID            = id,
                    Description   = avatarDescription,
                    PostureValues = zeroPosture,
                    Properties    = new Dictionary <string, string>(),
                    SceneObjects  = new List <string>()
                };

                //Add the avatar to the scene access
                UnitySceneAccess.AddAvatar(this.MAvatar);

                Debug.Log("Retargeting successfully set up");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initialization method -> just call the base class
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            MBoolResponse res = base.Initialize(avatarDescription, properties);

            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);

            return(res);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates a default MAvatarPosture based on the ISDescription class.
        /// This function is to be used to get an initial MAvatarPosture in
        /// zero posture, which is fixed up to the scale.
        /// </summary>
        /// <param name="avatarID"></param>
        /// <returns></returns>
        public static MAvatarDescription GenerateFromDescriptionFile(string avatarID)
        {
            MAvatarDescription desc = new MAvatarDescription
            {
                AvatarID = avatarID
            };

            List <MJoint> MJointList = ISDescription.GetDefaultJointList();

            desc.ZeroPosture = new MAvatarPosture(desc.AvatarID, MJointList);
            return(desc);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initialization method -> just call the base class
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            MBoolResponse res = base.Initialize(avatarDescription, properties);

            // Added new intermediate skeleton representation.
            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);

            this.constraintManager = new ConstraintManager(this.SceneAccess);

            return(res);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Basic initialization method. In order to setup the retargeting the base class method should be executed by the child class.
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public virtual MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            //Assign the avatar description
            this.AvatarDescription = avatarDescription;

            //Setup the retargeting already in the base classe
            this.SetupRetargeting(AvatarDescription.AvatarID);

            //Assign the skeleton access
            this.SkeletonAccess = this.GetSkeletonAccess();

            return(new MBoolResponse(true));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initialization method -> just call the base class
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            MBoolResponse response = base.Initialize(avatarDescription, properties);

            //Setuo the skeleton access
            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);

            //Create a new constraint manager
            this.constraintManager = new ConstraintManager(this.SceneAccess);

            return(response);
        }
Ejemplo n.º 9
0
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            base.Initialize(avatarDescription, properties);

            //Setuo the skeleton access
            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);


            //Initial rotations
            this.initialHeadRotation = SkeletonAccess.GetLocalJointRotation(AvatarDescription.AvatarID, MJointType.HeadJoint);
            this.initialNeckRotation = SkeletonAccess.GetLocalJointRotation(AvatarDescription.AvatarID, MJointType.C4C5Joint);

            return(new MBoolResponse(true));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Basic initialization function
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            //Call the base class
            base.Initialize(avatarDescription, properties);

            this.avatarDescription = avatarDescription;
            this.ActiveHands       = new List <HandContainer>();

            // Added new intermediate skeleton representation.
            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);

            this.constraintManager = new ConstraintManager(this.SceneAccess);

            return(new MBoolResponse(true));
        }
        /// <summary>
        /// Basic initialization of a MMMU
        /// </summary>
        /// <param name="mmuID"></param>
        /// <param name="sessionID"></param>
        public virtual MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties, string mmuID, string sessionID)
        {
            SessionContent sessionContent = null;
            AvatarContent  avatarContent  = null;

            MBoolResponse sessionResult = SessionData.GetContents(sessionID, out sessionContent, out avatarContent);

            this.skeletonAccess = new IntermediateSkeleton();
            this.skeletonAccess.InitializeAnthropometry(avatarDescription);

            //Skip if invalid session result
            if (!sessionResult.Successful)
            {
                return(sessionResult);
            }

            try
            {
                //Update the access time
                sessionContent.UpdateLastAccessTime();

                //Get the corresponding MMU
                IMotionModelUnitDev mmu = avatarContent.MMUs[mmuID];

                Logger.Log(Log_level.L_INFO, "MMU initialized: " + mmu.Name + " " + sessionID);

                //Call the respective MMU
                return(avatarContent.MMUs[mmuID].Initialize(avatarDescription, properties));
            }
            catch (Exception e)
            {
                Logger.Log(Log_level.L_ERROR, $"Problem at initializing MMU: {mmuID}, message: {e.Message}");

                return(new MBoolResponse(false)
                {
                    LogData = new List <string>()
                    {
                        e.Message,
                        e.StackTrace,
                        e.InnerException.ToString(),
                        e.StackTrace
                    }
                });
            }
        }
Ejemplo n.º 12
0
        public void TestSkeletonGeneration()
        {
            MAvatarDescription desc = IntermediateSkeleton.GenerateFromDescriptionFile("TestAvatar");

            Assert.AreEqual(desc.AvatarID, "TestAvatar");
            Assert.AreEqual(desc.ZeroPosture.Joints.Count, 19);

            IntermediateSkeleton skeleton = new IntermediateSkeleton();

            skeleton.InitializeAnthropometry(desc);
            Assert.AreEqual(desc, skeleton.GetAvatarDescription(desc.AvatarID));

            string[] jointnames = new string[] { "S1L5Joint", "T12L12Joint", "T1T2Joint", "C4C5Joint", "HeadJoint", "LeftShoulder", "LeftElbow", "LeftWrist", "RightShoulder", "RightElbow", "RightWrist", "LeftHip", "LeftKnee", "LeftAnkle", "LeftBall", "RightHip", "RightKnee", "RightAnkle", "RightBall" };
            for (int i = 0; i < desc.ZeroPosture.Joints.Count; i++)
            {
                MJoint joint = desc.ZeroPosture.Joints[i];
                Assert.AreEqual(joint.ID.ToString(), jointnames[i]);
            }
        }
Ejemplo n.º 13
0
        public void TestRootPosition()
        {
            MAvatarDescription   desc     = IntermediateSkeleton.GenerateFromDescriptionFile("TestAvatar");
            IntermediateSkeleton skeleton = new IntermediateSkeleton();

            skeleton.InitializeAnthropometry(desc);
            List <double> rotationValues = new List <double>()
            {
                0, 0, 0, 0.86041, -0.01303, 0.50383, 0.07533,                    //S1L5
                0.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.00000,   // T12L12
                0.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.00000,   // T1T2
                0.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.00000,   //C4C5
                0.00000, 0.00000, 0.00000, 0.98890, 0.04908, -0.13945, -0.01508, // Head
                0.00000, 0.00000, 0.00000, 0.74914, -0.35251, 0.02895, 0.56007,  // LeftShoulder
                0.98560, 0.11136, -0.00962, 0.12689,                             // Left ELbow
                0.96542, -0.01250, 0.25953, 0.02139,                             // Left Wrist
                0.00000, 0.00000, 0.00000, 0.74411, 0.10420, 0.26279, -0.60530,
                0.95158, 0.28073, 0.07735, -0.09850,                             // Right Elbow
                0.99256, -0.00379, 0.11897, -0.02548,                            // right wrist
                0.94999, -0.28306, 0.12805, 0.03154,                             // Left hip
                0.97503, 0.22205, 0.00000, -0.00001,                             // Knee
                0.99439, -0.07404, 0.06580, 0.03709,                             // Ankle
                1.00000, 0.00000, 0.00000, 0.00000,                              // Toes
                0.99694, 0.07053, -0.02371, 0.02406,                             // Right Hip
                0.91716, 0.39852, 0.00000, 0.00000,                              // Knee
                0.99076, -0.12976, 0.02501, 0.03048,                             // Ankle
                1.00000, 0.00000, 0.00000, 0.00000
            };                                                                   // Toes
            MAvatarPostureValues values = new MAvatarPostureValues(desc.AvatarID, rotationValues);

            skeleton.SetChannelData(values);
            MVector3 pos = skeleton.GetGlobalJointPosition(desc.AvatarID, MJointType.S1L5Joint);
            MVector3 gt  = skeleton.GetRoot(desc.AvatarID).GetMJoint().Position;

            gt = new MVector3(gt.X + rotationValues[0], gt.Y + rotationValues[1], gt.Z + rotationValues[2]);
            System.Console.WriteLine("pos: {0}, {1}, {2}", pos.X, pos.Y, pos.Z);
            System.Console.WriteLine("gt: {0}, {1}, {2}", gt.X, gt.Y, gt.Z);
            Assert.IsTrue(System.Math.Abs(pos.X - gt.X) < 0.001);
            Assert.IsTrue(System.Math.Abs(pos.Y - gt.Y) < 0.001);
            Assert.IsTrue(System.Math.Abs(pos.Z - gt.Z) < 0.001);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Initializes the anthropometry from a given description.
        /// Has to be performed prior to all other interactions with the
        /// intermediate skeleton (e.g. query for joint positions, etc.).
        /// </summary>
        /// <param name="description"></param>
        public void InitializeAnthropometry(MAvatarDescription description)
        {
            this.avatarDescriptions[description.AvatarID] = description;

            //update joint offsets
            this.hierarchies[description.AvatarID] = RJoint.Initialize(description.ZeroPosture.Joints);

            List <double> zero_rotations = new List <double>();

            this.hierarchies[description.AvatarID].CreateZeroVector(zero_rotations);
            MAvatarPostureValues values = new MAvatarPostureValues(description.AvatarID, zero_rotations);

            this.lastPostureValues[description.AvatarID] = values;

            List <MJointType> animatedJoints = new List <MJointType>();

            foreach (MJoint j in description.ZeroPosture.Joints)
            {
                animatedJoints.Add(j.Type);
            }
            this.SetAnimatedJoints(description.AvatarID, animatedJoints);
        }
        /// <summary>
        /// Basic initialization method
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            //Assign the vatar description
            this.AvatarDescription = avatarDescription;

            //Execute instructions on main thread
            this.ExecuteOnMainThread(() =>
            {
                base.Initialize(avatarDescription, properties);


                this.animator             = this.GetComponent <Animator>();
                this.animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                this.animator.enabled     = false;
                this.animator.speed       = this.Velocity / 2.0f;

                //Update the animator to establish a first posture
                this.animator.Update(0);
            });

            return(new MBoolResponse(true));
        }
Ejemplo n.º 16
0
 public MBoolResponse CreateSession(string sessionId, MAvatarDescription referenceAvatar)
 {
     return(this.instance.CreateSession(sessionId));
 }
Ejemplo n.º 17
0
        /// <summary>
        /// MMU causes problems if initializing multiple times -> To check in future
        /// Basic initialization
        /// For specifying the priorities of the MMUs /motion types the properties can be specified (e.g. {"walk", 1.0}, {"grasp", 2.0})
        /// The listed motion types are also the ones which are loaded. If this porperty is not defined then every MMU is loaded.
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            base.Initialize(avatarDescription, properties);

            Console.WriteLine("---------------------------------------------------------");
            Console.WriteLine("Initializing co-simulation MMU");

            //Full scene transmission initial required
            this.transmitFullScene = true;

            //Setup the mmu access
            this.mmuAccess = new MMUAccess(this.sessionId)
            {
                AvatarID    = avatarDescription.AvatarID,
                SceneAccess = this.SceneAccess
            };

            Console.WriteLine("Try to connect to mmu access...");


            //Connect to mmu access and load mmus
            if (this.mmuAccess.Connect(this.AdapterEndpoint, avatarDescription.AvatarID))
            {
                //Get all loadable MMUs within the current session
                List <MMUDescription> loadableMMUs = this.mmuAccess.GetLoadableMMUs();


                //Select the MMUs which should be loaded
                loadableMMUs = this.SelectMMUsToLoad(loadableMMUs);

                //Create a dictionary for storing the priorities
                Dictionary <string, float> priorities = new Dictionary <string, float>();
                priorities = this.GetPriorities?.Invoke();



                //Select the MMUs to load if explictely specified by the user
                if (properties != null && properties.Count > 0)
                {
                    for (int i = loadableMMUs.Count - 1; i >= 0; i--)
                    {
                        MMUDescription description = loadableMMUs[i];

                        float priority = 1;

                        //If MMU is listed -> add the priority
                        if (priorities.TryGetValue(description.MotionType, out priority))
                        {
                            priorities.Add(description.MotionType, priority);
                        }

                        //MMU is not explicetly listed -> remove from loading list
                        else
                        {
                            loadableMMUs.RemoveAt(i);
                        }
                    }
                }

                //No MMU list defined -> Load all MMUs with same priority (despite the own MMU)
                else
                {
                    //Remove the own MMU -> Avoid recursively instantiating own MMU (unless explictely forced)
                    if (loadableMMUs.Exists(s => s.Name == this.Name))
                    {
                        MMUDescription ownDescription = loadableMMUs.Find(s => s.Name == this.Name);
                        loadableMMUs.Remove(ownDescription);
                    }
                }

                Console.WriteLine("Got loadable MMUs:");

                try
                {
                    //Load the relevant MMUs
                    bool success = this.mmuAccess.LoadMMUs(loadableMMUs, TimeSpan.FromSeconds(20));
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error at loading MMUs : " + e.Message + e.StackTrace);

                    return(new MBoolResponse(false)
                    {
                        LogData = new List <string>()
                        {
                            e.Message,
                            e.StackTrace
                        }
                    });
                }

                Console.WriteLine("All MMUs successfully loaded");


                foreach (MMUDescription description in loadableMMUs)
                {
                    Console.WriteLine(description.Name);
                }


                //Initialize all MMUs
                bool initialized = this.mmuAccess.InitializeMMUs(TimeSpan.FromSeconds(20), avatarDescription.AvatarID);

                if (!initialized)
                {
                    Console.WriteLine("Problem at initializing MMUs");

                    return(new MBoolResponse(false)
                    {
                        LogData = new List <string>()
                        {
                            { "Problem at initializing MMUs" }
                        }
                    });
                }

                //Instantiate the cosimulator
                this.coSimulator = new MMICoSimulator(mmuAccess.MotionModelUnits);

                //Set the priorities of the motions
                this.coSimulator.SetPriority(priorities);


                return(new MBoolResponse(true));
            }

            else
            {
                Console.WriteLine("Connection to MMUAccess/MMIRegister failed");
                return(new MBoolResponse(false)
                {
                    LogData = new List <string>()
                    {
                        "Connection to MMUAccess/MMIRegister failed"
                    }
                });
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Create a new session
 /// </summary>
 /// <param name="sessionId"></param>
 /// <param name="referenceAvatar">The utilized reference avatar</param>
 public MBoolResponse CreateSession(string sessionId, MAvatarDescription referenceAvatar)
 {
     return(this.thriftClient.Access.CreateSession(sessionId));
 }
Ejemplo n.º 19
0
 public MBoolResponse Setup(MAvatarDescription avatar, Dictionary <string, string> properties)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Basic initialization method
 /// </summary>
 /// <param name="avatarDescription"></param>
 /// <param name="properties"></param>
 /// <returns></returns>
 public virtual MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
 {
     //Set the avatar description
     this.AvatarDescription = avatarDescription;
     return(new MBoolResponse(true));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Initialization function in which the MMU is initialized (called remote)
 /// </summary>
 public MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
 {
     //Call the remote MMU
     return(this.adapterClient.Access.Initialize(avatarDescription, new Dictionary <string, string>(), this.ID, this.sessionId));
 }
Ejemplo n.º 22
0
 public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
 {
     return(base.Initialize(avatarDescription, properties));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Basic initialization method
        /// </summary>
        /// <param name="avatarDescription"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
        {
            //Call the base class (important for automatic conversion from MSimulationState to SimulationState)
            base.Initialize(avatarDescription, properties);

            this.SkeletonAccess = new IntermediateSkeleton();
            this.SkeletonAccess.InitializeAnthropometry(avatarDescription);


            //Create a new session uuid
            this.sessionId = Guid.NewGuid().ToString();

            //Create a new virtual scene
            this.virtualScene = new MMIScene();

            //Create a unique id for the new virtual object representing the move target
            string moveTargetID = Guid.NewGuid().ToString();

            //Create a new virtual object representing the move target
            moveTarget = new MSceneObject(moveTargetID, "MoveTarget", new MTransform()
            {
                ID       = moveTargetID,
                Position = new MVector3(0, 0, 0),
                Rotation = new MQuaternion(0, 0, 0, 1)
            });

            //Add the virtual move target to the scene
            this.virtualScene.Apply(new MSceneUpdate()
            {
                AddedSceneObjects = new List <MSceneObject>()
                {
                    moveTarget
                }
            });


            //Full scene transmission initial required
            this.transmitFullScene = true;

            //Setup the mmu access
            this.mmuAccess = new MMUAccess(this.sessionId)
            {
                //IntermediateAvatarDescription = avatarDescription,
                SceneAccess = this.virtualScene
            };

            Console.WriteLine("Try to connect to mmu access...");

            //Connect to mmu access and load mmus
            bool connected = this.mmuAccess.Connect(this.AdapterEndpoint, this.AvatarDescription.AvatarID);


            if (connected)
            {
                //Get all loadable MMUs within the current session
                List <MMUDescription> loadableMMUs = this.mmuAccess.GetLoadableMMUs();


                MMUDescription moveMMU = loadableMMUs.Find(s => s.MotionType == "move");

                Console.WriteLine("Got loadable MMUs:");


                //Load the relevant MMUs
                bool loaded = this.mmuAccess.LoadMMUs(new List <MMUDescription>()
                {
                    moveMMU
                }, TimeSpan.FromSeconds(10));

                if (!loaded)
                {
                    Console.WriteLine("Error at loading MMU");

                    return(new MBoolResponse(false)
                    {
                        LogData = new List <string>()
                        {
                            { "Error at loading mmu" }
                        }
                    });
                }

                //Initialize all MMUs
                this.mmuAccess.InitializeMMUs(TimeSpan.FromSeconds(10), this.AvatarDescription.AvatarID);

                //Instantiate the cosimulator
                this.coSimulator = new MMICoSimulator(mmuAccess.MotionModelUnits);


                return(new MBoolResponse(true));
            }
            else
            {
                Console.WriteLine("Connection to MMUAccess/MMIRegister failed");
                return(new MBoolResponse(false)
                {
                    LogData = new List <string>()
                    {
                        "Connection to MMUAccess/MMIRegister failed"
                    }
                });
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Basic setup routine -> Nothing to do in here
 /// </summary>
 /// <param name="avatar"></param>
 /// <param name="properties"></param>
 /// <returns></returns>
 public virtual MBoolResponse Setup(MAvatarDescription avatar, Dictionary <string, string> properties)
 {
     return(new MBoolResponse(true));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Co Simulator has to be initialized before usage
 /// </summary>
 /// <param name="avatarDescription"></param>
 /// <param name="properties"></param>
 /// <returns></returns>
 public override MBoolResponse Initialize(MAvatarDescription avatarDescription, Dictionary <string, string> properties)
 {
     //Initialize the CoSimulator
     return(this.remoteCoSimulationMMU.Initialize(avatarDescription, properties));
 }