The deal, expected to close in the third quarter, comes at a time of increasing consolidation in the capital-intensive self-driving industry.