JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
7 days ago4 views
👨‍💻Programming
/*@!Encoding:65001*/
includes
{
  
}
variables
{
  double v_prev = 0.0;
  double t_prev = 0.0;
  double acc = 0.0;
}

on start
{
  t_prev = timeNow() / 1000.0;  // secondi
}

on message TSU::TCO1
{
  double v;
  double t;
  double dt;
  double acc_raw;

  // lettura segnale dal messaggio
  v = this.TcoVehSpeed;

  // conversione km/h → m/s
  v = v / 3.6;

  // tempo attuale
  t = timeNow() / 1000.0;

  dt = t - t_prev;

  if (dt > 0)
  {
    acc_raw = (v - v_prev) / dt;

    // filtro per stabilizzare
    acc = 0.8 * acc + 0.2 * acc_raw;
  }

  v_prev = v;
  t_prev = t;

  // scrivi system variable
  @sysvar::Calc_acc = (double)acc;
}
← Back to timeline