Underwater robots that can predict waves in real-time could reduce the cost of producing offshore renewable energy, a study suggests.