Пример #1
0
        private void initializeDrivetrain()
        {
            // Create a drive train
            var driveTrain = new agxPowerLine.PowerLine();

            m_simulation.add(driveTrain);

            //  Create an engine.
            m_engine = new agxDriveTrain.PidControlledEngine();
            // Initialize the engine parameters
            initializeEngine(driveTrain, m_engine);

            //

            //                                    Engine
            //                                      ^
            //                                      |
            //                                      |
            //                                    Clutch
            //                                      ^
            //                                      |
            //                                      |
            //     FrontRightWheelActuator        GearBox           RearRightWheelActuator
            //          ^                           ^                         ^
            //          |                           |                         |
            //          |                           |                         |
            //   FrontDifferential < ------- CenterDifferential -----> RearDifferential
            //          |                                                     |
            //          |                                                     |
            //     FrontLeftWheelActuator                            RearLeftWheelActuator


            var engineShaft = new agxDriveTrain.Shaft();

            engineShaft.getRotationalDimension().setName("engineShaft");

            m_clutch = new agxDriveTrain.Clutch(0.0);
            var clutchShaft = new agxDriveTrain.Shaft();

            clutchShaft.getRotationalDimension().setName("clutchShaft");

            m_gearbox = new agxDriveTrain.GearBox();

            /// Initialize the gear box parameters
            initializeGearBox(m_gearbox);

            var gearBoxShaft = new agxDriveTrain.Shaft();

            gearBoxShaft.getRotationalDimension().setName("gearBoxShaft");

            bool status = false;

            status = m_engine.connect(agxPowerLine.UnitSide.UNIT_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT, engineShaft);
            Debug.Assert(status);
            status = m_clutch.connect(engineShaft, agxPowerLine.ConnectorSide.CONNECTOR_INPUT, agxPowerLine.UnitSide.UNIT_OUTPUT);
            Debug.Assert(status);
            status = m_clutch.connect(clutchShaft, agxPowerLine.ConnectorSide.CONNECTOR_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT);
            Debug.Assert(status);
            status = m_gearbox.connect(clutchShaft, agxPowerLine.ConnectorSide.CONNECTOR_INPUT, agxPowerLine.UnitSide.UNIT_OUTPUT);
            Debug.Assert(status);
            status = m_gearbox.connect(gearBoxShaft, agxPowerLine.ConnectorSide.CONNECTOR_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT);
            Debug.Assert(status);


            var centerDifferential = new agxDriveTrain.Differential();
            var frontDifferential  = new agxDriveTrain.Differential();

            frontDifferential.setLock(true);
            var rearDifferential = new agxDriveTrain.Differential();

            rearDifferential.setLock(true);

            var frontDifferentialShaft = new agxDriveTrain.Shaft();

            frontDifferentialShaft.getRotationalDimension().setName("frontDifferentialShaft");
            var rearDifferentialShaft = new agxDriveTrain.Shaft();

            rearDifferentialShaft.getRotationalDimension().setName("rearDifferentialShaft");

            var frontRightWheelShaft = new agxDriveTrain.Shaft();
            var rearRightWheelShaft  = new agxDriveTrain.Shaft();
            var frontLeftWheelShaft  = new agxDriveTrain.Shaft();
            var rearLeftWheelShaft   = new agxDriveTrain.Shaft();

            status = centerDifferential.connect(gearBoxShaft, agxPowerLine.ConnectorSide.CONNECTOR_INPUT, agxPowerLine.UnitSide.UNIT_OUTPUT);
            Debug.Assert(status);

            status = centerDifferential.connect(frontDifferentialShaft, agxPowerLine.ConnectorSide.CONNECTOR_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT);
            Debug.Assert(status);

            status = centerDifferential.connect(rearDifferentialShaft, agxPowerLine.ConnectorSide.CONNECTOR_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT);
            Debug.Assert(status);

            status = frontDifferential.connect(frontDifferentialShaft, agxPowerLine.ConnectorSide.CONNECTOR_INPUT, agxPowerLine.UnitSide.UNIT_OUTPUT);
            Debug.Assert(status);

            status = rearDifferential.connect(rearDifferentialShaft, agxPowerLine.ConnectorSide.CONNECTOR_INPUT, agxPowerLine.UnitSide.UNIT_OUTPUT);
            Debug.Assert(status);


            status = frontDifferential.connect(frontRightWheelShaft, agxPowerLine.ConnectorSide.CONNECTOR_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT);
            Debug.Assert(status);

            status = rearDifferential.connect(rearRightWheelShaft, agxPowerLine.ConnectorSide.CONNECTOR_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT);
            Debug.Assert(status);

            status = frontDifferential.connect(frontLeftWheelShaft, agxPowerLine.ConnectorSide.CONNECTOR_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT);
            Debug.Assert(status);

            status = rearDifferential.connect(rearLeftWheelShaft, agxPowerLine.ConnectorSide.CONNECTOR_OUTPUT, agxPowerLine.UnitSide.UNIT_INPUT);
            Debug.Assert(status);

            //  Now connect wheel shafts to constraints.
            var frontRightWheelActuator = new agxPowerLine.RotationalActuator(m_wheelHinges["RightFrontHinge"]);
            var frontLeftWheelActuator  = new agxPowerLine.RotationalActuator(m_wheelHinges["LeftFrontHinge"]);
            var rearRightWheelActuator  = new agxPowerLine.RotationalActuator(m_wheelHinges["RightRearHinge"]);
            var rearLeftWheelActuator   = new agxPowerLine.RotationalActuator(m_wheelHinges["LeftRearHinge"]);

            status = frontRightWheelShaft.connect(frontRightWheelActuator);
            Debug.Assert(status);

            status = frontLeftWheelShaft.connect(frontLeftWheelActuator);
            Debug.Assert(status);

            status = rearRightWheelShaft.connect(rearRightWheelActuator);
            Debug.Assert(status);

            status = rearLeftWheelShaft.connect(rearLeftWheelActuator);
            Debug.Assert(status);
        }
