Exemplo n.º 1
0
        /// <summary>
        /// Loads a new robot and manipulator from given directorys
        /// </summary>
        /// <param name="directory">robot directory</param>
        /// <returns>whether the process was successful</returns>
        public bool LoadRobotWithManipulator(string baseDirectory, string manipulatorDirectory)
        {
            if (SpawnedRobots.Count >= MAX_ROBOTS)
            {
                return(false);
            }

            robotPath = baseDirectory;

            GameObject robotObject = new GameObject("Robot");
            MaMRobot   robot       = robotObject.AddComponent <MaMRobot>();

            robot.FilePath = robotPath;

            //Initialiezs the physical robot based off of robot directory. Returns false if not sucessful
            if (!robot.InitializeRobot(baseDirectory))
            {
                return(false);
            }

            //If this is the first robot spawned, then set it to be the active robot and initialize the robot camera on it
            if (ActiveRobot == null)
            {
                ActiveRobot = robot;
            }

            robot.ControlIndex = SpawnedRobots.Count;
            SpawnedRobots.Add(robot);

            DPMDataHandler.Load(robotPath);
            return(robot.InitializeManipulator(manipulatorDirectory));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Changes the active robot to a different robot based on a given index
 /// </summary>
 public void SwitchActiveRobot(int index)
 {
     if (index < SpawnedRobots.Count)
     {
         ActiveRobot = SpawnedRobots[index];
         DPMDataHandler.Load(ActiveRobot.FilePath);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Changes the active robot to a different robot based on a given index
 /// </summary>
 public void SwitchActiveRobot(int index)
 {
     if (SpawnedRobots.Count() > 0)
     {
         ActiveRobot = SpawnedRobots[index];
         DPMDataHandler.Load(ActiveRobot.FilePath); //reload robot data to allow for driver practice for multiplayer
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Loads a new robot from a given directory
        /// </summary>
        /// <param name="directory">robot directory</param>
        /// <returns>whether the process was successful</returns>
        public bool LoadRobot(string directory, bool isMixAndMatch)
        {
            if (SpawnedRobots.Count < MAX_ROBOTS)
            {
                GameObject     robotObject = new GameObject("Robot");
                SimulatorRobot robot;

                if (isMixAndMatch)
                {
                    robotPath = RobotTypeManager.RobotPath;
                    MaMRobot mamRobot = robotObject.AddComponent <MaMRobot>();
                    mamRobot.RobotHasManipulator = false; // Defaults to false
                    robot = mamRobot;
                }
                else
                {
                    robotPath = directory;
                    robot     = robotObject.AddComponent <SimulatorRobot>();
                }

                robot.FilePath = robotPath;

                //Initialiezs the physical robot based off of robot directory. Returns false if not sucessful
                if (!robot.InitializeRobot(robotPath))
                {
                    return(false);
                }

                //If this is the first robot spawned, then set it to be the active robot and initialize the robot camera on it
                if (ActiveRobot == null)
                {
                    ActiveRobot = robot;
                }

                robot.ControlIndex = SpawnedRobots.Count;
                SpawnedRobots.Add(robot);

                DPMDataHandler.Load(robotPath);

                if (!isMixAndMatch && !PlayerPrefs.HasKey(robot.RootNode.GUID.ToString()) && !SampleRobotGUIDs.Contains(robot.RootNode.GUID.ToString()))
                {
                    if (PlayerPrefs.GetInt("analytics") == 1)
                    {
                        PlayerPrefs.SetString(robot.RootNode.GUID.ToString(), "analyzed");
                        Analytics.CustomEvent(robot.RootNode.exportedWith.ToString(), new Dictionary <string, object> {
                        });
                    }
                }

                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Loads a new robot from a given directory
        /// </summary>
        /// <param name="directory">robot directory</param>
        /// <returns>whether the process was successful</returns>
        public bool LoadRobot(string directory, bool isMixAndMatch, int replacementIndex)
        {
            bool b = true;

            if (!Directory.Exists(directory))
            {
                return(false);
            }
            else
            {
                string[] files = Directory.GetFiles(directory);
                foreach (string a in files)
                {
                    string name = Path.GetFileName(a);
                    if (name.ToLower().Contains("skeleton"))
                    {
                        b = false;
                    }
                }
            }

            if (b)
            {
                return(false);
            }

            if (SpawnedRobots.Count < MAX_ROBOTS)
            {
                GameObject     robotObject = new GameObject("Robot");
                SimulatorRobot robot;

                if (isMixAndMatch)
                {
                    robotPath = RobotTypeManager.RobotPath;
                    MaMRobot mamRobot = robotObject.AddComponent <MaMRobot>();
                    mamRobot.RobotHasManipulator = false; // Defaults to false
                    robot = mamRobot;

                    if (AnalyticsManager.GlobalInstance != null)
                    {
                        AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.LoadRobot,
                                                                      AnalyticsLedger.EventAction.Load,
                                                                      "Robot - Mix and Match",
                                                                      AnalyticsLedger.getMilliseconds().ToString());
                    }
                }
                else
                {
                    robotPath = directory;
                    robot     = robotObject.AddComponent <SimulatorRobot>();

                    if (AnalyticsManager.GlobalInstance != null)
                    {
                        AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.LoadRobot,
                                                                      AnalyticsLedger.EventAction.Load,
                                                                      "Robot - Exported",
                                                                      AnalyticsLedger.getMilliseconds().ToString());
                    }
                }

                robot.FilePath = robotPath;

                //Initialiezs the physical robot based off of robot directory. Returns false if not sucessful
                if (!robot.InitializeRobot(robotPath))
                {
                    return(false);
                }

                //If this is the first robot spawned, then set it to be the active robot and initialize the robot camera on it
                if (ActiveRobot == null)
                {
                    ActiveRobot = robot;
                }

                robot.ControlIndex = SpawnedRobots.Count;
                if (replacementIndex != -1)
                {
                    SpawnedRobots[replacementIndex] = robot;
                }
                else
                {
                    SpawnedRobots.Add(robot);
                }

                DPMDataHandler.Load(robotPath);

                if (!isMixAndMatch && !PlayerPrefs.HasKey(robot.RootNode.GUID.ToString()) && !SampleRobotGUIDs.Contains(robot.RootNode.GUID.ToString()))
                {
                    AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.LoadRobot,
                                                                  AnalyticsLedger.EventAction.Load,
                                                                  robot.RootNode.GUID.ToString(),
                                                                  AnalyticsLedger.getMilliseconds().ToString());
                }

                return(true);
            }
            return(false);
        }