void Start() { os = FindObjectOfType <ObstacleSpawner>(); dc = FindObjectOfType <DudeController>(); a = GetComponent <Animator>(); sc = FindObjectOfType <SpeedControl>(); }
public void GetPositionTest() { //forward var speedControl = new SpeedControl(30, 160, .0001, .02); Assert.AreEqual(30, speedControl.GetPosition(-1)); Assert.AreEqual(30, speedControl.GetPosition(0)); Assert.AreEqual(30.005, speedControl.GetPosition(10)); Assert.AreEqual(30.5, speedControl.GetPosition(100)); Assert.AreEqual(48, speedControl.GetPosition(1000)); Assert.AreEqual(68, speedControl.GetPosition(2000)); Assert.AreEqual(88, speedControl.GetPosition(3000)); Assert.AreEqual(148, speedControl.GetPosition(6000)); Assert.AreEqual(158, speedControl.GetPosition(6500)); Assert.AreEqual(159.995, speedControl.GetPosition(6690)); Assert.AreEqual(160, speedControl.GetPosition(7000)); //reverse speedControl = new SpeedControl(160, 30, .0001, .02); Assert.AreEqual(160, speedControl.GetPosition(-1)); Assert.AreEqual(160, speedControl.GetPosition(0)); Assert.AreEqual(159.995, speedControl.GetPosition(10)); Assert.AreEqual(159.5, speedControl.GetPosition(100)); Assert.AreEqual(142, speedControl.GetPosition(1000)); Assert.AreEqual(122, speedControl.GetPosition(2000)); Assert.AreEqual(102, speedControl.GetPosition(3000)); Assert.AreEqual(42, speedControl.GetPosition(6000)); Assert.AreEqual(32, speedControl.GetPosition(6500)); Assert.AreEqual(30.004999999999995, speedControl.GetPosition(6690)); Assert.AreEqual(30, speedControl.GetPosition(7000)); }
public static void Start() { RuntimeObject.Init(); RigidBody.Init(); CollisionBody.Init(); CollisionSensor.Init(); TransportSurface.Init(); CollisionMaterial.Init(); HingeJoint.Init(); SlidingJoint.Init(); CylindricalJoint.Init(); FixedJoint.Init(); BallJoint.Init(); AngularLimit.Init(); LinearLimit.Init(); AngularSpring.Init(); LinearSpring.Init(); SpeedControl.Init(); PositionControl.Init(); BreakingConstraint.Init(); GearCoupling.Init(); CamCoupling.Init(); ElecCamCoupling.Init(); PreventCollision.Init(); ChangeMaterial.Init(); ComponentPart.Init(); SourceBehavior.Init(); SinkBehavior.Init(); GraphControl.Init(); ExternalConnection.Init(); SignalAdapter.Init(); Signal.Init(); ProxyObject.Init(); RuntimeParameters.Init(); }
// Use this for initialization void Start() { speedScript = GetComponent <SpeedControl>(); origHeight = GetComponent <CapsuleCollider>().height; motor = GetComponent <PlayerMotor> (); crouchPosition = new Vector3(mainObject.transform.localPosition.x, mainObject.transform.localPosition.y - 0.5f, mainObject.transform.localPosition.z); }
//used to zoom the camera into the sun to show off the AABB on the space ship //uses the custom LERP function to bring the camera between the start position and the sun void Update() { GameObject controller = GameObject.Find("SpeedController"); SpeedControl spController = controller.GetComponent <SpeedControl>(); speedScalar = spController.Speed; if (Input.GetKeyDown(KeyCode.Keypad1)) { PlanetSelect = GameObject.Find("Sun"); IsFollowing = true; returntobase = false; } if (Input.GetKeyDown(KeyCode.Keypad0)) { returntobase = true; IsFollowing = false; } if (IsFollowing == true & returntobase == false) { Vector3 temp = PlanetSelect.transform.position; Vector3 newPos = new Vector3(temp.x, temp.y + 30, temp.z - 50); transform.position = VectorMaths.LERP(transform.position, newPos, Time.deltaTime); } if (IsFollowing == false & returntobase == true) { Vector3 temp1 = new Vector3(0, 200, -400); transform.position = VectorMaths.LERP(transform.position, temp1, Time.deltaTime); } }
// Use this for initialization void Start() { initY = transform.position.y; speedC = GameObject.Find("GvrMain").GetComponent <SpeedControl>(); obsC = GameObject.Find("GvrMain").GetComponent <ObstacleControl>(); moveC = GameObject.Find("GvrMain").GetComponent <MoveNew> (); }
// Use this for initialization void Start() { state = State.grounded; _initialPos = InitialPosition.position; _initialRot = InitialPosition.rotation; _initialScale = InitialPosition.localScale; _jumpFuelTime = JumpFuelTime; _xSpeedControl = new SpeedControl(walkDragForce, airDragForce, brakeForce, airBrakeForce, speed, speedRun); }
// Update is called once per frame void Update() { GameObject controller = GameObject.Find("SpeedController"); SpeedControl spController = controller.GetComponent <SpeedControl>(); speedScalar = spController.Speed; Rotate(); orbit(); }
public void TestHelperMethod001_GivenSpeedControl_WhenGetDistanceSegmentsHelperMethodIsCalled_ThenReturnTheDistanceBetweenEachSegment() { double[] distanceSamples = new double[] { 0.0, 0.19, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25 }; double[] expectedResult = new double[] { 0.19, 0.31, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25 }; double[] actualResult = SpeedControl.GetDistanceSegments(distanceSamples); CollectionAssert.AreEqual(expectedResult, actualResult); }
public void TestHelperMethod002_GivenSpeedControl_WhenGetSegmentsAverageSpeedsMethodIsCalled_ThenReturnTheFloorIntegerAverageSpeedPerSegment() { double[] distanceSegments = new double[] { 0.19, 0.31, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25 }; int seconds = 15; int[] expectedResult = new int[] { 45, 74, 60, 60, 60, 60, 60, 60, 60 }; int[] actualResult = SpeedControl.GetSegmentsAverageSpeeds(distanceSegments, seconds); CollectionAssert.AreEqual(expectedResult, actualResult); }
public void Test003_GivenSpeedControl_WhenMoreThanTwoDistanceSamplesExist_ThenReturnTheCorrectSpeed() { double[] distanceSamples = new double[] { 0.0, 0.19, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25 }; int seconds = 15; int expectedResult = 74; int actualResult = SpeedControl.GetMaxAverageSpeedPerHour(seconds, distanceSamples); Assert.AreEqual(expectedResult, actualResult); }
public void Test001_GivenSpeedControl_WhenLessThanTwoDistanceSamplesExist_ThenZeroIsReturned() { double[] distanceSamples = new double[] { 0.0 }; int seconds = 25; int expectedResult = 0; int actualResult = SpeedControl.GetMaxAverageSpeedPerHour(seconds, distanceSamples); Assert.AreEqual(expectedResult, actualResult); }
public void TestSpeedControl(byte speedControl) { var expected = new SpeedControl(speedControl).Compile(); using var ns = PacketTestUtilities.CreateTestNetState(); ns.SendSpeedControl((SpeedControlSetting)speedControl); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }
// Use this for initialization void Start() { tu = GetComponent <TownUpgrade>(); du = GetComponent <DudeUpgrade>(); slider.value = sliderVal; sc = FindObjectOfType <SpeedControl>(); ChangeSpeed(startSpeed); dude = FindObjectOfType <DudeController>(); ec = GetComponent <EndingControl>(); }
public void TestSpeedControl(byte speedControl) { var data = new SpeedControl(speedControl).Compile(); Span <byte> expectedData = stackalloc byte[6]; var pos = 0; expectedData.Write(ref pos, (byte)0xBF); // Packet ID expectedData.Write(ref pos, (ushort)6); // Length expectedData.Write(ref pos, (ushort)0x26); // Command expectedData.Write(ref pos, speedControl); AssertThat.Equal(data, expectedData); }
public void Dispose() { FilteredSource.Dispose(); FilteredSource = null; SpeedControl.Dispose(); SpeedControl = null; audio.Dispose(); audio = null; audioStream.Dispose(); audioStream = null; audioGraph.Dispose(); audioGraph = null; audioAnalysis.Dispose(); audioAnalysis = null; GC.Collect(); }
private void speedBar_Scroll(object sender, EventArgs e) { TrackBar speedBar = (TrackBar)sender; if (speedBar.Name == "speedbarJoint") { speedJ_txt.Text = speedBar.Value.ToString() + " %"; } else { speedXYX_txt.Text = speedBar.Value.ToString() + " %"; } try { SpeedControl.SpeedChange(speedBar.Value, serialPort); } catch (Exception ex) { MessageBox.Show("Wystąpił błąd!\n" + ex.ToString(), "Error", MessageBoxButtons.OK); } }
public SatNavView(SatNavModel model) { //InitializeComponent(); this.model = model; this.model.ModelChanged += HandleModelChanged; northButton = new Button(); southButton = new Button(); eastButton = new Button(); westButton = new Button(); feedbackLabel = new Label(); speedControl = new SpeedControl(); this.SatNavView_Load(null, EventArgs.Empty); }
// Use this for initialization void Start() { spdControl = this.GetComponent <SpeedControl>(); second = 60f; minute = 2; }
public void Awake() { sc = FindObjectOfType <SpeedControl>(); dc = FindObjectOfType <DudeController>(); os = FindObjectOfType <ObstacleSpawner>(); }
public override void OnEnter() { base.OnEnter(); speedcontrol = Owner.gameObject.GetComponent <SpeedControl>(); }
//moons orbit around a planet, and as such need to find the position of the planet they orbit before calculating their orbit path void OrbitAround() { GameObject controller = GameObject.Find("SpeedController"); SpeedControl spController = controller.GetComponent <SpeedControl>(); SpeedScalar = spController.Speed; worldPos = Planet.transform.position; OrbitRotation.y += Time.deltaTime * orbitSpeed * SpeedScalar; Vector3[] TransformedVertices = new Vector3[ModelSpaceVertices.Length]; yawAngle += Time.deltaTime; //create the first rotation matrix for individual planet rotation Matrix4by4 rollMatrix = new Matrix4by4 (new Vector3(Mathf.Cos(yawAngle), Mathf.Sin(yawAngle), 0), new Vector3(-Mathf.Sin(yawAngle), Mathf.Cos(yawAngle), 0), new Vector3(0, 0, 1), Vector3.zero); Matrix4by4 pitchmatrix = new Matrix4by4( new Vector3(1, 0, 0), new Vector3(0, Mathf.Cos(yawAngle), Mathf.Sin(yawAngle)), new Vector3(0, -Mathf.Sin(yawAngle), Mathf.Cos(yawAngle)), Vector3.zero); Matrix4by4 yawmatrix = new Matrix4by4( new Vector3(Mathf.Cos(yawAngle), 0, -Mathf.Sin(yawAngle)), new Vector3(0, 1, 0), new Vector3(Mathf.Sin(yawAngle), 0, Mathf.Cos(yawAngle)), Vector3.zero); //create second rotation matrix for the planet's orbit Matrix4by4 OrbitRoll = new Matrix4by4 (new Vector3(Mathf.Cos(OrbitRotation.z), Mathf.Sin(OrbitRotation.z), 0), new Vector3(-Mathf.Sin(OrbitRotation.z), Mathf.Cos(OrbitRotation.z), 0), new Vector3(0, 0, 1), Vector3.zero); Matrix4by4 OrbitPitch = new Matrix4by4( new Vector3(1, 0, 0), new Vector3(0, Mathf.Cos(OrbitRotation.x), Mathf.Sin(OrbitRotation.x)), new Vector3(0, -Mathf.Sin(OrbitRotation.x), Mathf.Cos(OrbitRotation.x)), Vector3.zero); Matrix4by4 OrbitYaw = new Matrix4by4( new Vector3(Mathf.Cos(OrbitRotation.y), 0, -Mathf.Sin(OrbitRotation.y)), new Vector3(0, 1, 0), new Vector3(Mathf.Sin(OrbitRotation.y), 0, Mathf.Cos(OrbitRotation.y)), Vector3.zero); Matrix4by4 RotationOfOrbit = OrbitYaw * (OrbitPitch * OrbitRoll); Matrix4by4 R = yawmatrix * (pitchmatrix * rollMatrix); offset = RotationOfOrbit * orbitDistance; newPos = worldPos + offset; Matrix4by4 T = new Matrix4by4(new Vector3(1, 0, 0), new Vector3(0, 1, 0) , new Vector3(0, 0, 1), new Vector3(newPos.x + offset.x, newPos.y + offset.y, newPos.z + offset.z)); Matrix4by4 S = new Matrix4by4(new Vector3(1, 0, 0) * Scale, new Vector3(0, 1, 0) * Scale, new Vector3(0, 0, 1) * Scale, Vector3.zero); Matrix4by4 M = T * R * S; for (int i = 0; i < TransformedVertices.Length; i++) { TransformedVertices[i] = M * ModelSpaceVertices[i]; } MeshFilter MF = GetComponent <MeshFilter>(); MF.mesh.vertices = TransformedVertices; MF.mesh.RecalculateNormals(); MF.mesh.RecalculateBounds(); }
private void Capture_ImageGrabbed(object sender, EventArgs e) { try { int sizeOfPicBox = Convert.ToInt32(picBoxCameraView.Height); currentFrame = cameraCapture.QueryFrame().ToImage <Bgr, Byte>(); hsvFrame = currentFrame.Convert <Hsv, Byte>(); hsvFindColorFrame = ImageProcessing.ImageProcessing.FindColor(hsvFrame); binaryFrame = ImageProcessing.ImageProcessing.ConvertImageToBinary(hsvFindColorFrame); rectanglesFist = fistClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12); rectanglesPalm = palmClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12); rectanglesTomb = tombClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12); rectanglesTwoFingers = twoFingersClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12); rectanglesFinger = fingerClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12); rectanglesTwoFingers = victoryClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12); foreach (var rectangle in rectanglesPalm) { currentFrame.Draw(rectangle, new Bgr(50, 255, 50)); richTextBoxStatus.Text = string.Empty + "Run"; richTextBoxRecognitionData.Text = "x = " + rectangle.X + "y = " + rectangle.Y; MovingRobotXYZ.MoveRobotXYZ(rectangle, richTextBoxRecognitionData, serialPort); } foreach (var rectangle in rectanglesFist) { currentFrame.Draw(rectangle, new Bgr(255, 0, 0)); richTextBoxStatus.Text = string.Empty + "Stop"; } foreach (var rectangle in rectanglesTomb) { currentFrame.Draw(rectangle, new Bgr(128, 0, 128)); richTextBoxStatus.Text = string.Empty + "Chwytak ON"; SendingCommandsToRobot.SendCommand("HNDOFF1", serialPort); } foreach (var rectangle in rectanglesTwoFingers) { currentFrame.Draw(rectangle, new Bgr(75, 0, 130)); richTextBoxStatus.Text = string.Empty + "Chwytak OFF"; SendingCommandsToRobot.SendCommand("HNDON1", serialPort); } foreach (var rectangle in rectanglesVictory) { currentFrame.Draw(rectangle, new Bgr(0, 0, 128)); int actualSpeed = Convert.ToInt32(speedTxtBox.Text); int newSpeed; if (actualSpeed == 100) { newSpeed = 100; } else { newSpeed = actualSpeed + 10; } SpeedControl.SpeedChange(newSpeed, serialPort, speedTxtBox); } foreach (var rectangle in rectanglesFinger) { currentFrame.Draw(rectangle, new Bgr(135, 200, 255)); int actualSpeed = Convert.ToInt32(speedTxtBox.Text); int newSpeed; if (actualSpeed == 0) { newSpeed = 0; } else { newSpeed = actualSpeed - 10; } SpeedControl.SpeedChange(newSpeed, serialPort, speedTxtBox); } Bitmap bitmap = currentFrame.ToBitmap(); bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); picBoxCameraView.Image = bitmap; } catch (Exception) { } }
public void GoFaster() { SpeedControl.IncreaseSpeed(); }
private void Start() { speedScript = transform.root.GetComponent <SpeedControl>(); }
public void Connect(string strName, out SpeedControl item) { ExAddProperty(this.m_pSelf, strName, 4, 0x7918); item = null; }
public void Connect(string strName, out SpeedControl item) { item = RuntimeObject.FromPtr(ExGetProperty(this.m_pSelf, strName, 4, 0x7918)) as SpeedControl; }
void Start() { controller = GameObject.Find("SpeedController"); spController = controller.GetComponent <SpeedControl>(); }
public void GoSlower() { SpeedControl.DecreaseSpeed(); }
// Update section // --------------------------------------------------------------------------------------------- // Read the standard input values and translate them to the internal blocks. // Also set the state values expected by each block. // Called before each integration step. protected override void DoUpdateBlocks() { // Collect input and settings int[] inputData = data.Get(Channel.Input); int[] settingsData = data.Get(Channel.Settings); float brakePosition = Mathf.Clamp01(inputData[InputData.Brake] / 10000.0f); float handbrakePosition = Mathf.Clamp01(inputData[InputData.Handbrake] / 10000.0f); float throttlePosition = Mathf.Clamp01(inputData[InputData.Throttle] / 10000.0f); float steerPosition = Mathf.Clamp(inputData[InputData.Steer] / 10000.0f, -1.0f, 1.0f); int automaticGearInput = inputData[InputData.AutomaticGear]; int ignitionInput = inputData[InputData.Key]; // Process gear mode preventing direction changes when the vehicle is not stopped m_gearMode = Mathf.Clamp(automaticGearInput, (int)Gearbox.AutomaticGear.R, (int)Gearbox.AutomaticGear.D); if (m_gearMode != m_prevGearMode) { if (m_gearMode == (int)Gearbox.AutomaticGear.D && speed < -gearChangeMaxSpeed || m_gearMode == (int)Gearbox.AutomaticGear.R && speed > gearChangeMaxSpeed) { m_gearMode = m_prevGearMode; } else { m_prevGearMode = m_gearMode; } } // No throttle if the vehicle is switched off. if (ignitionInput < 0) { throttlePosition = 0.0f; } else { throttlePosition = SpeedControl.GetThrottle(speedControl, inputData, data.Get(Channel.Vehicle)); } // Process inputs // Input settings are configured in the car independently of the torque maps. // Being in a separate class allows all intermediate steps to be traced separately // (pedal > input > electrical torque > mechanical torque > wheel torque) int gear = m_gearMode - (int)Gearbox.AutomaticGear.N; m_throttleInput = input.GetThrottleInput(throttlePosition); m_brakePressure = input.GetBrakePressure(brakePosition); if (m_brakePressure > brakePressureThreshold) { m_throttleInput = 0.0f; } m_frontPowertrain.SetInputs(gear, m_throttleInput, m_brakePressure); m_rearPowertrain.SetInputs(gear, m_throttleInput, m_brakePressure); // Traction control if (gear != 0) { // Independent traction control per axle /* * int tcsOverride = settingsData[SettingsData.TcsOverride]; * if (tractionControl.enabled && tcsOverride != 2 || tcsOverride == 1) * { * float frontFinalRatio = frontDifferential.gearRatio * Mathf.Sign(gear); * float rearFinalRatio = rearDifferential.gearRatio * Mathf.Sign(gear); * float maxFrontRpm = TractionControl.GetMaxEngineRpm(this, tractionControl, 0, 1, frontFinalRatio, maxDriveRpm); * float maxRearRpm = TractionControl.GetMaxEngineRpm(this, tractionControl, 2, 3, rearFinalRatio, maxDriveRpm); * * // TO-DO: electric motors * // m_frontPowertrain.directDrive.maxRpm = maxFrontRpm; * // m_rearPowertrain.directDrive.maxRpm = maxRearRpm; * } */ // Apply motor input /* * float motorInput = throttlePosition * Mathf.Sign(gear); * m_rearPowertrain.electricMotor.motorInput = motorInput * frontToRearBalance; * m_frontPowertrain.electricMotor.motorInput = motorInput * (1.0f - frontToRearBalance); */ } // Steering if (settingsData[SettingsData.SteeringAidsOverride] != 2) { SteeringAids.Apply(this, steering, steeringAids, ref steerPosition); } m_steering.steerInput = steerPosition; m_steering.DoUpdate(); // Track changes in the inertia settings m_inertia.DoUpdate(cachedRigidbody); // Differential overrides m_frontPowertrain.differentialOverride = (Powertrain.DifferentialOverride)settingsData[SettingsData.DifferentialLock]; m_rearPowertrain.differentialOverride = (Powertrain.DifferentialOverride)settingsData[SettingsData.DifferentialLock]; }