Пример #2
0
        protected override bool Initialize()
        {
            if (!agx.Runtime.instance().isModuleEnabled("AgX-DriveTrain"))
            {
                Debug.LogWarning("GearConstraint requires a valid license for the AGX Dynamics module: AgX-DriveTrain", this);
                return(false);
            }

            if (BeginActuatorConstraint?.GetInitialized <Constraint>() == null)
            {
                Debug.LogError("Invalid GearConstraint: Begin actuator constraint is invalid or null.", this);
                return(false);
            }
            if (EndActuatorConstraint?.GetInitialized <Constraint>() == null)
            {
                Debug.LogError("Invalid GearConstraint: End actuator constraint is invalid  or null.", this);
                return(false);
            }
            if (BeginActuatorConstraint == EndActuatorConstraint)
            {
                Debug.LogError("Invalid GearConstraint: Begin actuator constraint is the same instance as the end actuator constraint.", this);
                return(false);
            }
            if (!IsValidConstraintType(BeginActuatorConstraint.Type))
            {
                Debug.LogError($"Invalid GearConstraint: Begin actuator constraint type {BeginActuatorConstraint.Type} isn't supported.", this);
                return(false);
            }
            if (!IsValidConstraintType(EndActuatorConstraint.Type))
            {
                Debug.LogError($"Invalid GearConstraint: End actuator constraint type {EndActuatorConstraint.Type} isn't supported.", this);
                return(false);
            }

            // Rotational -> Rotational:
            //     Begin Actuator -> shaft -> Gear -> shaft -> End Actuator
            // Rotational -> Translational
            //     Begin Actuator -> shaft -> Gear -> shaft -> Converter (Rotational to Translational) -> End Actuator
            // Translational -> Translational
            //     Begin Actuator -> Converter -> shaft -> Gear -> shaft -> Converter -> End Actuator
            // Translational -> Rotational (Inverted)
            //     End Actuator -> shaft -> Gear -> shaft -> Converter -> Begin Actuator

            BeginActuator = CreateActuator(BeginActuatorConstraint);
            EndActuator   = CreateActuator(EndActuatorConstraint);

            IsInverted = BeginActuator.GetType() != EndActuator.GetType() &&
                         BeginActuator is agxPowerLine.TranslationalActuator &&
                         EndActuator is agxPowerLine.RotationalActuator;

            PowerLine = new agxPowerLine.PowerLine();
            Gear      = new agxDriveTrain.Gear(GearRatio);

            PowerLine.add(Gear);
            PowerLine.setName(name);

            var beginShaft = new agxDriveTrain.Shaft();
            var endShaft   = new agxDriveTrain.Shaft();

            Gear.connect(agxPowerLine.Side.INPUT, agxPowerLine.Side.OUTPUT, beginShaft);
            Gear.connect(agxPowerLine.Side.OUTPUT, agxPowerLine.Side.INPUT, endShaft);

            // Translational -> Rotational.
            if (IsInverted)
            {
                EndActuator.connect(endShaft);
                var converter = new agxPowerLine.RotationalTranslationalConnector();
                converter.connect((BeginActuator as agxPowerLine.TranslationalActuator).getInputRod());

                beginShaft.connect(converter);
            }
            // Rotational -> Translational.
            else if (BeginActuator is agxPowerLine.RotationalActuator &&
                     EndActuator is agxPowerLine.TranslationalActuator)
            {
                BeginActuator.connect(beginShaft);
                var converter = new agxPowerLine.RotationalTranslationalConnector();
                converter.connect((EndActuator as agxPowerLine.TranslationalActuator).getInputRod());

                endShaft.connect(converter);
            }
            // Translational -> Translational.
            else if (BeginActuator is agxPowerLine.TranslationalActuator &&
                     EndActuator is agxPowerLine.TranslationalActuator)
            {
                var beginConverter = new agxPowerLine.RotationalTranslationalConnector();
                var endConverter   = new agxPowerLine.RotationalTranslationalConnector();

                beginConverter.connect((BeginActuator as agxPowerLine.TranslationalActuator).getInputRod());
                endConverter.connect((EndActuator as agxPowerLine.TranslationalActuator).getInputRod());

                beginShaft.connect(beginConverter);
                endShaft.connect(endConverter);
            }
            // Rotational -> Rotational.
            else
            {
                BeginActuator.connect(beginShaft);
                EndActuator.connect(endShaft);
            }

            GetSimulation().add(PowerLine);

            return(true);
        }
Пример #3
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);
        }