I have a question about terrain

Hi, I’m using an optical flow + lidar (MTF-01) for px4 drones right now.
As I drive in offboard mode, the drone shakes up and down due to holes or hills. Is there any way to solve this? Please let me know if you have any good information. Thank you.