Exemplo n.º 1
0
 /// <summary>
 /// main()
 /// </summary>
 /// <param name="args"></param>
 static void Main(string[] args)
 {
     string robot_acc = "";
     string robot_passwd = "";
     if (args.Length == 0)
     {
         Console.WriteLine("USAGE:MSNRobot.exe <msn_account> [password]");    
         return;
     }
     robot_acc = args[0];
     if (args.Length == 2)
         robot_passwd = args[1];
     else
     {
         Console.WriteLine("Password for " + robot_acc + ":");
         robot_passwd = Console.ReadLine();
     }
     RobotMain app = new RobotMain();
     app.BeginLogin(robot_acc, robot_passwd);
    
     while (true)
     {
         Console.WriteLine("I am a MSN robot:" + robot_acc);
         Console.ReadLine();
     }
 }
Exemplo n.º 2
0
 public RobotConversation(Conversation conv, RobotMain robotmain)
 {
     Console.WriteLine("==> Struct a conversation");
     _conversation = conv;
     _conversation.Switchboard.TextMessageReceived += new EventHandler<TextMessageEventArgs>(Switchboard_TextMessageReceived);
     _conversation.Switchboard.SessionClosed += new EventHandler<EventArgs>(Switchboard_SessionClosed);
     _conversation.Switchboard.ContactLeft += new EventHandler<ContactEventArgs>(Switchboard_ContactLeft);
     _robotmain = robotmain;
 }
    // Use this for initialization
    void Start()
    {
        isTheChosenOne    = true;
        filePathPosResNum = Application.dataPath + pathPosNum;
        if (File.Exists(filePathPosResNum))
        {
            fileContent = File.ReadAllText(filePathPosResNum);
            trajectory  = JsonUtility.FromJson <JsonRobotData>(fileContent);
            Debug.Log(trajectory.time);
            filePos.Close();
            if (trajectory.time == 0.0f)
            {
                CheckIteration();
            }
        }

        alpha = startingAlpha;
        beta  = startingBeta;

        if (alpha + beta < 1f)
        {
            CheckIteration();
        }

        timer       = Timer();
        robot       = GameObject.Find("Robot");
        robotScript = robot.GetComponent <RobotMain>();
        rPl         = robot.GetComponent <RobotPlanning>();
        rP          = robot.GetComponent <RobotProgress>();
        rDMUtility  = robot.GetComponent <RobotDMUtilityCloseWall>();

        rDMUtility.alpha             = startingAlpha;
        rDMUtility.beta              = startingBeta;
        robotScript.forgettingFactor = forgettingFactor[startingDelta];
        rP.pathMapNum = pathMapNum + iteration.ToString() + ".json";
        rP.pathPosNum = pathPosNum + iteration.ToString() + ".json";

        alpha      = startingAlpha;
        beta       = startingBeta;
        deltaIndex = startingDelta;

        //robotScript.SetVariables();
        rP.DefiningFolderAndFile();
        rP.SetAlpha(alpha);
        rP.SetBeta(beta);
        rP.SetDelta(forgettingFactor[deltaIndex]);
        rP.SetMapName(mapName);

        Debug.Log(rDMUtility.alpha);
        Debug.Log(rDMUtility.beta);
        Debug.Log(robotScript.forgettingFactor);

        StartCoroutine(timer);
    }
Exemplo n.º 4
0
    void Start()
    {
        /* #if UNITY_EDITOR
         *  UnityEditor.SceneView.FocusWindowIfItsOpen(typeof(UnityEditor.SceneView));
         #endif */

        playerScript = player.GetComponent <Player>();
        robotScript  = player.GetComponent <RobotMain>();

        tutorialGameUIManagerScript.Fade(0.7f, 1f, true, 0.5f);
    }
    private Vector3 localDownVector; // vector used to give the angular direction of the camera

    void Start()
    {
        /* #if UNITY_EDITOR
         *  UnityEditor.SceneView.FocusWindowIfItsOpen(typeof(UnityEditor.SceneView));
         #endif */

        playerScript = player.GetComponent <Player>();
        robotScript  = player.GetComponent <RobotMain>();

        for (int i = 0; i < target.Length; i++)
        {
            targetReached.Add(false);
        }

        tutorialGameUIManagerScript.Fade(0.7f, 1f, true, 0.5f);
    }
    private void OnLevelWasLoaded(int level)
    {
        if (!isTheChosenOne)
        {
            Destroy(this.gameObject);
        }
        else
        {
            iteration = 1 + iteration;
            if (alpha < maxAlpha)
            {
                alpha = 0.1f + alpha;
            }
            else if (beta < maxBeta)
            {
                beta  = 0.1f + beta;
                alpha = minAlpha;
            }
            else if (deltaIndex < maxDeltaIndex)
            {
                deltaIndex = deltaIndex + 1;
                alpha      = minAlpha;
                beta       = minBeta;
            }

            filePathPosResNum = Application.dataPath + pathPosNum;
            if (File.Exists(filePathPosResNum))
            {
                fileContent = File.ReadAllText(filePathPosResNum);
                trajectory  = JsonUtility.FromJson <JsonRobotData>(fileContent);
                Debug.Log(trajectory.time);
                filePos.Close();
                if (trajectory.time == 0.0f)
                {
                    CheckIteration();
                }
            }

            if (alpha + beta < 1f)
            {
                CheckIteration();
            }

            timer                        = Timer();
            robot                        = GameObject.Find("Robot");
            robotScript                  = robot.GetComponent <RobotMain>();
            rPl                          = robot.GetComponent <RobotPlanning>();
            rP                           = robot.GetComponent <RobotProgress>();
            rDMUtility                   = robot.GetComponent <RobotDMUtilityCloseWall>();
            rDMUtility.alpha             = alpha;
            rDMUtility.beta              = beta;
            robotScript.forgettingFactor = forgettingFactor[deltaIndex];
            rP.pathMapNum                = pathMapNum + iteration.ToString() + ".json";
            rP.pathPosNum                = pathPosNum + iteration.ToString() + ".json";

            //robotScript.SetVariables();
            rP.DefiningFolderAndFile();
            rP.SetAlpha(alpha);
            rP.SetBeta(beta);
            rP.SetDelta(forgettingFactor[deltaIndex]);
            rP.SetMapName(mapName);

            Debug.Log(alpha);
            Debug.Log(beta);
            Debug.Log(forgettingFactor[deltaIndex]);

            StartCoroutine(timer);
        }
    }
    protected RobotMain mainScipt; //The core component (the one responsible for scanning and decisioning)

    private void Start()
    {
        mainScipt = GetComponent <RobotMain>();
    }
