Skip to content

Latest commit

 

History

History
139 lines (101 loc) · 3.88 KB

README.md

File metadata and controls

139 lines (101 loc) · 3.88 KB

TreadJS

A JavaScript library for modeling and realtime simulation of automotive tires.

import { Pacejka2002, TireProperties } from '@hivoltagexyz/tread'

// Load tire properties
const properties = new TireProperties()
properties.fromTirFile(
  await Deno.readTextFileSync('./racing-tire.tir'),
)

// Create and initialize a magic formula model
const pac2002Model = new Pacejka2002({
  tireProperties: properties,
})
// Decide to handle or ignore any errors that arise during initialization
const initErrors = pac2002Model.initializeFromProperties()

// Set our model inputs
const slipAngle = Math.PI / 6
const slipRatio = 0.25

// Get our model outputs
const latForceOutputVector = [0, 0, 0, 0]
pac2002Model.computeLateralForce(
  slipAngle,
  pac2002Model.verticalParameters.fNomin,
  0,
  1.0,
  latForceOutputVector,
)
const lateralForce = latForceOutputVector[0]

const longitudinalForce = pac2002Model.computeLongitudinalForce(
  slipRatio,
  pac2002Model.verticalParameters.fNomin,
  0,
  1.0,
)

Supported Models

Installation

Tread runs everywhere standard Web APIs are present. Install it for local use with any JavaScript runtime, or use it in the browser.

Browser

import * as Tread from 'https://jsr.io/@hivoltagexyz/tread/2024.6.5/src/mod.js'

Deno

deno add @hivoltagexyz/tread

Node.js

npx jsr add @hivoltagexyz/tread

Bun

bunx jsr add @hivoltagexyz/tread

Cloudflare Workers

npx jsr add @hivoltagexyz/tread

Demos and Examples

See examples/ for a growing list of example use cases for this library.

Documentation

See jsr.io/@hivoltagexyz/tread/doc for this library's documentation.

Versioning

This project employs a Calendar Versioning scheme following the form YYYY.MM.PATCH. Patch level releases will NOT contain known breaking changes. Releases that contain breaking changes will change the date component (YYYY.MM) of the library's version.

Contributing

Contributions to Tread are welcome. Please view the project's contribution guidelines in docs/contributing.md.

Legal

Copyright 2024 Gerald Nash

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Third Party Notices

Third party notices can be found in this repository's THIRD_PARTY_NOTICES file.