generate_motion_graph
Compute velocity and acceleration from position data over time, extracting X, Y, Z, or magnitude component for motion graph generation.
Instructions
Generate motion graph data (position, velocity, acceleration vs time).
Calculates velocity and acceleration from position data and extracts
the specified component for graphing.
Args:
times: Time values in seconds (or JSON string)
positions: Position vectors [[x,y,z], ...] in meters (or JSON string)
component: Which component to analyze - "x", "y", "z", or "magnitude" (default)
Returns:
Dict containing:
- times: Time values
- positions: Position values (selected component)
- velocities: Velocity values (selected component)
- accelerations: Acceleration values (selected component)
- max_velocity: Maximum velocity magnitude
- max_acceleration: Maximum acceleration magnitude
- component: Which component was analyzed
Example:
result = await generate_motion_graph(
times=[0, 1, 2, 3],
positions=[[0,0,0], [5,0,0], [20,0,0], [45,0,0]],
component="x"
)
# Automatically calculates v and a
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| times | Yes | ||
| positions | Yes | ||
| component | No | magnitude |
Implementation Reference
- MCP tool handler that parses inputs, creates a MotionGraphRequest, delegates to the core generate_motion_graph function, and returns the response dict.
async def generate_motion_graph( times: Union[list[float], str], positions: Union[list[list[float]], str], component: str = "magnitude", ) -> dict: """Generate motion graph data (position, velocity, acceleration vs time). Calculates velocity and acceleration from position data and extracts the specified component for graphing. Args: times: Time values in seconds (or JSON string) positions: Position vectors [[x,y,z], ...] in meters (or JSON string) component: Which component to analyze - "x", "y", "z", or "magnitude" (default) Returns: Dict containing: - times: Time values - positions: Position values (selected component) - velocities: Velocity values (selected component) - accelerations: Acceleration values (selected component) - max_velocity: Maximum velocity magnitude - max_acceleration: Maximum acceleration magnitude - component: Which component was analyzed Example: result = await generate_motion_graph( times=[0, 1, 2, 3], positions=[[0,0,0], [5,0,0], [20,0,0], [45,0,0]], component="x" ) # Automatically calculates v and a """ from ..kinematics import MotionGraphRequest, generate_motion_graph as gen_graph # Parse inputs parsed_times = json.loads(times) if isinstance(times, str) else times parsed_positions = json.loads(positions) if isinstance(positions, str) else positions request = MotionGraphRequest( times=parsed_times, positions=parsed_positions, component=component, # type: ignore ) response = gen_graph(request) return response.model_dump()