public void CanProcessCommand_WhenRobotIsNotOnTheTableAndCommandIsPlace_ShouldReturnTrue() { var brain = new RobotBrain(); var canProcess = brain.CanProcessCommand(new Command(CommandType.PLACE), null, null); Assert.That(canProcess, Is.True); }
static void Main(string[] args) { Console.WriteLine("hello scribby"); ////rbt = new NxtBrain(@"C:\Microsoft Robotics Studio (1.5)\samples\IPRE\Foundation\IPREFoundationClasses\IPREFoundationClasses\NxtConfig\IPRE.LEGO.NXT.TriBot.config.xml"); ////rbt = new ScribblerBrain(@"C:\Microsoft Robotics Studio (1.5)\samples\IPRE\Foundation\IPREFoundationClasses\IPREFoundationClasses\IPRE.Scribbler.standard.config.xml"); rbt = new SRV1Brain(@"C:\Microsoft Robotics Studio (1.5)\samples\IPRE\Surveyor\SRV-1\Srv1Services\Config\IPRE.Surveyor.SRV1.Vehicle.config.xml"); ////rbt = new CreateBrain(@"C:\Microsoft Robotics Studio (1.5)\samples\IPRE\Foundation\IPREFoundationClasses\IPREFoundationClasses\CreateConfig\IPRE.iRobot.DriveBumper.config.xml"); //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //robotgui = new Form1(rbt); //logger = new Logger(robotgui); //logger.Add(new LogEntry("SRV ready !!!")); //Thread th = new Thread(new ThreadStart(work)); //th.Start(); //Application.Run(robotgui); Application app = new Application(); Blend1.Window1 robotgui = new Blend1.Window1(rbt); logger = new Logger(robotgui); logger.Add(new LogEntry("SRV-1 ready !!!")); Thread th = new Thread(new ThreadStart(work)); th.Start(); app.Run(robotgui); }
bool CheckForMakeRobotTurn() { RobotBrain b = Robot.GetComponent <RobotBrain>(); Rigidbody o = Robot.GetComponent <Rigidbody>(); // Are we autonomous and do we have an angular velocity if (b.autoMode && (o.angularVelocity.magnitude > AcceptableAngularVelocityMagnitude)) { // if one of the motors is moving and they're not equal. // Are we responsable for this angular velocity? if ((b.motor.right != 0 || b.motor.left != 0) && b.motor.right != b.motor.left) { // are we doing it for enough time? if (CheckForMakeRobotTurnElapsedTime < CheckForMakeRobotTurnElapsedTimeGoal) { CheckForMakeRobotTurnElapsedTime += Time.deltaTime; } else { return(true); } } } return(false); }
public void Report_WhenTheGivenLocationIsInvalid_ShouldRetrunEmptryReport() { var brain = new RobotBrain(); var report = brain.Report(null, Direction.NORTH); Assert.That(report, Is.Empty); }
private void FillAPixRobotView_Load(object sender, EventArgs e) { _robotBrain = new RobotBrain(); _robotBrain.PropertyChanged += RobotBrain_PropertyChanged; _robotBrain.ExperienceWanted += RobotBrain_ExperienceWanted; _robotBrain.ActionWanted += RobotBrain_ActionWanted; _robotBrain.ConflictDetected += RobotBrain_ConflictDetected; }
// Start is called before the first frame update void Start() { robotBrain = robot.GetComponent <RobotBrain>(); ResetRobotPositionButton.onClick.AddListener(resetRobotPosition); ExitApplicationButton.onClick.AddListener(QuitGame); InitialPosition = robot.transform.position; InitialRotation = robot.transform.rotation; }
public void CanProcessCommand_WhenRobotIsNotOnTheTableAndCommandIsNotPlace_ShouldReturnFalse() { var brain = new RobotBrain(); var canMove = brain.CanProcessCommand(new Command(CommandType.MOVE), null, null); var canTurnLeft = brain.CanProcessCommand(new Command(CommandType.LEFT), null, null); var canTurnRight = brain.CanProcessCommand(new Command(CommandType.RIGHT), null, null); var canReport = brain.CanProcessCommand(new Command(CommandType.REPORT), null, null); Assert.That(canMove || canTurnLeft || canTurnRight || canReport, Is.False); }
public void Move_WhenItIsSafeToMove_ShouldMove(int initialX, int initialY, Direction facing, int expectedX, int expectedY) { var brain = new RobotBrain(); var initialLocation = new Location(initialX, initialY); var location = brain.Move(initialLocation, facing); // should not move Assert.That(location.X, Is.EqualTo(expectedX)); Assert.That(location.Y, Is.EqualTo(expectedY)); }
public void Place_WhenGivenPositionAndDirectionAreCorrect_ProcessCommand() { var brain = new RobotBrain(); PlaceCommandParameter placementParam = new PlaceCommandParameter(1, 1, "north"); var position = brain.Place(placementParam); Assert.That(position, Is.Not.Null); Assert.That(position.location.X, Is.EqualTo(placementParam.X)); Assert.That(position.location.Y, Is.EqualTo(placementParam.Y)); Assert.That(position.orientation.Direction.ToString().Equals(placementParam.Direction, StringComparison.CurrentCultureIgnoreCase)); }
public void Move_WhenRobotIsPlacedAtTheEdgeOfTheTable_ShouldNotMoveOutsideOfTheTable(int initialX, int initialY, Direction facing) { var brain = new RobotBrain(); var initialLocation = new Location(initialX, initialY); var location = brain.Move(initialLocation, facing); // should not move Assert.That(location.X, Is.EqualTo(initialLocation.X)); Assert.That(location.Y, Is.EqualTo(initialLocation.Y)); }
bool CheckForMakeScriptReturnColor() { RobotBrain b = Robot.GetComponent <RobotBrain>(); if (b.scriptReturn != null) { if (b.scriptReturn.ToObject() is LuaColor) { return(true); } } return(false); }
bool CheckForMakeScriptReturnRange() { RobotBrain b = Robot.GetComponent <RobotBrain>(); if (b.scriptReturn != null) { if (b.scriptReturn.ToObject() is double) { return(true); } } return(false); }
public void Report_WhenTheGivenLocationIsValid_ShouldRetrunTheReport() { var brain = new RobotBrain(); Location currentLocation = new Location(1, 1); const Direction direction = Direction.NORTH; var report = brain.Report(currentLocation, direction); Assert.IsFalse(string.IsNullOrEmpty(report)); var expectedReport = string.Format(Constants.DefaultReportFormat, currentLocation.X, currentLocation.Y, direction); Assert.That(report.Equals(expectedReport, StringComparison.CurrentCultureIgnoreCase)); }
public void Move_WhenGivenAnInvalidCurrentLocation_ShouldThrowException() { var brain = new RobotBrain(); ArgumentNullException exception = null; try { brain.Move(null, Direction.EAST); } catch (ArgumentNullException e) { exception = e; } Assert.That(exception, Is.Not.Null); }
public void Left_WhenGivenAValidCurrentDirection_ShouldReturnTheNewDirectionOnTheLeft() { var brain = new RobotBrain(); var orientation = brain.Left(Direction.NORTH); Assert.That(orientation.Direction, Is.EqualTo(Direction.WEST)); orientation = brain.Left(orientation.Direction); Assert.That(orientation.Direction, Is.EqualTo(Direction.SOUTH)); orientation = brain.Left(orientation.Direction); Assert.That(orientation.Direction, Is.EqualTo(Direction.EAST)); orientation = brain.Left(orientation.Direction); Assert.That(orientation.Direction, Is.EqualTo(Direction.NORTH)); }
public void Place_WhenGivenDirectionIsInvalid_ShouldThrownException() { var brain = new RobotBrain(); SimulationException exception = null; try { PlaceCommandParameter placementParam = new PlaceCommandParameter(1, 1, "north-ish"); brain.Place(placementParam); } catch (SimulationException e) { exception = e; } Assert.That(exception, Is.Not.Null); }
bool CheckForMakeRobotMoveForward() { RobotBrain b = Robot.GetComponent <RobotBrain>(); if (b.motor.right != 0f && b.motor.left != 0f && b.autoMode) { if (CheckForMakeRobotMoveForwardElapsedTime < CheckForMakeRobotMoveForwardElapsedTimeGoal) { CheckForMakeRobotMoveForwardElapsedTime += Time.deltaTime; } else { return(true); } } return(false); }
void Awake() { if (m_RobotBrain == null) { m_RobotBrain = transform.parent.parent.parent.GetComponent <RobotBrain>(); } if (m_LegTargetPrefab == null) { Debug.LogError("Didn't set the Leg Target Prefab on leg " + gameObject.name); return; } if (m_IKScript == null) { Debug.LogError("Leg not set up correctly"); return; } // Spawn & set the object the leg follows. if (m_SpawnedLegTarget == null) { m_SpawnedLegTarget = GameObject.Instantiate(m_LegTargetPrefab, m_IKScript.transform.position, m_LegTargetPrefab.transform.rotation); m_SpawnedLegTarget.name += m_LegIdentifier; m_IKScript.Target = m_SpawnedLegTarget.transform; } // Spawn the object the target tries to be close to. if (m_SpawnedLegTargetHome == null) { m_SpawnedLegTargetHome = GameObject.Instantiate(m_LegTargetHomePrefab, m_IKScript.transform.position, m_LegTargetHomePrefab.transform.rotation, transform.parent.parent); m_SpawnedLegTargetHome.name = "LegTargetHome" + m_LegIdentifier; m_SpawnedLegTarget.GetComponent <Steppy>().SetHomePosition(m_SpawnedLegTargetHome.transform); } if (m_IKScript != null && m_SpawnedLegTarget != null && m_SpawnedLegTargetHome != null) { m_ReadyToWalk = true; m_RobotBrain.AddLeg(m_SpawnedLegTarget.GetComponent <Steppy>(), m_LegIdentifier - 1); } else { Debug.LogWarning(gameObject.name + " has failed to setup."); } }
bool CheckForFollowLine() { RobotBrain b = Robot.GetComponent <RobotBrain>(); if (b.autoMode) { if (HelperTaggedItemInRange(RobotDetectLineDistance, "Line")) { if (CheckForFollowLineTurnElapsedTime < CheckForFollowLineTurnElapsedTimeGoal) { CheckForFollowLineTurnElapsedTime += Time.deltaTime; } else { return(true); } } } return(false); }
bool CheckForAvoidWall() { // while code is running RobotBrain b = Robot.GetComponent <RobotBrain>(); if (b.autoMode) { // Wait untill a wall is close enough if (HelperTaggedItemInRange(CheckForWallDistance, "Wall")) { wallInRange = true; } //now, wait untill it goes away if (wallInRange == true && !HelperTaggedItemInRange(CheckForWallDistance, "Wall")) { return(true); } } return(false); }
public Form1(RobotBrain rbt) { this.rbt = rbt; InitializeComponent(); myInitialize(); }
public Window1(RobotBrain rbt) { this.rbt = rbt; this.InitializeComponent(); this.myInitialization(); }
void Start() { robotBrain = robot.GetComponent <RobotBrain>(); }