SITL copter mission mixing "Relative" and "Terrain" waypoints: should it work (4.1dev)?

All below in SITL 4.1dev.

Consider this mission:
QGC WPL 110
0 1 0 16 0 0 0 0 33.74113111 -118.374600 178 1
1 0 10 22 0 0 0 0 33.74116111 -118.374600 1.00 1
2 0 10 201 0 0 0 0 33.74111111 -118.375 1.00 1
3 0 0 93 0.001 0 0 0 0 0 0 1
4 0 10 16 0 0 0 0 33.74111111 -118.37472222 4.00 1
5 0 10 16 0 0 0 0 33.74117111 -118.37472222 1.00 1
6 0 10 16 0 0 0 0 33.74124111 -118.37472222 4.00 1
7 0 10 16 0 0 0 0 33.74117111 -118.37472222 1.00 1
8 0 10 16 0 0 0 0 33.74111111 -118.37472222 4.00 1
9 0 10 16 0 0 0 0 33.74105111 -118.37472222 1.00 1
10 0 10 16 0 0 0 0 33.74099111 -118.37472222 4.00 1
11 0 10 16 0 0 0 0 33.74105111 -118.37472222 1.00 1
12 0 10 177 3 3 0 0 0 0 0 1
13 0 0 93 0.001 0 0 0 0 0 0 1
14 0 3 16 0 0 0 0 33.74111111 -118.37472222 20.00 1
15 0 10 16 0 0 0 0 33.74117111 -118.37472222 1.00 1
16 0 3 16 0 0 0 0 33.74124111 -118.37472222 20.00 1
17 0 10 16 0 0 0 0 33.74117111 -118.37472222 1.00 1
18 0 3 16 0 0 0 0 33.74111111 -118.37472222 20.00 1
19 0 10 16 0 0 0 0 33.74105111 -118.37472222 1.00 1
20 0 3 16 0 0 0 0 33.74099111 -118.37472222 20.00 1
21 0 10 16 0 0 0 0 33.74105111 -118.37472222 1.00 1
22 0 3 177 13 3 0 0 0 0 0 1
23 0 10 21 0 0 0 0 33.74119111 -118.374600 0.00 1
consisting in four Big W’s (as this, simulation done at Big W documented original location) repeated two times:
-first four Big W’s five vertexes height 1m (two low ones) and 4m (three high ones);
-second four Big W’s five vertexes height 1m (two low ones) and 20m (three high ones).

./sim_vehicle.py -v ArduCopter -f quad -l 33.74111111,-118.374600,178,270 --use-dir=BigW

Simulation done with simulated rangefinder up to 15m:
RNGFND1_MAX_CM 1500
distance chosen since in SITL when taking off it stays at 10m (I don’t know how to change this).

Waypoints heights in first four Big W’s height (from 1m to 4m) are within rangefinder range (RNGFND1_MAX_CM 1500), and the waypoints have 10 (“Terrain”) as third parameter, as explained here. Since on the second four Big W’s (from 1m to 20m) high Big W vertexes height (20m) is higher than 15 m (RNGFND1_MAX_CM 1500) the third parameter of the corresponding waypoints is 3 (“Relative”) as explained here.

When simulated, the first Big W’s (1m to 4m) are followed, but on the second four Big W’s (1m to 20m) when going towards waypoint 15 (4m high (10 “Terrain”)) after waypoint 14 (20m high (3 “Relative”)), the copter climbs to 20m with correct inclination (waypoint 14) and then somehow it does not ‘know’ how to go to waypoint 15 (10 (“Terrain”) as third parameter), “Failsafe: terrain data missing” is heard, and RTL follows, as seen with the 3D capture (from here) video:




Note that waypoint 15 (as also 17, 19 and 21) has to have 10 (“Terrain”) as third parameter, since being close to ground if relying on barometer it could touch ground (real thing).

This is the simulation .tlog log and this is the simulation parameters file.

Is this expected behavior? If so, what else is needed to mix “Terrain” (third parameter 10) and “Relative” (third parameter 3) waypoints in a Copter mission?

This was discussed here without solution, but it was seen that SITL shows the same problems as the real thing.

Incidentally, note that waypoint 2 (201: DO_SET_ROI) is not obeyed, possibly because of low height after takeoff.

BTW, congratulations to all developers: here it is seen how faithfully the real thing is emulated in SITL.