As FedEx Corp. and United Parcel Service Inc. beef up automation to keep pace with surging e-commerce and a potential threat from Amazon.com Inc., they’ve been stumped at a crucial stage: loading and unloading trucks. Robot makers are getting close to solving part of that puzzle.