calculate_jerk
Calculate jerk, the rate of change of acceleration, from time series acceleration data. Useful for assessing ride comfort and mechanical stress.
Instructions
Calculate jerk (rate of change of acceleration).
Jerk = da/dt is important for comfort in vehicles and mechanical design.
Args:
times: Time values in seconds (or JSON string)
accelerations: Acceleration vectors [[x,y,z], ...] in m/s² (or JSON string)
Returns:
Dict containing:
- jerks: Jerk vectors [[x,y,z], ...] in m/s³
- average_jerk: Average jerk [x,y,z] in m/s³
- max_jerk_magnitude: Maximum jerk magnitude in m/s³
Example:
result = await calculate_jerk(
times=[0, 1, 2, 3],
accelerations=[[0,0,0], [2,0,0], [4,0,0], [6,0,0]]
)
# jerk_x ≈ 2 m/s³ (constant)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| times | Yes | ||
| accelerations | Yes |
Implementation Reference
- MCP tool wrapper for calculate_jerk. Handles JSON string parsing, delegates to core function in kinematics.py. Decorated with @tool for MCP registration.
@tool # type: ignore[arg-type] async def calculate_jerk( times: Union[list[float], str], accelerations: Union[list[list[float]], str], ) -> dict: """Calculate jerk (rate of change of acceleration). Jerk = da/dt is important for comfort in vehicles and mechanical design. Args: times: Time values in seconds (or JSON string) accelerations: Acceleration vectors [[x,y,z], ...] in m/s² (or JSON string) Returns: Dict containing: - jerks: Jerk vectors [[x,y,z], ...] in m/s³ - average_jerk: Average jerk [x,y,z] in m/s³ - max_jerk_magnitude: Maximum jerk magnitude in m/s³ Example: result = await calculate_jerk( times=[0, 1, 2, 3], accelerations=[[0,0,0], [2,0,0], [4,0,0], [6,0,0]] ) # jerk_x ≈ 2 m/s³ (constant) """ from ..kinematics import JerkCalculationRequest, calculate_jerk as calc_jerk # Parse inputs parsed_times = json.loads(times) if isinstance(times, str) else times parsed_accelerations = ( json.loads(accelerations) if isinstance(accelerations, str) else accelerations ) request = JerkCalculationRequest( times=parsed_times, accelerations=parsed_accelerations, ) response = calc_jerk(request) return response.model_dump()