Cyber-physical systems are ever more common in manufacturing industries. Increasing their autonomy has been declared an explicit goal, for example, as part of the Industry 4.0 vision. To achieve this system intelligence, principled and software-driven methods are required to analyze sensing data, make goal-directed decisions, and eventually execute and monitor chosen tasks. In this chapter, we present a number of knowledge-based approaches to these problems and case studies with in-depth evaluation results of several different implementations for groups of autonomous mobile robots performing in-house logistics in a smart factory. We focus on knowledge-based systems because besides providing expressive languages and capable reasoning techniques, they also allow for explaining how a particular sequence of actions came about, for example, in the case of a failure.