Make sure you’ve completed the installation steps before continuing.
Train a Model
Create a new Python file and add the following code:Use the Trained Model
Once training completes, you can pull the model from code and simulate a trajectory:Understanding the Code
Model Inputs and Outputs
Onyx comes with a set of built-in tools to help create and manage model features:Output: Features the model predicts (acceleration)Input: Features fed into the model (velocity, position, control_input)
parent and relation parameters of the Input and Output classes define how features update in the simulate() method:
'derivative': The parent is the time derivative of this feature'delta': The parent is the delta change per timestep'equal': The parent is equal to this feature (feed output straight back in as input)
acceleration -> velocity -> position.
You can also always use the underlying PyTorch model as is without calling simulate():
Simulation
Thesimulate() method handles multi-step prediction:
- Takes initial state values in
x0 - Takes the full trajectory for non-derived features in
external_inputs - Automatically integrates states using the defined relations to roll out the trajectory
- Returns a
SimulationResultwith trajectory data for all features
parent and relation).