Visible to the public CPS:Synergy:Learning to Walk - Optimal Gait Synthesis and Online Learning for Terrain-Aware Legged Locomotion