public void InitDetection() { signDetector = new SignDetector(); courseAdvisor = new CourseAdvisor(droneControl.BottomCameraPictureSize, droneControl.BottomCameraFieldOfViewDegrees); course = new CourseList(); InitDetectionSliders(); }
void FixedUpdate() { // Calculate and display speed to GUI speed = -(wheelRR.radius * Mathf.PI * wheelRR.rpm * 60f / 1000f); TextField.text = "Speed: " + speed.ToString("0.00") + "km/h RPM: " + (-wheelRL.rpm); float scaledTorque = -Input.GetAxis("Vertical") * torque; if (wheelRL.rpm < idealRPM) { scaledTorque = Mathf.Lerp(scaledTorque / 10f, scaledTorque, wheelRL.rpm / idealRPM); } else { scaledTorque = Mathf.Lerp(scaledTorque, 0, (wheelRL.rpm - idealRPM) / (maxRPM - idealRPM)); } // Counter the inertial forces on the vehicle by adding force to springs DoRollBar(wheelFR, wheelFL); DoRollBar(wheelRR, wheelRL); // Get user input for turning or, if autopilot is active, axis value from DLL if (SignDetector.getAxis() == -2.0) { wheelFR.steerAngle = Input.GetAxis("Horizontal") * turnRadius; wheelFL.steerAngle = Input.GetAxis("Horizontal") * turnRadius; } else { wheelFR.steerAngle = (float)SignDetector.getAxis() * turnRadius; wheelFL.steerAngle = (float)SignDetector.getAxis() * turnRadius; } // Set torque to drive-wheels wheelFR.motorTorque = driveMode == DriveMode.Rear ? 0 : scaledTorque; wheelFL.motorTorque = driveMode == DriveMode.Rear ? 0 : scaledTorque; wheelRR.motorTorque = driveMode == DriveMode.Front ? 0 : scaledTorque; wheelRL.motorTorque = driveMode == DriveMode.Front ? 0 : scaledTorque; // If brakes are active, apply brakeTorque if (Input.GetButton("Fire1")) { wheelFR.brakeTorque = brakeTorque; wheelFL.brakeTorque = brakeTorque; wheelRR.brakeTorque = brakeTorque; wheelRL.brakeTorque = brakeTorque; } else { wheelFR.brakeTorque = 0; wheelFL.brakeTorque = 0; wheelRR.brakeTorque = 0; wheelRL.brakeTorque = 0; } rotateWheels(); }