Autonomous Gait Planning for a Hexapod Robot in Unstructured Environments based on 3 D Terrain Perception