Skip to content

Conversation

@juan-g-bonilla
Copy link
Contributor

@juan-g-bonilla juan-g-bonilla commented Dec 10, 2025

Description

This PR introduces a reusable linear time invariant (LTI) system module to support state space models inside MuJoCo based dynamics, plus two concrete subclasses.

An LTI system has:

x_dot = A x + B u  
y = C x + D u

where A, B, C, and D are constant matrices. This form covers many control schemes, filters, delays, and smoothing blocks.

Key additions:

  • LinearTimeInvariantSystem (abstract base class)

    • Stores matrices A, B, C, D.
    • Implements generic propagation:
      • Reads u via virtual readInput.
      • Computes x_dot = A x + B u.
      • Computes y = C x + D u.
      • Writes y via virtual writeOutput.
    • Automatically registers and manages state.
    • Provides dimensional inference for input, state, and output.
    • Includes helpers:
      • configureSecondOrder(wn, zeta, k)
      • configureSecondOrder(wn_vec, zeta_vec, k_vec) for MIMO.
    • Performs strict consistency checks in Reset.
  • Concrete subclasses

    • SingleActuatorLTI: SISO actuator model mapped to SingleActuatorMsgPayload.
    • ForceAtSiteLTI: 3 input, 3 output force model mapped to ForceAtSiteMsgPayload.
  • SWIG interface

    • Adds linearTimeInvariantSystem.i with directors enabled, which means that you can actually crease subclasses of LinearTimeInvariantSystem implemented in Python.
  • Tests

    • Adds complete first order and second order unit tests validating both C++ and Python subclass behavior.
  • Release notes

    • Updated to include all new modules.

Verification

Validation performed through automated tests:

  • First order test

    • Executes both:
      • C++ SingleActuatorLTI
      • Python subclass of LinearTimeInvariantSystem
    • Configures x_dot = -a x + a u with step input u = 1.
    • Confirms:
      • Final value matches analytic solution.
      • Sizes of input, output, and state are correct.
  • Second order test

    • Uses configureSecondOrder(wn, zeta) with critical damping.
    • Validates:
      • Convergence to steady state.
      • No overshoot.
      • Time history matches analytic critically damped step response.

Both tests integrate into an MJScene and are skipped when MuJoCo is disabled.
No existing tests were changed.

Documentation

New release notes entries added, headers include detailed doxygen comments.

A scenario using this new model will be added through #1195.

Future work

Add other SysModel based on LTI systems. Demonstrate usage in (a) scenario(s).

@juan-g-bonilla juan-g-bonilla self-assigned this Dec 10, 2025
@juan-g-bonilla juan-g-bonilla added the enhancement New feature or request label Dec 10, 2025
@juan-g-bonilla juan-g-bonilla moved this to 🏗 In progress in Basilisk Dec 10, 2025
@juan-g-bonilla juan-g-bonilla marked this pull request as ready for review December 10, 2025 07:09
@juan-g-bonilla juan-g-bonilla requested a review from a team as a code owner December 10, 2025 07:09
@juan-g-bonilla juan-g-bonilla moved this from 🏗 In progress to 👀 In review in Basilisk Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Add support for Linear Time Invariant StatefulSysModel

2 participants