示例#1
0
        static void Main(string[] _)
        {
            Console.WriteLine("Connecting to Fenton Chassis");
            Console.WriteLine("Ports available:");
            Console.WriteLine(string.Join(" ", SerialPort.GetPortNames()));
            Console.Write("Choose port: ");

            string portName = Console.ReadLine();

            portName = string.IsNullOrWhiteSpace(portName.Trim())
                            ? "COM5"
                            : portName.ToUpper().Trim();

            Roomba roomba = new Roomba(portName);

            roomba.Sensors.ButtonSpot.Subscribe(o => Console.WriteLine("Spot Button Pressed"));

            roomba.Song(Song.Define(SongNumber.Song1, Melody.Define((Note.C4, 64), (Note.D4, 32), (Note.E4, 16))));

            roomba.Sing(SongNumber.Song1);

            Console.ReadLine();

            roomba.ModeOff();
        }
示例#2
0
        /// <summary>
        /// Connect to the robot.
        /// </summary>
        /// <param name="portName"></param>
        private void ConnectToRobot(string portName)
        {
            // Create robot.
            this.robot = new Roomba(new SerialCommunicator(portName));

            // Attach events.
            this.robot.OnMesage += this.robot_OnMesage;

            // Connect to robot.
            this.robot.Connect();

            // Wakeup procedure.
            this.robot.Start();
            this.robot.Start();
            this.robot.Safe();
            this.robot.Start();
            this.robot.Safe();

            // Show connect message.
            if (robot.IsConnected)
            {
                string message = "Robot Connection: Connected@" + portName;
                this.tsslRobotConnection.Text = message;
                this.LogMessage(message);
            }
        }
示例#3
0
 public override void Move()
 {
     roomba = GetComponent <Roomba>();
     //SetTimer();
     //Debug.Log("Timer set");
     StartCoroutine(RandomMove());
     StartCoroutine(WaitToSpiral());
 }
示例#4
0
 /// <summary>
 /// Connect to the robot.
 /// </summary>
 /// <param name="portName"></param>
 private void ConnectToRobot(string portName)
 {
     this.robot               = new Roomba(portName);
     this.robot.OnMesage     += this.robot_OnMesage;
     this.robot.OnConnect    += Robot_OnConnect;
     this.robot.OnDisconnect += Robot_OnDisconnect;
     this.robot.Connect();
 }
示例#5
0
    void OnRoombaCollision(Roomba roomba)
    {
        //just disappear for now (back into the ObjectPool)
        bool pickedUpBaby = roomba.PickupBaby(this);

        if (pickedUpBaby)
        {
            babyManager.DestroySprite(this.gameObject);
        }
    }
示例#6
0
        private void AutoStart()
        {
            Roomba.SendToRoomba str = PortRoomba.Write;
            roomba = new Roomba(str);

            ConnectSynchronous();
            roomba.InitROI();
            roomba.Leds_Raw(80, 92, 124, 0);  // write rob
            //sensorGroupList.SelectedItem = 3;
            //updateFreqTrackBar.Value = 4;
            // StartPollingSensors();
        }
示例#7
0
 static void Main(string[] args)
 {
     try
     {
         Roomba roomba = new Roomba();
         roomba.Auto();
         Console.ReadLine();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
示例#8
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (GameManager.Instance.IsPlaying)
        {
            if (other.gameObject.GetComponent <Door>() != null)
            {
                OnDoorCollision();
                return;
            }

            Roomba roomba = other.gameObject.GetComponent <Roomba>();
            if (roomba != null)
            {
                OnRoombaCollision(roomba);
                return;
            }
        }
    }
示例#9
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        Human human = collision.gameObject.GetComponent <Human>();

        //If collided with human
        if (human != null && Activated && !human.falling)
        {
            Transform shadow = human.gameObject.transform.Find("Shadow");
            if (shadow != null)
            {
                Debug.Log(shadow);
                Destroy(shadow.gameObject);
            }
            human.StopAllCoroutines();

            SortLayer sortLayer = human.gameObject.GetComponent <SortLayer>();
            sortLayer.offset = -6000;
            human.gameObject.transform.GetChild(0).GetComponent <SortParent>().offset = -1;

            Vector3 humanpos = human.transform.position;
            Vector3 newPos   = Vector3.Lerp(humanpos, gameObject.transform.position, 0.1f);

            Vector3 thisPos = gameObject.transform.position;

            if (Vector3.Magnitude(humanpos - newPos) < 0.1f)
            {
                collision.gameObject.GetComponent <Collider2D>().enabled = false;
                Drop(human);
            }
            else
            {
                human.transform.position = newPos;
            }
        }
        if (collision.gameObject.tag == "Roomba")
        {
            Roomba roomba = collision.gameObject.GetComponent <Roomba>();
            roomba.bodyCarried = false;
        }
        else
        {
            collision.gameObject.transform.parent = border.transform;
        }
    }
示例#10
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (roomba == null)
     {
         roomba = GameObject.FindGameObjectWithTag("roomba").GetComponent <Roomba>();
         Debug.Log("Vac Eff: " + roomba.GetVacEff());
         Debug.Log("Whisker Eff: " + roomba.GetWhiskerEff());
         Debug.Log(roomba != null);
     }
     else if (Object.FindObjectOfType <Simulation>().IsPlaying())
     {
         if (other.gameObject.tag == "whiskers")
         {
             dirtiness *= 1.0f - (roomba.GetWhiskerEff() / 100.0f);
         }
         else if (other.gameObject.tag == "vacuum")
         {
             dirtiness *= 1.0f - (roomba.GetVacEff() / 100.0f);
         }
     }
 }
示例#11
0
 void Awake()
 {
     instance = this;
 }
示例#12
0
文件: Mode.cs 项目: dm-j/iCreateOI2
 public static IInteractionMode Init(Roomba robot) =>
 new Off(robot);
示例#13
0
文件: Mode.cs 项目: dm-j/iCreateOI2
 protected OpenInterfaceMode(Roomba robot)
 {
     this.robot = robot;
 }
示例#14
0
        private void Robot_OnConnect(object sender, EventArgs e)
        {
            Roomba robot = (Roomba)sender;

            this.LogMessage("Connected to robot port: " + robot.PortName);
        }
示例#15
0
 void Awake()
 {
     instance = this;
 }
示例#16
0
 internal Passive(Roomba robot)
     : base(robot)
 {
     Console.WriteLine("OI Mode: Passive");
 }
示例#17
0
 void Start()
 {
     roomba = GetComponentInParent <Roomba>();
     path   = roomba.GetPath();
 }
示例#18
0
 internal Full(Roomba robot)
     : base(robot)
 {
     Console.WriteLine("OI Mode: Full");
 }
示例#19
0
文件: Off.cs 项目: dm-j/iCreateOI2
 internal Off(Roomba robot)
     : base(robot)
 {
     Console.WriteLine("OI Mode: Off");
 }
示例#20
0
 internal Safe(Roomba robot)
     : base(robot)
 {
     Console.WriteLine("OI Mode: Safe");
 }