Example #1
0
        public static void AddContactMaterial(string a, string b, double restitution, double friction, double youngsModulus)
        {
            var material_A       = new agx.Material(a);
            var material_B       = new agx.Material(b);
            var contact_material = new agx.ContactMaterial(material_A, material_B);

            contact_material.setFrictionCoefficient(restitution);
            contact_material.setRestitution(friction);
            contact_material.setYoungsModulus(youngsModulus);
            sim_Instance.add(material_A);
            sim_Instance.add(material_B);
            sim_Instance.add(contact_material);
        }
Example #2
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);
        }
 public void OnInitialize(agxSDK.Simulation simulation)
 {
     m_simulationStepEvents = new SimulationStepEvents(this);
     simulation.add(m_simulationStepEvents);
 }