Beispiel #1
0
        private void initializeEngine(agxPowerLine.PowerLine drivetrain, agxDriveTrain.PidControlledEngine engine)
        {
            // set a value for the inertia of the rotational dimension
            engine.setInertia(0.4);
            drivetrain.setSource(engine);
            // Create a rpm/torque table


            var rpm_torque_table = new agx.RealPairVector();

            foreach (var t in m_rpm_torque)
            {
                rpm_torque_table.Add(new agx.RealPair(t.First, t.Second));
            }

            engine.setRPMTorqueTable(rpm_torque_table);
            engine.ignition(true);
            engine.setThrottle(1.0);
        }
Beispiel #2
0
        protected override bool Initialize()
        {
            if (!agx.Runtime.instance().isModuleEnabled("AgX-DriveTrain"))
            {
                Debug.LogWarning("WheelLoader requires a valid license for the AGX Dynamics module: AgX-DriveTrain", this);
            }

            PowerLine = new agxPowerLine.PowerLine();
            PowerLine.setName(name);
            Engine          = new agxDriveTrain.CombustionEngine(InletVolume);
            TorqueConverter = new agxDriveTrain.TorqueConverter();
            GearBox         = new agxDriveTrain.GearBox();
            Differentials[(int)DifferentialLocation.Rear]   = new agxDriveTrain.Differential();
            Differentials[(int)DifferentialLocation.Center] = new agxDriveTrain.Differential();
            Differentials[(int)DifferentialLocation.Front]  = new agxDriveTrain.Differential();

            m_actuators[(int)WheelLocation.LeftFront]  = new agxPowerLine.RotationalActuator(LeftFrontHinge.GetInitialized <Constraint>().Native.asHinge());
            m_actuators[(int)WheelLocation.RightFront] = new agxPowerLine.RotationalActuator(RightFrontHinge.GetInitialized <Constraint>().Native.asHinge());
            m_actuators[(int)WheelLocation.LeftRear]   = new agxPowerLine.RotationalActuator(LeftRearHinge.GetInitialized <Constraint>().Native.asHinge());
            m_actuators[(int)WheelLocation.RightRear]  = new agxPowerLine.RotationalActuator(RightRearHinge.GetInitialized <Constraint>().Native.asHinge());

            foreach (var wheelHinge in WheelHinges)
            {
                wheelHinge.GetController <TargetSpeedController>().Enable = false;
            }

            var engineTorqueConverterShaft    = new agxDriveTrain.Shaft();
            var torqueConverterGearBoxShaft   = new agxDriveTrain.Shaft();
            var gearBoxCenterDiffShaft        = new agxDriveTrain.Shaft();
            var centerDiffRearDiffShaft       = new agxDriveTrain.Shaft();
            var centerDiffFrontDiffShaft      = new agxDriveTrain.Shaft();
            var frontDiffFrontLeftWheelShaft  = new agxDriveTrain.Shaft();
            var frontDiffFrontRightWheelShaft = new agxDriveTrain.Shaft();
            var rearDiffRearLeftWheelShaft    = new agxDriveTrain.Shaft();
            var rearDiffRearRightWheelShaft   = new agxDriveTrain.Shaft();

            PowerLine.setSource(Engine);

            Engine.connect(engineTorqueConverterShaft);
            engineTorqueConverterShaft.connect(TorqueConverter);
            TorqueConverter.connect(torqueConverterGearBoxShaft);
            torqueConverterGearBoxShaft.connect(GearBox);
            GearBox.connect(gearBoxCenterDiffShaft);
            gearBoxCenterDiffShaft.connect(Differentials[(int)DifferentialLocation.Center]);

            Differentials[(int)DifferentialLocation.Center].connect(centerDiffFrontDiffShaft);
            centerDiffFrontDiffShaft.connect(Differentials[(int)DifferentialLocation.Front]);
            Differentials[(int)DifferentialLocation.Front].connect(frontDiffFrontLeftWheelShaft);
            Differentials[(int)DifferentialLocation.Front].connect(frontDiffFrontRightWheelShaft);
            frontDiffFrontLeftWheelShaft.connect(m_actuators[(int)WheelLocation.LeftFront]);
            frontDiffFrontRightWheelShaft.connect(m_actuators[(int)WheelLocation.RightFront]);

            Differentials[(int)DifferentialLocation.Center].connect(centerDiffRearDiffShaft);
            centerDiffRearDiffShaft.connect(Differentials[(int)DifferentialLocation.Rear]);
            Differentials[(int)DifferentialLocation.Rear].connect(rearDiffRearLeftWheelShaft);
            Differentials[(int)DifferentialLocation.Rear].connect(rearDiffRearRightWheelShaft);
            rearDiffRearLeftWheelShaft.connect(m_actuators[(int)WheelLocation.LeftRear]);
            rearDiffRearRightWheelShaft.connect(m_actuators[(int)WheelLocation.RightRear]);

            var munu = new agx.RealPairVector(new agx.RealPair[]
            {
                new agx.RealPair(-0.0001, 0.00),
                new agx.RealPair(0.00001, 0.50),
                new agx.RealPair(0.00011, 2.00),
                new agx.RealPair(0.00100, 2.00),
                new agx.RealPair(0.20000, 1.10),
                new agx.RealPair(0.40000, 1.15),
                new agx.RealPair(0.60000, 1.05),
                new agx.RealPair(0.80000, 1.01),
                new agx.RealPair(0.90000, 0.99),
                new agx.RealPair(1.00000, 0.98),
                new agx.RealPair(1.00100, 0.98)
            });

            TorqueConverter.setMuTable(munu);
            TorqueConverter.setMaxMultiplication(2.0);
            TorqueConverter.setPumpTorqueReferenceRPM(1000.0);

            GearBox.setGearRatios(new agx.RealVector(new double[] { GearRatios.x, GearRatios.y }));
            GearBox.gearUp();

            GetSimulation().add(PowerLine);

            var f1 = new agx.Frame();
            var f2 = new agx.Frame();

            agx.Constraint.calculateFramesFromBody(new agx.Vec3(),
                                                   agx.Vec3.X_AXIS(),
                                                   gearBoxCenterDiffShaft.getRotationalDimension().getOrReserveBody(),
                                                   f1,
                                                   null,
                                                   f2);
            BrakeHinge = new agx.Hinge(gearBoxCenterDiffShaft.getRotationalDimension().getOrReserveBody(),
                                       f1,
                                       null,
                                       f2);
            GetSimulation().add(BrakeHinge);

            try {
                GetOrCreateTireModelProperties();
                foreach (WheelLocation location in Enum.GetValues(typeof(WheelLocation)))
                {
                    GetOrCreateTireModel(location)?.GetInitialized <TwoBodyTire>();
                }
            }
            catch (Exception e) {
                Debug.LogWarning("Unable to initialize tire models: " + e.Message);
            }

            return(true);
        }