The math models in VehicleSim products can be extended several ways:
- The VS Math Model can be connected to a model in another simulation environment, such as Simulink.
- Equations and and variables can be added using VS Commands.
- Variables can be exchanged with custom programs as is done with Simulink.
- Variables in the math model can be accessed directly by custom programs that support C/C++ pointers.
This page describes options 3 and 4 (above) for using custom simulation programs that make use of the VS API.
VS API: VehicleSim Application Program Interface
A VS Solver is a program in a VehicleSim product that reads input files, writes output files, and calculates variables from an internal math model. Although each specific VS Solver is intended to represent a different kind of vehicle or other simulated system, all operate the same way when it comes to reading and writing files, solving differential equations, and communicating with other software.
VS Solvers are provided for Windows OS as dynamically linked library (DLL) files. As such, they are controlled by other software using the VS application program interface (API) — a set of functions that exist in all VS Solver programs.
The same solver
DLL is used in all Windows simulation environments (built-in, Simulink, LabView,
ASCET, command-line EXE, etc.). When no other software is used, the DLLs are
loaded and run directly by the VS Browser (e.g.,
Support for other software such as Simulink
is handled by small "wrapper
programs" that load and run the VS Solver and communicate as needed with
the other software.
Besides supporting the use of a VS Solver DLL with the VS Browser and commercial simulation software, the VS API works well for use with custom Windows programs.
Basic Control with VS API
The API supports basic steps in simulation: initializing, running, and terminating. Any programming language that can load a DLL and access the public functions can be used to run simulations using VS Solvers.
Variables can be exchanged in the same manner used with Simulink and other commercial simulation environments. Arrays are set up for import and export variables (in these cases, going back and forth between the VS Solver and the custom wrapper program).
Example source code (Visual Basic, MATLAB, C) is provided showing how to use the VS API to run the VS solvers.
The VS API also provides access to the 3D geometry of the VS roads for use with external models such as user-defined vehicle models and advanced driver models that look ahead at the road geometry.
Advanced Control with C/C++
Running a VS Solver from ANSI C is simpler than from VB or MATLAB, because variables and functions can be shared directly via C pointers.
The VS API gives access to any variable or parameter in the math model that has a keyword. These include hundreds of parameters and thousands of variables.
The VS Solvers also support the use of externally defined callback functions at various times during the simulation. The API is used to provide pointers to the externally defined functions, and they are added to lists of functions used multiple times during each time step in the simulation. The support of callback function allows even tighter integration between the wrapper and the VS Solver than is possible with the once-per-time-step communication used with import and export arrays.
VehicleSim products include example custom program in MATLAB, VB, and ANSI C that show how to load and run the VS Solver, and possibly use the custom program to interact with the VS math models.
CarSim and TruckSim math models are used in over 1400 driving simulators. The vast majority of these were done with the ordinary Windows versions of the products. The makers of the driving simulators combine third-party visualization software and databases with the VS Math Model. Communication with the DLL is handled using the VS API functions.
Motorsport Team Applications
CarSim is in use today by sophisticated top-tier teams to reduce the workload of producing simulations. The VS API makes it possible to run third-party tire models, advanced damper models, detailed aero maps, and alternative engines and transmissions, to name just a few. Complex detailed arrangements can be accommodated, such as highly asymmetric suspensions, preloaded components, third springs, and inerters.
Race engineers extend CarSim to get the fastest available simulation together with all the advanced systems and components unique to their level of competition. CarSim is in use right now to simulate 7 post rigs, conduct optimization studies, study tire wear effects on lap time, examine trade-offs in set ups for mechanical versus aerodynamic grip, and to optimize setup of differentials and control systems.
CarSim engineers have worked with race engineers from NASCAR, Formula 1, ALMS, and IndyCar series who want to add their theories and knowledge to a fast, stable, and proven simulation tool.
VS Vehicle Model FeaturesPaths and Roads
Moving Objects and ADAS Sensors
Core VehicleSim TechnologyGUI, Database, and Documentation
Fast and Parametric Math Model Solvers
Viewing Results: Animation and Plotting
Advanced ApplicationsSimulink, LabVIEW, and ASCET
Automation and COM
Real-Time OptionsReal-Time HIL Testing