Experts have warned about the havoc robots could cause humanity. How do we ensure machines are friends rather than foes?