Exemple #1
0
        public Dictionary <RelocatableObjectInfo, GameObject> CreateGraspablesPositionsMap()
        {
            this.DeactivateGraspingCandidatesPositions();

            // Shuffle the grasping candidates list
            this.graspables = this.graspables.OrderBy(i => Guid.NewGuid()).ToList();

            // Shuffle the grasping candidates position list
            this.graspingCandidatesPositions = this.graspingCandidatesPositions.OrderBy(i => Guid.NewGuid()).ToList();


            Dictionary <RelocatableObjectInfo, GameObject> graspablesPositionsMap = new Dictionary <RelocatableObjectInfo, GameObject>();

            for (int i = 0; i < this.graspables.Count; i++)
            {
                RelocatableObjectInfo graspablePositionInfo = new RelocatableObjectInfo();

                graspablePositionInfo.name        = this.graspables[i].name;
                graspablePositionInfo.position    = this.graspingCandidatesPositions[i].transform.position - new Vector3(0, this.graspingCandidatesPositions[i].transform.localScale.y * 0.49f, 0);
                graspablePositionInfo.eulerAngles = this.graspingCandidatesPositions[i].transform.eulerAngles;

                graspablesPositionsMap.Add(graspablePositionInfo, this.graspables[i]);
            }

            return(graspablesPositionsMap);
        }
Exemple #2
0
        public IEnumerator SaveEnvironmentInfo()
        {
            EnvironmentInfo environmentInfo = new EnvironmentInfo();

            environmentInfo.taskMessage        = this.GetTaskDetail();
            environmentInfo.environmentName    = this.environmentName;
            environmentInfo.graspingTargetName = this.graspingTarget.name;
            environmentInfo.destinationName    = this.destination.name;

            List <RelocatableObjectInfo> graspablesPositions = new List <RelocatableObjectInfo>();

            foreach (KeyValuePair <RelocatableObjectInfo, GameObject> graspablePositionPair in this.graspablesPositionsMap)
            {
                RelocatableObjectInfo graspableInfo = new RelocatableObjectInfo();
                graspableInfo.name        = graspablePositionPair.Value.name;
                graspableInfo.position    = graspablePositionPair.Key.position;
                graspableInfo.eulerAngles = graspablePositionPair.Key.eulerAngles;

                graspablesPositions.Add(graspableInfo);
            }

            environmentInfo.graspablesPositions = graspablesPositions;

            yield return(null);

            List <RelocatableObjectInfo> destinationsPositions = new List <RelocatableObjectInfo>();

            foreach (KeyValuePair <RelocatableObjectInfo, GameObject> destinationPositionPair in this.destinationsPositionsMap)
            {
                RelocatableObjectInfo destinationInfo = new RelocatableObjectInfo();
                destinationInfo.name        = destinationPositionPair.Value.name;
                destinationInfo.position    = destinationPositionPair.Key.position;
                destinationInfo.eulerAngles = destinationPositionPair.Key.eulerAngles;

                destinationsPositions.Add(destinationInfo);
            }

            environmentInfo.destinationsPositions = destinationsPositions;

            yield return(null);

            object[] args = new object[] { environmentInfo, Application.dataPath };

            Thread threadWritingFile = new Thread(new ParameterizedThreadStart(this.SaveEnvironmentInfo));

            threadWritingFile.Start(args);
        }
Exemple #3
0
        public Dictionary <RelocatableObjectInfo, GameObject> CreateDestinationsPositionsMap()
        {
            Dictionary <RelocatableObjectInfo, GameObject> destinationsPositionsMap = new Dictionary <RelocatableObjectInfo, GameObject>();

            for (int i = 0; i < this.destinationCandidates.Count; i++)
            {
                RelocatableObjectInfo destinationPositionInfo = new RelocatableObjectInfo();

                destinationPositionInfo.name        = this.destinationCandidates[i].name;
                destinationPositionInfo.position    = this.destinationCandidates[i].transform.position;
                destinationPositionInfo.eulerAngles = this.destinationCandidates[i].transform.eulerAngles;

                destinationsPositionsMap.Add(destinationPositionInfo, this.destinationCandidates[i]);
            }

            return(destinationsPositionsMap);
        }