I would imagine you could reuse code from a flying drone on Earth.
We have plenty of faux-mars environments to practice these techniques on. NASA even has their own.
many of the toy indoor-use drones use such techniques for attitude/altitude-hold features when under a roof.