Erratic Mega Output when connected to USB cable

Thanks. I suspected something like this and I'll try out your suggestions. Normally I do put capacitors across the motor terminals. A little difficult with these 350 W motors running a 100 lb robot. The power leads are heavy duty, insulated wires that carry 45 amps in skid turns and I don't want to bare any insulation. I'll first try putting the capacitors on the motor driver output. BTW, the problem also occurs when the robot is sitting on a stand with the 24v, PbSO4 battery charger connected.
I also understand about ground loops; I'll see if there's any improvement I can make.

John-