001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package org.wpilib.math.optimization.ocp;
006
007import org.wpilib.math.autodiff.Variable;
008import org.wpilib.math.autodiff.VariableMatrix;
009
010/**
011 * Function representing an explicit or implicit ODE, or a discrete state transition function.
012 *
013 * <ul>
014 *   <li>Explicit: dx/dt = f(t, x, u, *)
015 *   <li>Implicit: f(t, [x dx/dt]', u, *) = 0
016 *   <li>State transition: xₖ₊₁ = f(t, xₖ, uₖ, dt)
017 * </ul>
018 */
019@FunctionalInterface
020public interface DynamicsFunction {
021  /**
022   * Applies this function with the arguments and returns the result.
023   *
024   * @param t Time in seconds.
025   * @param x State vector.
026   * @param u Input vector.
027   * @param dt Timestep duration in seconds.
028   * @return The state derivative dx/dt.
029   */
030  VariableMatrix apply(Variable t, VariableMatrix x, VariableMatrix u, Variable dt);
031}