public ClassicPlayer( GenieNanoCamera genieNanoCamera, MockCamera mockCamera, MotorController motorController, IWriteable <ClassicPlayerSettings> settings, IWriteable <ClassicImageProcessorSettings> imgProcSettings, ILogger <ClassicPlayer> logger, ILoggerFactory loggerFactory) { _settings = settings; _logger = logger; _imgProcessor = new ClassicImageProcessor(imgProcSettings); _motorController = motorController; var channels = new VideoChannel[] { new VideoChannel("Image", "Raw Image"), new VideoChannel("EdgeDetection", "Image after EdgeDetection"), }; _videoInterface = new VideoInterface(channels, loggerFactory, nameof(ClassicPlayer)); if (genieNanoCamera.PeripheralState == PeripheralState.Ready) { _camera = genieNanoCamera; } else { _camera = mockCamera; } }
private static void InitHardware() { //TODO: Ethernet not found, set dummy mode string ip = SystemContext.SystemPara.IpAddress; int port = SystemContext.SystemPara.Port; var device = TcpClientStream.SearchDevice(ip, port); if (device == null) { SystemContext.IsDummyMode = true; var motor = new DummyMotorController(); var laser = new DummyLaser(); var blowing = new DummyIO(); SystemContext.Hardware = new HardwareProxy(motor, laser, blowing); } else { SystemContext.IsDummyMode = false; var para = SystemContext.SystemPara; Func <AxisParameter, MotorParameter> convert = x => new MotorParameter { Ratio = x.Ratio, IsReversed = x.Reversed }; var motorPara = new Dictionary <AxisTypes, MotorParameter>(); motorPara[AxisTypes.AxisX] = convert(para.XPara); motorPara[AxisTypes.AxisY] = convert(para.YPara); motorPara[AxisTypes.AxisY].IsDualDriven = true; motorPara[AxisTypes.AxisZ] = convert(para.ZPara); motorPara[AxisTypes.AxisW] = new MotorParameter(); var motor = new MotorController(device, motorPara); var laser = new LaserController(device, 10); var blowing = new IOController(device); SystemContext.Hardware = new HardwareProxy(motor, laser, blowing); } }
void Awake() { if (!cameraTransform && Camera.main) { cameraTransform = Camera.main.transform; } if (!cameraTransform) { Debug.Log("Please assign a camera to the Camera script."); enabled = false; } _target = transform; if (_target) { controller = _target.GetComponent <MotorController>(); } if (controller) { Collider characterController = _target.collider; centerOffset = characterController.bounds.center - _target.position; headOffset = centerOffset; headOffset.y = characterController.bounds.max.y - _target.position.y; } else { Debug.Log("Please assign a target to the camera that has a ThirdPersonController script attached."); } Cut(_target, centerOffset); }
private async Task Initialze() { if (LightningProvider.IsLightningEnabled) { LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider(); } else { throw new Exception("Lightning drivers not enabled. Please enable Lightning drivers."); } _camera = new Camera(); await _camera.Initialize(); SpeedSensor.Initialize(); SpeedSensor.Start(); SpeechSynthesis.Initialze(); await AudioPlayerController.Initialize(); _accelerometerSensor = new AccelerometerGyroscopeSensor(); await _accelerometerSensor.Initialize(); _accelerometerSensor.Start(); _automaticSpeakController = new AutomaticSpeakController(_accelerometerSensor); _motorController = new MotorController(); await _motorController.Initialize(_automaticSpeakController); _servoController = new ServoController(); await _servoController.Initialize(); _distanceMeasurementSensor = new DistanceMeasurementSensor(); await _distanceMeasurementSensor.Initialize(I2C_ADDRESS_SERVO); _automaticDrive = new AutomaticDrive(_motorController, _servoController, _distanceMeasurementSensor); _speechRecognation = new SpeechRecognition(); await _speechRecognation.Initialze(_motorController, _servoController, _automaticDrive); _speechRecognation.Start(); _gamepadController = new GamepadController(_motorController, _servoController, _automaticDrive, _accelerometerSensor); _camera.Start(); _httpServerController = new HttpServerController(_motorController, _servoController, _automaticDrive, _camera); SystemController.Initialize(_accelerometerSensor, _automaticSpeakController, _motorController, _servoController, _automaticDrive, _camera, _httpServerController, _speechRecognation, _gamepadController); await SystemController.SetAudioRenderVolume(AUDIO_RENDER_VOLUME, true); await SystemController.SetAudioCaptureVolume(AUDIO_CAPTURE_VOLUME, true); await AudioPlayerController.PlayAndWaitAsync(AudioName.Welcome); _automaticSpeakController.Start(); }
private void Awake() { touchsensor = gameObject.GetComponent <TouchSensor>(); button = gameObject.GetComponent <ButtonSensor>(); rfidsensor = gameObject.GetComponent <RFIDReader>(); objectposition = gameObject.GetComponent <PositionReader>(); lightcontroller = gameObject.GetComponent <LightController>(); soundemitter = gameObject.GetComponent <SoundEmitterController>(); motorcontroller = gameObject.GetComponent <MotorController>(); videoemitter = gameObject.GetComponent <VideoEmitterController>(); effectcontroller = gameObject.GetComponent <EffectController>(); }
public HttpServer(MotorController motorController, ServoController servoController, AutomaticDrive automaticDrive, Camera camera) { _motorController = motorController; _servoController = servoController; _automaticDrive = automaticDrive; _camera = camera; _listener = GetStreamSocketListener(); }
public MainPage() { this.InitializeComponent(); IHubProxy DoorHubProxy = _HubConnection.CreateHubProxy("DoorHub"); DoorHubProxy.On("GetMessage", async() => { _Sensor.IsActive = false; MotorController.PWM(26); await Task.Delay(20000); _Sensor.IsActive = true; }); }
public DroneSimulator() { this.pwmController = new SimulationPwmController(); this.orientationSensor = new SimulationOrientationSensor(); this.motorController = new MotorController(this.pwmController); this.orientationController = new OrientationController(this.motorController, this.orientationSensor, new Dictionary <Axis, IOrientationOffsetHandler>() { [Axis.Yaw] = new QLearningOrientationOffsetHandler(-180, 180, 1, -.05f, .05f, .01f), [Axis.Pitch] = new QLearningOrientationOffsetHandler(-180, 180, 1, -.05f, .05f, .01f), [Axis.Roll] = new QLearningOrientationOffsetHandler(-180, 180, 1, -.05f, .05f, .01f), }); this.outputQueue = new ConcurrentQueue <Vector3>(); }
private void InitMotorController() { // Get MotorController component motorController = gameObject.GetComponent <MotorController>(); if (motorController == null) { Debug.Log("Cannot find the motorController"); // TODO:Show something and then quit Application.LoadLevel(3); } motorController.SetGameStateManager(this); Debug.Log("Get motorController success"); }
void IFoundation.Initialize(IEngine engine) { // Initialize _engine = engine ?? throw new TeaArgumentNullException(nameof(engine)); _engine.Add(this); _isInitialized = true; // Add sub-components _motorController = new MotorController(); _motorController.Initialize(this); _sensorAnalyzer = new SensorAnalyzer(); _sensorAnalyzer.Initialize(this); }
public void Start() { _transform = transform; if (LevelConfiguration.Instance.IsMotocycleLevel) { characterController = MotorController.GetInstance(); } else { characterController = Controller.GetInstance(); } if (!target && characterController != null) { target = characterController.GetTransform(); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // await _HubConnection.Start(); var cam = new MediaCapture(); await cam.InitializeAsync(new MediaCaptureInitializationSettings() { MediaCategory = MediaCategory.Media, StreamingCaptureMode = StreamingCaptureMode.Video }); _Sensor.MotionDetected += async(int pinNum) => { await Task.Factory.StartNew(async() => { _Sensor.IsActive = false; var stream = new InMemoryRandomAccessStream(); await cam.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream); stream.Seek(0); var imageStream = stream.AsStream(); imageStream.Seek(0, SeekOrigin.Begin); string imageUrl = await NotificationHelper.UploadImageAsync(imageStream); switch (await OxfordHelper.IdentifyAsync(imageUrl)) { case AuthenticationResult.IsOwner: // open the door MotorController.PWM(26); break; case AuthenticationResult.Unkown: // send notification to the owner await NotificationHelper.NotifyOwnerAsync(imageUrl); break; case AuthenticationResult.None: default: break; } _Sensor.IsActive = true; }); }; }
public GamepadController(MotorController motorController, ServoController servoController, AutomaticDrive automaticDrive, AccelerometerGyroscopeSensor acceleratorSensor) { if (_shutdown) { return; } _motorController = motorController; _servoController = servoController; _automaticDrive = automaticDrive; _acceleratorSensor = acceleratorSensor; Gamepad.GamepadAdded += GamepadAdded; Gamepad.GamepadRemoved += GamepadRemoved; }
public void MotorController_Stop_CallsMotorActorSetSpeedOnceOnEachSideWithZero() { // Arrange var motorActors = new Mock <IDirectional <IMotorActor> >(); var motorActorLeft = new Mock <IMotorActor>(); var motorActorRight = new Mock <IMotorActor>(); motorActors.SetupGet(_ => _.Right).Returns(motorActorRight.Object); motorActors.SetupGet(_ => _.Left).Returns(motorActorLeft.Object); var motorSpeedConverter = new MotorSpeedConverter(); var testee = new MotorController(motorActors.Object, motorSpeedConverter); // Act testee.Stop(); // Assert motorActors.Verify(p => p.Right.SetSpeed(0), Times.Once()); motorActors.Verify(p => p.Left.SetSpeed(0), Times.Once()); }
public void MotorController_SetForward_CallsMotorActorSetSpeedOnceOnEachSide(MotorSpeed motorSpeed) { // Arrange var motorActors = new Mock <IDirectional <IMotorActor> >(); var motorActorLeft = new Mock <IMotorActor>(); var motorActorRight = new Mock <IMotorActor>(); motorActors.SetupGet(_ => _.Right).Returns(motorActorRight.Object); motorActors.SetupGet(_ => _.Left).Returns(motorActorLeft.Object); var motorSpeedConverter = new MotorSpeedConverter(); var testee = new MotorController(motorActors.Object, motorSpeedConverter); // Act testee.SetForward(motorSpeed); // Assert motorActors.Verify(p => p.Right.SetSpeed(It.IsAny <double>()), Times.Once()); motorActors.Verify(p => p.Left.SetSpeed(It.IsAny <double>()), Times.Once()); }
public async Task Initialze(MotorController motorController, ServoController servoController, AutomaticDrive automaticDrive) { _motorController = motorController; _servoController = servoController; _automaticDrive = automaticDrive; _speechRecognizer = new SpeechRecognizer(new Language("de-DE")); var grammerFile = await Package.Current.InstalledLocation.GetFileAsync(@"Audio\SpeechRecognizerGrammer.xml"); var grammarConstraint = new SpeechRecognitionGrammarFileConstraint(grammerFile); _speechRecognizer.Constraints.Add(grammarConstraint); var compilationResult = await _speechRecognizer.CompileConstraintsAsync(); _speechRecognizer.ContinuousRecognitionSession.ResultGenerated += RecognationResult; _speechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed; }
public HttpServerController(MotorController motorController, ServoController servoController, AutomaticDrive automaticDrive, Camera camera) { Task.Factory.StartNew(() => { _httpServer = new HttpServer(motorController, servoController, automaticDrive, camera); _httpServer.Start(); }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default) .AsAsyncAction() .AsTask() .ContinueWith((t) => { Logger.Write(nameof(HttpServerController), t.Exception).Wait(); SystemController.ShutdownApplication(true).Wait(); }, TaskContinuationOptions.OnlyOnFaulted); }
public static void Main(string[] args) { //Connect to LiDAR lidarController = new LidarController("192.168.0.100", 2111); // Real Robot //COnnect to Motor Controller motorController = new MotorController(motorPort); motorController.Connect(); //initialize obstacle detection tolerances Obstacle.ObstacleInitialize(15, 150, 5, 200);//maxrarius of 15m, //ImportLandmark Locations from Text file knownLandmarks = Localization.KnownLandmarksInit(@"..\..\landmarksDay2.txt"); //Specify which XY Location the robot will start in the field at //YetiLocation = new LocationPoint(0.5, -1, 0); // YetiLocation = new LocationPoint(0.25, -1, 0); //YetiLocation = new LocationPoint(0.0, -1, 0); YetiLocation = new LocationPoint(0.0, 0, 0); //IMPORT the locations of the Waypoint navigation targets //TargetLocationList = Target.ReadLocationData(@"..\..\navigationQualification.txt"); //TargetLocationList = Target.ReadLocationData(@"..\..\navigationDay1.txt"); TargetLocationList = Target.ReadLocationData(@"..\..\navigationTripleIFinal.txt"); TargetLocation = TargetLocationList[0]; //set first target as first from txt file PrevTargetLocation = new Target(); //initialize previous target to null //Initialize the Yeti Location history for Stall detection YetiHistory = new Queue <LocationPoint>(YetiHistorySize); //stall detection //this is flag which specifies if this is the first lidar scan. This is set to false after the first LiDAR scan keepCorrecting = true;//do once //Main loop where all of the fun stuff happens while (AutonomousEnabled) { ScanThread(); } }//end main
public static void Initialize(AccelerometerGyroscopeSensor accelerometerSensor, AutomaticSpeakController automaticSpeakController, MotorController motorController, ServoController servoController, AutomaticDrive automaticDrive, Camera camera, HttpServerController httpServerController, SpeechRecognition speechRecognation, GamepadController gamepadController) { _accelerometerSensor = accelerometerSensor; _automaticSpeakController = automaticSpeakController; _motorController = motorController; _servoController = servoController; _automaticDrive = automaticDrive; _camera = camera; _httpServerController = httpServerController; _speechRecognation = speechRecognation; _gamepadController = gamepadController; _initialized = true; }
// Start is called before the first frame update void Start() { if (onlyStright) { movList = new Direction[] { Direction.driveStright, Direction.stop, }; } if (onlyRotate) { if (rotation_wanted < 0) { movList = new Direction[] { Direction.rotateLeft, Direction.stop, }; rotation_wanted *= -1; } else { movList = new Direction[] { Direction.rotateRight, Direction.stop, }; } } if (onlyStright && onlyRotate) { movList = new Direction[] { Direction.stop, }; } robotController = GetComponent <RobotController>(); sensorFront = robotController.getSensorsControllers()[0]; motorLeft = robotController.getMotorsControllers()[0]; motorRight = robotController.getMotorsControllers()[1]; u = 0; e = 0; e_prev = 0; arrived = false; e_r = 0; e_prev_r = 0; distance_r = 0; distance_wanted_r = (float)(2f * (rotation_wanted / 360f) * Mathf.PI * halfDistanceBetweenWheels); arrived_r = false; }
public static void Main() { //Post methods //THIS SECTION CREATES / INITIALIZES THE SERIAL LOGGER Debug.Print("Flight computer posted successfully. Beginning INIT."); //Initialize sensors, etc. Debug.Print("Starting stopwatch"); Clock.Instance.Start(); //Thread.Sleep(5000); Debug.Print("Flight computer INIT Complete. Continuing with boot."); //THIS SECTION INITIALIZES AND STARTS THE MEMORY MONITOR Debug.Print("Starting memory monitor..."); MemoryMonitor.Instance.Start(); var _motors = new MotorController(); var testPing = new PingUpdater(Pins.GPIO_PIN_A0); testPing.Start(); var testIR = new IRDistanceUpdater(AnalogChannels.ANALOG_PIN_A1, 25, 100); testIR.Start(); // Start sensor actions here. Debug.Print("Flight computer boot successful."); while (true) { Debug.Print("IR: " + RobotState.IRDistance); Debug.Print("\nPing: " + RobotState.PingDistance); Thread.Sleep(1000); var oldSenV = RobotState.LastIRDistance; var currentSenV = RobotState.IRDistance; GreenLED.Write(RobotState.CheckReady()); BlueLED.Write(currentSenV >= 1000); YellowLED.Write(currentSenV >= 2000); if (currentSenV >= 1000) { BlueLED.Write(true); } if (Math.Abs(oldSenV - currentSenV) > .01) { Debug.Print("SensorValue: " + currentSenV); RedLED.Write(false); YellowLED.Write(false); BlueLED.Write(false); if (currentSenV >= 1000) { BlueLED.Write(true); } if (currentSenV >= 2000) { YellowLED.Write(true); } if (!(currentSenV >= 3000)) { continue; } RedLED.Write(true); _motors.Halt(); _motors.Backward(255); Thread.Sleep(100); if (currentSenV >= 2000) { //do nothing Debug.Print("Too close..."); _motors.Halt(); _motors.Right(255); } } } }
public MotorDiagnosticsController(MotorController motorController) { _motorController = motorController; }
// Start is called before the first frame update void Start() { RC = GetComponent <RobotController>(); MC_L = RC.getMotorsControllers()[0]; MC_R = RC.getMotorsControllers()[1]; }
void Start() { controller = MotorController.GetInstance(); }
public MovementController(MotorController motorController) { //... }
public async Task <bool> MoveToTarget(string ip, int port) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var controlWordEP = new ControlWordController(); var statusWordEP = new StatusWordController(); var motorEP = new MotorController(); uint acceleration = Convert.ToUInt32(Acceleration * Precision); uint deceleration = Convert.ToUInt32(Deceleration * Precision); uint velocity = Convert.ToUInt32(TargetVelocity * Precision); int targetPosition = Convert.ToInt32(TargetPosition * Precision); // Set operation mode motorEP.SetOperationMode(ip, port, 1); Stopwatch operationMode = new Stopwatch(); operationMode.Start(); while (motorEP.GetOperationModeDisplay(ip, port) != 1) { Debug.WriteLine("OPM wrong"); await Delay(10); } operationMode.Stop(); Debug.WriteLine($"OperationMode Set: {operationMode.ElapsedMilliseconds}"); // Check if start is reseted ControlWord controlWord = new ControlWord(); controlWord = controlWordEP.GetControlWord(ip, port); if (controlWord.Bit04) { Debug.WriteLine("Reset bit 4, Z190"); controlWord.Bit04 = false; controlWordEP.SetControlWord(ip, port, controlWord); } // Set relative positioning if (RelativePosition) { if (!controlWord.Bit06) { controlWord.Bit06 = true; controlWordEP.SetControlWord(ip, port, controlWord); // Check relative positioning is set (Bit 6) controlWord = controlWordEP.GetControlWord(ip, port); if (controlWord.Bit06 != RelativePosition) { return(false); } } } else { if (controlWord.Bit06) { controlWord.Bit06 = false; controlWordEP.SetControlWord(ip, port, controlWord); // Check relative positioning is set (Bit 6) controlWord = controlWordEP.GetControlWord(ip, port); if (controlWord.Bit06 != RelativePosition) { return(false); } } } int positionWindow = motorEP.GetPositionWindow(ip, port); // Set acceleration motorEP.SetProfileAcceleration(ip, port, acceleration); if (acceleration != motorEP.GetProfileAcceleration(ip, port)) { return(false); } // Set deceleration motorEP.SetProfileDeceleration(ip, port, deceleration); if (deceleration != motorEP.GetProfileDeceleration(ip, port)) { return(false); } // Set velocity motorEP.SetProfileVelocity(ip, port, velocity); if (velocity != motorEP.GetProfileVelocity(ip, port)) { return(false); } // Set target position motorEP.SetTargetPosition(ip, port, targetPosition); if (targetPosition != motorEP.GetTargetPosition(ip, port)) { return(false); } // Check controlWord bit 4 (Start) controlWord = controlWordEP.GetControlWord(ip, port); if (controlWord.Bit04) { Debug.WriteLine("Reset bit 4 Z243"); controlWord.Bit04 = false; controlWordEP.SetControlWord(ip, port, controlWord); await Delay(50); } ////////////////// Debug stopwatch.Stop(); Debug.WriteLine($"Instruction Time: {stopwatch.ElapsedMilliseconds}"); stopwatch = new Stopwatch(); stopwatch.Start(); ////////////////// // Start controlWord.Bit04 = true; controlWordEP.SetControlWord(ip, port, controlWord); await Delay(50); // Check statusWord bit 12 while (!NewTargetSet(statusWordEP.GetStatusWord(ip, port))) { Debug.WriteLine("Check bit 12"); await Delay(50); } // Reset start controlWord.Bit04 = false; controlWordEP.SetControlWord(ip, port, controlWord); while (!TargetReached(statusWordEP.GetStatusWord(ip, port)) && !InPositionWindow(targetPosition, motorEP.GetActualPosition(ip, port), positionWindow)) { Stopwatch targetReached = new Stopwatch(); targetReached.Start(); if (TargetReached(statusWordEP.GetStatusWord(ip, port)) && !InPositionWindow(targetPosition, motorEP.GetActualPosition(ip, port), positionWindow)) { Debug.WriteLine("--------------------------"); Debug.WriteLine("-----------Error----------"); Debug.WriteLine("--------------------------"); } targetReached.Stop(); Debug.WriteLine($"Target check time: {targetReached.ElapsedMilliseconds}"); await Delay(50); } stopwatch.Stop(); Debug.WriteLine($"Movement Time: {stopwatch.ElapsedMilliseconds}"); return(true); }
private void Start() { controller = GetComponent <MotorController>(); }
void Start() { _motorController = transform.parent.GetComponent<MotorController>(); }
void Start() { _motorController = GetComponent<MotorController>(); _direction = transform.FindChild("Direction").transform; }
private void BTN_StartTest_Click(object sender, EventArgs e) { BTN_StartTest.Enabled = false; /*parameter initialize*/ List <double> z2Positions; try { z2Positions = Properties.Settings.Default.MotorZ2Positions.Split(',').ToList().Select(x => double.Parse(x)).ToList(); } catch (Exception ex) { MessageBox.Show("Failed to retrieve test positions, please check the configuration file"); BTN_StartTest.Enabled = true; return; } /*device initialize*/ CameraController camera = UC_CameraCtrl.Device; Result ret = camera.Open(UC_CameraCtrl.TestType); if (ret.Id != "Ok" && ret.Id != "Dummy") { MessageBox.Show($"Failed to open camera for {UC_CameraCtrl.TestType}({ret.Id})"); //return; } MotorController motor = MotorCtrlUC.Device; if (motor == null) { MessageBox.Show($"Failed to open motor for {UC_CameraCtrl.TestType}"); } for (int i = 0; i < z2Positions.Count; i++) { double offset = 0; if (i == 0) { offset = z2Positions[0]; } else { offset = z2Positions[i] - z2Positions[i - 1]; } motor.MoveZ2(offset); Thread.Sleep(2000); ret = camera.Read(z2Positions[i].ToString()); UpdateImg(ret.Param as Bitmap); ret = camera.Analyze(UC_CameraCtrl.TestType, z2Positions[i]); UpdateImg(ret.Param as Bitmap); if (camera.Imgs.Last().Circles.Count == 0) { MessageBox.Show("Failed to find any circles in recent images"); break; } Thread.Sleep(1000); } ret = camera.Calculate(UC_CameraCtrl.TestType); UC_Result.Update(ret.Param as Dictionary <string, string>); BTN_StartTest.Enabled = true; }
public MotorCtrlUC() { InitializeComponent(); Device = new MotorController(ConfigurationManager.AppSettings["DS102Port"]); Device.Observer = UpdatePosition; }