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(); }
/// <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); } }
public override void Move() { roomba = GetComponent <Roomba>(); //SetTimer(); //Debug.Log("Timer set"); StartCoroutine(RandomMove()); StartCoroutine(WaitToSpiral()); }
/// <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(); }
void OnRoombaCollision(Roomba roomba) { //just disappear for now (back into the ObjectPool) bool pickedUpBaby = roomba.PickupBaby(this); if (pickedUpBaby) { babyManager.DestroySprite(this.gameObject); } }
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(); }
static void Main(string[] args) { try { Roomba roomba = new Roomba(); roomba.Auto(); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.Message); } }
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; } } }
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; } }
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); } } }
void Awake() { instance = this; }
public static IInteractionMode Init(Roomba robot) => new Off(robot);
protected OpenInterfaceMode(Roomba robot) { this.robot = robot; }
private void Robot_OnConnect(object sender, EventArgs e) { Roomba robot = (Roomba)sender; this.LogMessage("Connected to robot port: " + robot.PortName); }
internal Passive(Roomba robot) : base(robot) { Console.WriteLine("OI Mode: Passive"); }
void Start() { roomba = GetComponentInParent <Roomba>(); path = roomba.GetPath(); }
internal Full(Roomba robot) : base(robot) { Console.WriteLine("OI Mode: Full"); }
internal Off(Roomba robot) : base(robot) { Console.WriteLine("OI Mode: Off"); }
internal Safe(Roomba robot) : base(robot) { Console.WriteLine("OI Mode: Safe"); }