added saving robot state and a unit test for it