Adaptive locomotion over difficult or irregular terrain is considered as a superiority feature of walking robots over wheeled or tracked machines. However, safe foot positioning, body posture and stability, correct leg trajectory, and efficient path planning are a necessity for legged robots to overcome a variety of possible terrains and obstacles. Without these properties, any walking machine becomes useless. Energy consumption is one of the major problems for robots with a large number of Degrees of Freedom (DoF). When considering a path plan or movement parameters such as speed, step length or step height, it is important to choose the most suitable variables to sustain long battery life and to reach the objective or complete the task successfully. We change the settings of a hexapod robot leg trajectory for overcoming small terrain irregularities by optimizing consumed energy and leg trajectory during each leg transfer. The trajectory settings are implemented as a part of hexapod robot simulation model and tested through series of experiments with various terrains of differing complexity and obstacles of various sizes. Our results show that the proposed energy-efficient trajectory transformation is an effective method for minimizing energy consumption and improving overall performance of a walking robot.