window_obstacle_sa_loop_BASE.sa 867 B

12345678910111213141516171819202122232425
  1. // outdated
  2. semantic adaptation window_obstacle_sa_loop overrides master
  3. for fmu window_sa, obstacle
  4. input ports motor_speed
  5. output ports reaction_torque
  6. param MAXITER = 100;
  7. param REL_TOL = 1e-8;
  8. param ABS_TOL = 1e-8;
  9. in rules {
  10. true -> {
  11. height := height; // do_step will always use the last values, local_step does not advance time so will replace the last signal values! therefore, we must set the signal at time t+h of reaction_torque and height. this is done by a very weird statement:
  12. reaction_force := 0; // and just initialise other values at time t+h
  13. var prev_height; // to compare new value with previous value
  14. for (var iter in 0 .. MAXITER) {
  15. prev_height := height;
  16. local_step(obstacle); // with delayed input for height
  17. local_step(window_sa);
  18. if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
  19. break;
  20. }
  21. }
  22. } --> { };
  23. }