//outdated

semantic adaptation window_obstacle_sa_loop
for fmu window_sa, obstacle
input ports motor_speed
output ports reaction_torque
param MAXITER = 100;
param REL_TOL = 1e-8;
param ABS_TOL = 1e-8;
control rules {
	var prev_height;
	var window_state;
	var obstacle_state;
	for (var iter in 0 .. MAXITER) {
		window_state := get_state(window_sa);
		obstacle_state := get_state(obstacle);
		prev_height := height;
		do_step(obstacle, H); // with delayed input for height
		do_step(window_sa, H);
		if (is_close(prev_height, height, REL_TOL, ABS_TOL)) {
			break;
		} else {
			set_state(window_sa, window_state);
			set_state(obstacle, obstacle_state);
		}
	}
	return H;
}