Towards Robust And Flexible Robot State And Motion Estimation Through Optimization And Learning