예제 #1
0
 public void OnButtonClick()
 {
     //UnityEngine.Debug.Log("Button clicked");
     if (isInitialized == false)
     {
         this.Initialize();
         GameObject root = GameObject.Find("Robot");
         foreach (Transform child in root.transform)
         {
             HakoniwaRobotConfigInfo robot_cfg = hakoniwa_cfg.GetRobotConfig(child.name);
             if (robot_cfg != null)
             {
                 this.activate_one(robot_cfg);
             }
         }
     }
 }
예제 #2
0
        public void Initialize()
        {
            this.root     = GameObject.Find("Robot");
            this.myObject = GameObject.Find("Robot/" + this.transform.name);
            this.parts    = myObject.GetComponentInChildren <Hakoniwa.Assets.EV3.IEV3Parts>();

            this.isConnected = false;
            this.InitActuator();
            this.InitSensor();

            GameObject     hakoniwa     = GameObject.Find("Hakoniwa");
            HakoniwaConfig hakoniwa_cfg = hakoniwa.GetComponentInChildren <Hakoniwa.Core.HakoniwaConfig>();

            if (hakoniwa_cfg == null)
            {
                UnityEngine.Debug.LogError("Not found hakoniwa_cfg : " + hakoniwa_cfg);
                return;
            }
            this.writer      = this.myObject.GetComponentInChildren <IoWriter>();
            this.reader      = this.myObject.GetComponentInChildren <IoReader>();
            this.robotConfig = hakoniwa_cfg.GetRobotConfig(this.transform.name);
            if (robotConfig == null)
            {
                UnityEngine.Debug.LogError("Not found hakoniwa_robot_cfg : " + robotConfig);
                return;
            }
            if (hakoniwa_cfg.IsMmap(robotConfig))
            {
                this.writer.filepath = hakoniwa_cfg.GetRobotMmapWriterFilePath(this.transform.name);
                this.reader.filepath = hakoniwa_cfg.GetRobotMmapReaderFilePath(this.transform.name);
                this.writer.InitializeMmap();
                this.reader.InitializeMmap();
            }
            else
            {
                this.writer.host = hakoniwa_cfg.GetRobotConfig(this.transform.name).Udp.AthrillIpAddr;
                this.writer.port = hakoniwa_cfg.GetRobotConfig(this.transform.name).Udp.AthrillPort;
                this.reader.port = hakoniwa_cfg.GetRobotConfig(this.transform.name).Udp.UnityPort;
                this.writer.Initialize();
                this.reader.Initialize();
            }
            this.reader.SetCallback(UdpServerCallback);
        }
예제 #3
0
        private void activate_one(HakoniwaRobotConfigInfo robot_cfg)
        {
            string arg = null;

            if (this.hakoniwa_cfg.IsMmap(robot_cfg))
            {
                arg = string.Format("{0} -c1 -t -1 -m {1}/{2}/memory_mmap.txt  -d {1}/{2}/device_config_mmap.txt {1}/{3} ",
                                    athrillPath,
                                    robot_cfg.WorkspacePathUnix,
                                    robot_cfg.ApplicationName,
                                    robot_cfg.BinaryName);
            }
            else
            {
                arg = string.Format("{0} -c1 -t -1 -m {1}/{2}/memory.txt  -d {1}/{2}/device_config.txt {1}/{3} ",
                                    athrillPath,
                                    robot_cfg.WorkspacePathUnix,
                                    robot_cfg.ApplicationName,
                                    robot_cfg.BinaryName);
            }
            if (this.terminal.Contains("wsl"))
            {
                exProcess = Process.Start(this.terminal, arg);
            }
            else if (this.terminal.Contains("open"))
            {
                string       exec_cmd = hakoniwa_cfg.GetCurrentPath() + "/athrill.command";
                StreamWriter writer   = new StreamWriter(exec_cmd);
                writer.Write(arg);
                writer.Close();
                exProcess = Process.Start("/usr/bin/open", exec_cmd);
                UnityEngine.Debug.Log("exec= " + exec_cmd);
            }
            isInitialized = true;
            UnityEngine.Debug.Log("arg=" + arg);
            //UnityEngine.Debug.Log("exProcess=" + exProcess);
        }