/// <summary> /// Initialize the whole vehicle /// </summary> private void initializeVehicle() { if (m_initialized) { return; } var sim = GetSimulation(); Assert.IsNotNull(sim); // Access the hinge used for steering m_steeringHinge = GetSimulation().getHinge("WaistHingeTurning"); Assert.IsNotNull(m_steeringHinge); m_steeringHinge.getMotor1D().setEnable(true); m_steeringHinge.getMotor1D().setSpeed(0.0f); m_steeringHinge.getMotor1D().setLockedAtZeroSpeed(true); /// Access all the hinges attached to all the rims var hingeJointNames = new List <string> { "RightRearHinge", "LeftRearHinge", "RightFrontHinge", "LeftFrontHinge" }; foreach (var n in hingeJointNames) { var hinge = sim.getHinge(n); Assert.IsNotNull(hinge, string.Format("Hinge {0} is missing in Simulation", n)); m_wheelHinges.Add(hinge.getName(), hinge); } if (m_chassieRigidBody == null) { m_chassieRigidBody = sim.getRigidBody("FrontBody"); Assert.IsNotNull(m_chassieRigidBody); } //Hinge.GetController<TargetSpeedController>().Enable = true; // Make sure body exists before I start using it. //Body.GetInitialized<RigidBody>().Native.setEnable(false); initializeTires(); // Create the Vehicle class that initializes brakes etc. m_vehicle = new Vehicle(GetSimulation(), m_wheelHinges); m_initialized = true; }
void updateForceRange() { var steering_range = new agx.RangeReal(-SteeringForce, SteeringForce); m_steeringHinge.getMotor1D().setForceRange(steering_range); }