Basics of PhysX Vehicle SDK

Similar documents
Extracting Tire Model Parameters From Test Data

Development of a Multibody Systems Model for Investigation of the Effects of Hybrid Electric Vehicle Powertrains on Vehicle Dynamics.

The Car Tutorial Part 2 Creating a Racing Game for Unity

Identification of tyre lateral force characteristic from handling data and functional suspension model

Modeling tire vibrations in ABS-braking

Parameters. Version 1.0 6/18/2008 1

Users are provided with the same installation file for both Workstation and Render node MadCard_WS.exe

Design and Analysis of suspension system components

FRONTAL OFF SET COLLISION

View Numbers and Units

Technical Report Lotus Elan Rear Suspension The Effect of Halfshaft Rubber Couplings. T. L. Duell. Prepared for The Elan Factory.

Jaroslav Maly & team CAE departament. AV ENGINEERING, a.s.

A double-wishbone type suspension is used in the front. A multi-link type suspension is used in the rear. Tread* mm (in.) 1560 (61.

Chassis development at Porsche

Skid against Curb simulation using Abaqus/Explicit

Tech Tip: Trackside Tire Data

Kinematic Analysis of Roll Motion for a Strut/SLA Suspension System Yung Chang Chen, Po Yi Tsai, I An Lai

2015 The MathWorks, Inc. 1

Torsen Differentials - How They Work and What STaSIS Does to Improve Them For the Audi Quattro

SPMM OUTLINE SPECIFICATION - SP20016 issue 2 WHAT IS THE SPMM 5000?

ISO 8855 INTERNATIONAL STANDARD. Road vehicles Vehicle dynamics and road-holding ability Vocabulary

PRESEASON CHASSIS SETUP TIPS

OptimumDynamics. Computational Vehicle Dynamics Help File

Part 1. The three levels to understanding how to achieve maximize traction.

BIG BAR SOFT SPRING SET UP SECRETS

Accident Reconstruction Tech and Heavy Trucks

VHDL (and verilog) allow complex hardware to be described in either single-segment style to two-segment style

Vitesse. Simulation of Active Vehicle Systems using SIMPACK Code Export

Advanced Vehicle Performance by Replacing Conventional Vehicle Wheel with a Carbon Fiber Reinforcement Composite Wheel

CHAPTER 4 MODELING OF PERMANENT MAGNET SYNCHRONOUS GENERATOR BASED WIND ENERGY CONVERSION SYSTEM

Basic Wheel Alignment Techniques

TECHNICAL NOTE. NADS Vehicle Dynamics Typical Modeling Data. Document ID: N Author(s): Chris Schwarz Date: August 2006

NUMERICAL ANALYSIS OF IMPACT BETWEEN SHUNTING LOCOMOTIVE AND SELECTED ROAD VEHICLE

SPMM OUTLINE SPECIFICATION - SP20016 issue 2 WHAT IS THE SPMM 5000?

SUMMARY OF STANDARD K&C TESTS AND REPORTED RESULTS

Design And Analysis Of Two Wheeler Front Wheel Under Critical Load Conditions

Cornering & Traction Test Rig MTS Flat-Trac IV CT plus

SAE Mini BAJA: Suspension and Steering

Electronic Paint- Thickness Gauges What They Are, and Why You Need Them

4 Bar Linkage Calculator v3.0 Bump Travel 4.00 in Droop Travel in Static Geometry: Bump Geometry: Droop Geometry: Upper Links x y z Upper Links

Tutorials Tutorial 3 - Automotive Powertrain and Vehicle Simulation

Crash Cart Barrier Project Teacher Guide

Design and Integration of Suspension, Brake and Steering Systems for a Formula SAE Race Car


ALTERNATING CURRENT - PART 1

LG CORVETTE GT2 COIL OVERS

The Influence of Roll and Weight Transfer on Vehicle Handling

Analysis and control of vehicle steering wheel angular vibrations

Angular Momentum Problems Challenge Problems

Modification of IPG Driver for Road Robustness Applications

ME 455 Lecture Ideas, Fall 2010

Design of a Gearbox for an electric FSAE vehicle

Environmental Envelope Control

CNG Fuel System Integrity

VIBRATION ANALYSIS OPERATIONAL DEFLECTION SHAPES & MODE SHAPES VERIFICATION OF ANALYTICAL MODELLING MATTIA PIRON GIOVANNI BORTOLAN LINO CORTESE

Accident Reconstruction & Vehicle Data Recovery Systems and Uses

SAE Mini BAJA: Suspension and Steering

SIMULATING A CAR CRASH WITH A CAR SIMULATOR FOR THE PEOPLE WITH MOBILITY IMPAIRMENTS

Implementation and application of Simpackmulti-attribute vehicle models at Toyota Motor Europe

Design, analysis and mounting implementation of lateral leaf spring in double wishbone suspension system

Structural Analysis of Student Formula Race Car Chassis

Suspension systems and components

ALIGNING A 2007 CADILLAC CTS-V

STIFFNESS CHARACTERISTICS OF MAIN BEARINGS FOUNDATION OF MARINE ENGINE

Torque steer effects resulting from tyre aligning torque Effect of kinematics and elastokinematics

NEW DESIGN AND DEVELELOPMENT OF ESKIG MOTORCYCLE

Wheel Alignment And Diagnostic Angles (STE04)

Wheeled Mobile Robots

Dipl.-Ing. Thorsten Pendzialek Dipl.-Ing. Matthias Mrosek. Model-Based Testing of Driver Assistance Systems for Counterbalance Forklift Trucks

Booming Noise Optimization on an All Wheel Drive Vehicle

ALWAYS ON THE SAFE SIDE

Design of Suspension and Steering system for an All-Terrain Vehicle and their Interdependence

Reduction of Self Induced Vibration in Rotary Stirling Cycle Coolers

X4-X7 Hyper 600cc Chassis Setup Guide

The Mark Ortiz Automotive

DESIGN, ANALYSIS AND FABRICATION OF BRAKING SYSTEM WITH REAR INBOARD BRAKES IN BAJA ATV

MECA0492 : Vehicle dynamics

Research on Skid Control of Small Electric Vehicle (Effect of Velocity Prediction by Observer System)

Simulation of Collective Load Data for Integrated Design and Testing of Vehicle Transmissions. Andreas Schmidt, Audi AG, May 22, 2014

Simulating Rotary Draw Bending and Tube Hydroforming

KISSsys application:

Mechanical Considerations for Servo Motor and Gearhead Sizing

BIMEE-007 B.Tech. MECHANICAL ENGINEERING (BTMEVI) Term-End Examination December, 2013

Full Vehicle Durability Prediction Using Co-simulation Between Implicit & Explicit Finite Element Solvers

Vehicle Dynamic Simulation Using A Non-Linear Finite Element Simulation Program (LS-DYNA)

Appendix X New Features in v2.4 B

V 2.0. Version 9 PC. Setup Guide. Revised:

The Application of Simulink for Vibration Simulation of Suspension Dual-mass System

Camber Angle. Wheel Alignment. Camber Split. Caster Angle. Caster and Ride Height. Toe Angle. AUMT Wheel Alignment

Dynamic Behavior Analysis of Hydraulic Power Steering Systems

Virtual Durability Simulation for Chassis of Commercial vehicle

Using ABAQUS in tire development process

Chapter 15. Inertia Forces in Reciprocating Parts

Multirotor UAV propeller development using Mecaflux Heliciel

Roehrig Engineering, Inc.

Working Paper No. HDH-11-08e (11th HDH meeting, 10 to 12 October 2012) Heavy Duty Hybrid Powertrain Testing

What you need to know about Electric Locos

4.5 Ride and Roll Kinematics Front Suspension

Sequoia power steering rack service Match-mounting wheels and tires Oxygen sensor circuit diagnosis

DOUBLE WISHBONE SUSPENSION SYSTEM

Transcription:

PhysX Vehicles 1

PhysX Collision and Dynamics SDK (now) owned by Nvidia Most common physics library used in games for this course Includes lots of vehicle specific features Experimenting with a change to allow deeper usage this year Previous years we allowed rigid body physics libraries but required building driving model from scratch Getting a good driving model is by far the biggest challenge for teams, and was often holding back game quality significantly

Basics of PhysX Vehicle SDK Essential tasks Set up library Create some meshes Allocate simulation data Allocate actor and add to world Per frame : Setup inputs to drive and steering Per frame : Wheel raycasts Per frame : Tick simulation Caveat : I have not personally built anything with this Sample code : PhysX-SDK/Sample/SampleVehicle

Initialization PxPhysics Base context for all operations PxAllocatorCallback* allocator = &gdefaultallocatorcallback; mfoundation = PxCreateFoundation(PX_PHYSICS_VERSION, *allocator, getsampleerrorcallback()); mphysics = PxCreatePhysics(PX_PHYSICS_VERSION, *mfoundation, scale, recordmemoryallocations, mprofilezonemanager);

Initialization PxCooking Utility class for creating meshes in physics PhysX vehicles uses meshes for all objects in vehicle system PxCookingParams params(scale); params.meshweldtolerance = 0.001f; params.meshpreprocessparams = PxMeshPreprocessingFlags(PxMeshPreprocessingFlag::eWELD_VERTICES PxMeshPreprocessingFlag::eREMOVE_UNREFERENCED_VERTICES PxMeshPreprocessingFlag::eREMOVE_DUPLICATED_TRIANGLES); mcooking = PxCreateCooking(PX_PHYSICS_VERSION, *mfoundation, params);

Initialization PxScene Container for all object in simulation Global world properties (i.e. gravity) Any objects not in vehicle system can be added straight to this with minimal extra work Probably going to want to add at least one static object mscene = mphysics->createscene(scenedesc); mscene.setgravity(pxvec3(0.0f, -9.81f, 0.0f)); mmaterials = getphysics().creatematerial(staticfriction, dynamicfriction, restitution); PxRigidStatic* plane = PxCreatePlane(*mPhysics, PxPlane(PxVec3(0,1,0), 0), *mmaterial); mscene->addactor(*plane);

Initialization Setup vehicle support Few essential parameters need to be set No context object, just free functions PxInitVehicleSDK(physics); PxVec3 up(0,1,0); PxVec3 forward(0,0,1); PxVehicleSetBasisVectors(up,forward); //Set the vehicle update mode to be immediate velocity changes. PxVehicleSetUpdateMode(PxVehicleUpdateMode::eVELOCITY_CHANGE);

Mesh creation PxConvexMeshDesc convexdesc; convexdesc.points.count = numverts; convexdesc.points.stride = sizeof(pxvec3); convexdesc.points.data = verts; convexdesc.flags = PxConvexFlag::eCOMPUTE_CONVEX PxConvexFlag::eINFLATE_CONVEX; PxConvexMesh* convexmesh = NULL; PxDefaultMemoryOutputStream buf; if(cooking.cookconvexmesh(convexdesc, buf)) PxDefaultMemoryInputData id(buf.getdata(), buf.getsize()); convexmesh = physics.createconvexmesh(id);

Set up simulation data void createvehicle4wsimulationdata (const PxF32 chassismass, PxConvexMesh* chassisconvexmesh, const PxF32 wheelmass, PxConvexMesh** wheelconvexmeshes, const PxVec3* wheelcentreoffsets, PxVehicleWheelsSimData& wheelsdata, PxVehicleDriveSimData4W& drivedata, PxVehicleChassisData& chassisdata) //Extract the chassis AABB dimensions from the chassis convex mesh. const PxVec3 chassisdims=computechassisaabbdimensions(chassisconvexmesh); //The origin is at the center of the chassis mesh. //Set the center of mass to be below this point and a little towards the front. const PxVec3 chassiscmoffset=pxvec3(0.0f,-chassisdims.y*0.5f+0.65f,0.25f); //Now compute the chassis mass and moment of inertia. //Use the moment of inertia of a cuboid as an approximate value for the chassis moi. PxVec3 chassismoi ((chassisdims.y*chassisdims.y + chassisdims.z*chassisdims.z)*chassismass/12.0f, (chassisdims.x*chassisdims.x + chassisdims.z*chassisdims.z)*chassismass/12.0f, (chassisdims.x*chassisdims.x + chassisdims.y*chassisdims.y)*chassismass/12.0f); //A bit of tweaking here. The car will have more responsive turning if we reduce the //y-component of the chassis moment of inertia. chassismoi.y*=0.8f; //Let's set up the chassis data structure now. chassisdata.mmass=chassismass; chassisdata.mmoi=chassismoi; chassisdata.mcmoffset=chassiscmoffset; //Compute the sprung masses of each suspension spring using a helper function. PxF32 suspsprungmasses[4]; PxVehicleComputeSprungMasses(4,wheelCentreOffsets,chassisCMOffset,chassisMass,1,suspSprungMasses); //Extract the wheel radius and width from the wheel convex meshes. PxF32 wheelwidths[4]; PxF32 wheelradii[4]; computewheelwidthsandradii(wheelconvexmeshes,wheelwidths,wheelradii); //Now compute the wheel masses and inertias components around the axle's axis. //http://en.wikipedia.org/wiki/list_of_moments_of_inertia PxF32 wheelmois[4]; for(pxu32 i=0;i<4;i++) wheelmois[i]=0.5f*wheelmass*wheelradii[i]*wheelradii[i]; //Let's set up the wheel data structures now with radius, mass, and moi. PxVehicleWheelData wheels[4]; for(pxu32 i=0;i<4;i++) wheels[i].mradius=wheelradii[i]; wheels[i].mmass=wheelmass; wheels[i].mmoi=wheelmois[i]; wheels[i].mwidth=wheelwidths[i]; //Disable the handbrake from the front wheels and enable for the rear wheels wheels[pxvehicledrive4wwheelorder::efront_left].mmaxhandbraketorque=0.0f; wheels[pxvehicledrive4wwheelorder::efront_right].mmaxhandbraketorque=0.0f; wheels[pxvehicledrive4wwheelorder::erear_left].mmaxhandbraketorque=4000.0f; wheels[pxvehicledrive4wwheelorder::erear_right].mmaxhandbraketorque=4000.0f; //Enable steering for the front wheels and disable for the front wheels. wheels[pxvehicledrive4wwheelorder::efront_left].mmaxsteer=pxpi*0.3333f; wheels[pxvehicledrive4wwheelorder::efront_right].mmaxsteer=pxpi*0.3333f; wheels[pxvehicledrive4wwheelorder::erear_left].mmaxsteer=0.0f; wheels[pxvehicledrive4wwheelorder::erear_right].mmaxsteer=0.0f; //Let's set up the tire data structures now. //Put slicks on the front tires and wets on the rear tires. PxVehicleTireData tires[4]; tires[pxvehicledrive4wwheelorder::efront_left].mtype=tire_type_slicks; tires[pxvehicledrive4wwheelorder::efront_right].mtype=tire_type_slicks; tires[pxvehicledrive4wwheelorder::erear_left].mtype=tire_type_wets; tires[pxvehicledrive4wwheelorder::erear_right].mtype=tire_type_wets; //Let's set up the suspension data structures now. PxVehicleSuspensionData susps[4]; for(pxu32 i=0;i<4;i++) susps[i].mmaxcompression=0.3f; susps[i].mmaxdroop=0.1f; susps[i].mspringstrength=35000.0f; susps[i].mspringdamperrate=4500.0f; susps[pxvehicledrive4wwheelorder::efront_left].msprungmass=suspsprungmasses[pxvehicledrive4wwheelorder::efront_left]; susps[pxvehicledrive4wwheelorder::efront_right].msprungmass=suspsprungmasses[pxvehicledrive4wwheelorder::efront_right]; susps[pxvehicledrive4wwheelorder::erear_left].msprungmass=suspsprungmasses[pxvehicledrive4wwheelorder::erear_left]; susps[pxvehicledrive4wwheelorder::erear_right].msprungmass=suspsprungmasses[pxvehicledrive4wwheelorder::erear_right]; //Set up the camber. //Remember that the left and right wheels need opposite camber so that the car preserves symmetry about the forward direction. //Set the camber to 0.0f when the spring is neither compressed or elongated. const PxF32 camberangleatrest=0.0; susps[pxvehicledrive4wwheelorder::efront_left].mcamberatrest=camberangleatrest; susps[pxvehicledrive4wwheelorder::efront_right].mcamberatrest=-camberangleatrest; susps[pxvehicledrive4wwheelorder::erear_left].mcamberatrest=camberangleatrest; susps[pxvehicledrive4wwheelorder::erear_right].mcamberatrest=-camberangleatrest; //Set the wheels to camber inwards at maximum droop (the left and right wheels almost form a V shape) const PxF32 camberangleatmaxdroop=0.001f; susps[pxvehicledrive4wwheelorder::efront_left].mcamberatmaxdroop=camberangleatmaxdroop;

Simulation data setup Three key classes Wheel - Suspension, radius, etc.. Chassis - Body of the vehicle Drive - How are power and steering applied PxVehicleWheelsSimData* wheelssimdata=pxvehiclewheelssimdata::allocate(4); PxVehicleDriveSimData4W drivesimdata; PxVehicleChassisData chassisdata; createvehicle4wsimulationdata (chassismass,chassisconvexmesh, 20.0f,wheelConvexMeshes4,wheelCentreOffsets4, *wheelssimdata,drivesimdata,chassisdata);

Setup examples Chassis centre of mass const PxVec3 chassiscmoffset=pxvec3(0.0f,-chassisdims.y*0.5f+0.65f,0.25f); chassisdata.mcmoffset=chassiscmoffset; Suspension spring parameters PxVehicleSuspensionData susps[4]; for(pxu32 i=0;i<4;i++) susps[i].mmaxcompression=0.3f; susps[i].mmaxdroop=0.1f; susps[i].mspringstrength=35000.0f; susps[i].mspringdamperrate=4500.0f; for(pxu32 i=0;i<4;i++) wheelsdata.setsuspensiondata(i,susps[i]); //... Engine properties PxVehicleEngineData engine; engine.mpeaktorque=500.0f; engine.mmaxomega=600.0f;//approx 6000 rpm drivedata.setenginedata(engine);

Setup actor and drivetrain instance Previous object were all static data, need an instance as well Actor is set of rigid bodies for wheel Drive is instance of drivetrain Actor and drivetrain get linked Actor added to scene PxRigidDynamic* vehactor = physics.createrigiddynamic(pxtransform(pxidentity)); for(pxu32 i=0;i<numwheelgeometries;i++) PxShape* wheelshape=vehactor->createshape(*wheelgeometries[i],*wheelmaterial); wheelshape->setqueryfilterdata(vehqryfilterdata); wheelshape->setsimulationfilterdata(wheelcollfilterdata); wheelshape->setlocalpose(wheellocalposes[i]); // Need to add chassis as well //... PxVehicleDrive4W* car = PxVehicleDrive4W::allocate(4); car->setup(&physics,vehactor,*wheelssimdata,drivesimdata,0); mscene.addactor(*vehactor);

Per-frame actions Input setup PxVehicleDrive4WRawInputData carrawinputs; carrawinputs.setanalogaccel(mgamepadaccel); carrawinputs.setanalogbrake(mgamepadcarbrake); carrawinputs.setanalogsteer(mgamepadcarsteer); PxVehicleDrive4WSmoothAnalogRawInputsAndSetAnalogInputs (gcarpadsmoothingdata,gsteervsforwardspeedtable, carrawinputs,timestep,isinair,(pxvehicledrive4w&)focusvehicle); Wheel raycasts if(null==msqwheelraycastbatchquery) msqwheelraycastbatchquery=msqdata->setupbatchedscenequery(scene); PxVehicleSuspensionRaycasts(mSqWheelRaycastBatchQuery,mNumVehicles,mVehicles, msqdata->getraycastqueryresultbuffersize(),msqdata->getraycastqueryresultbuffer());

Per-frame actions (cont d) Update simulation PxVehicleUpdates(timestep,gravity,*mSurfaceTirePairs, numvehicles,vehicles,vehiclewheelqueryresults); scene->simulate(mstepsize, NULL, scratchblock, scratchblocksize);

Conclusions Use the PhysX vehicle library unless you have a really good reason not to Spoiler : you don t have a good reason Mechanics of setup are complex, don t be afraid to steal the PhysX sample code The driving model in the PhysX sample app is now the baseline, need to make it better if you want good marks on the driving portion of things