Getting lower output voltage than expected in 5 level inverter
To keep the high-side FETs turned on their Gates need to go above the battery voltage by &gt;=10 V. However you must also ensure that they don't receive more than 20 V between Gate and Source, so you can't just boost the battery voltage by 10 V because then the total would be 22 V which could blow up the FETs.
One way to do it is with an isolated DC/DC converter such as the Recom ROL-1212S, powered by the battery being switched and with its output connected between the optocoupler positive supply and FET Source. You will need one converter per high-side FET.
For testing you could use PP9 dry cell batteries, which should last a long time at the low current your Gate driver draws.
Apart from that your circuit and program appear to be correct. The rms output voltage should be ~20 V.