window_obstacle_sa_loop_BASE.sa 854 B

1234567891011121314151617181920212223
  1. semantic adaptation window_obstacle_sa_loop overrides master
  2. for fmu window_sa, obstacle
  3. input ports motor_speed
  4. output ports reaction_torque
  5. param MAXITER = 100;
  6. param REL_TOL = 1e-8;
  7. param ABS_TOL = 1e-8;
  8. in rules {
  9. true -> {
  10. 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:
  11. reaction_force := 0; // and just initialise other values at time t+h
  12. var prev_height; // to compare new value with previous value
  13. for (var iter in 0 .. MAXITER) {
  14. prev_height := height;
  15. local_step(obstacle); // with delayed input for height
  16. local_step(window_sa);
  17. if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
  18. break;
  19. }
  20. }
  21. } --> { };
  22. }