Yeap you can do this . . . but if you do the math (calculate mAh), you'd find the energy you get from the solar panel will probably only extend your robot run for a minute tops.
If you are using wall power, don't do this with NiCad batteries since if you recharge improperly, it will reduce the battery lifetime. NiMH should be fine.