Text this: Adaptive Resource Allocation and Mode Switching for D2D Networks With Imperfect CSI in AGV-Based Factory Automation