Box2d levitation

Hi guys,
What is the best way to make a body levitate on the ground? I want to make a spaceship that stays at a certain distance from the ground! I was thinking of checking the distance between the space ship and the ground, and apply a force accordingly! If it passes the given height i would apply a force up or down, given the need!What do you think?Is there a better way?
Thanks a lot!

Original thread: https://box2d.org/forum/viewtopic.php?t=7600