Exemplo n.º 8
0
        public bool WriteCommand(string message)
        {
            if (string.IsNullOrEmpty(message) || string.IsNullOrWhiteSpace(message))
            {
                return(false);
            }

            byte id = 0b00000000;

            byte[] buffer = new byte[1];
            byte[] ascii  = new byte[1];

            int spaceIndex = message.IndexOf(' ');

            if (spaceIndex <= 0)
            {
                spaceIndex = message.Length;
            }
            string cmdString = message.Substring(0, spaceIndex).ToLower().Trim();

            string[] argStrings = message.Substring(spaceIndex >= message.Length ? spaceIndex : spaceIndex + 1).ToLower().Trim().Split(' ');
            for (int i = argStrings.Length - 1; i >= 0; i--)
            {
                argStrings[i] = argStrings[i].Trim();
            }

            switch (cmdString)
            {
            case "help":
                WriteHelp();
                break;

            case "health":
                WriteHealth();
                break;

            case "start_test":
                if (RobotMain.IsRunning == false)
                {
                    RobotMain.Start();
                }
                RobotMain.State = RobotMain.RobotState.TestInit;
                break;

            case "start_idle":
                if (RobotMain.IsRunning == false)
                {
                    RobotMain.Start();
                }
                RobotMain.State = RobotMain.RobotState.IdleInit;
                break;

            case "start_autonomous":
                if (RobotMain.IsRunning == false)
                {
                    RobotMain.Start();
                }
                RobotMain.State = RobotMain.RobotState.AutonomousInit;
                break;

            case "start_teleop":
                if (RobotMain.IsRunning == false)
                {
                    RobotMain.Start();
                }
                RobotMain.State = RobotMain.RobotState.TeleopInit;
                break;

            case "setchnnl":
                WriteSetChnnl(Convert.ToByte(argStrings[0]));
                break;

            case "start":
                WriteStart();
                if (RobotMain.IsRunning == false)
                {
                    RobotMain.Start();
                }
                break;

            case "stop":
                WriteStop();
                if (RobotMain.IsRunning == true)
                {
                    RobotMain.Stop();
                }
                break;

            case "print":
                string msg = string.Empty;
                for (int i = 0; i < argStrings.Length; i++)
                {
                    if (i == 0)
                    {
                        msg += $"{argStrings[i]}";
                    }
                    else
                    {
                        msg += $" {argStrings[i]}";
                    }
                }

                WritePrint(msg);
                break;

            case "ping":
                WritePing();
                break;

            case "setbchnnl":
                WriteSetBChnnl(Convert.ToByte(argStrings[0]));
                break;

            case "drive":
                WriteDrive(Convert.ToByte(argStrings[0]), Convert.ToByte(argStrings[1]));
                break;

            case "drivetimed":
                WriteDriveTimed(Convert.ToByte(argStrings[0]), Convert.ToByte(argStrings[1]), Convert.ToInt16(argStrings[2]));
                break;

            case "tdrive":
                WriteTDrive(Convert.ToByte(argStrings[0]), Convert.ToByte(argStrings[1]));
                break;

            case "tdrivetimed":
                WriteTDriveTimed(Convert.ToByte(argStrings[0]), Convert.ToByte(argStrings[1]), Convert.ToInt16(argStrings[2]));
                break;

            case "claw":
                WriteClaw(Convert.ToByte(argStrings[0]));
                break;

            default:
                WriteBlank();
                break;
            }

            return(true);
        }