1. A mobile apparatus comprising a control device and having an operation controlled by the control device to autonomously move along a target trajectory representing changes in a target position defined in a two-dimensional model space, the control device including a first processing unit, a second processing unit, and a third processing unit, wherein the first processing unit recognizes a position of a boundary of a region through which the mobile apparatus is capable of passing as a position of a boundary of an element passing region in the model space, recognizes the mobile apparatus and a position of the mobile apparatus as a first spatial element and a first position, respectively, recognizes an object and a position of the object as a second spatial element and a second position, respectively, and recognizes the second spatial element continuously or intermittently expanded in accordance with the change in the second position as an expanded second spatial element, the second processing unit determines whether a first safety condition is satisfied based on the first spatial element, the first position, the second spatial element and the second position of the recognition result by the first processing unit, the first safety condition specifying that a possibility of contact between the first spatial element and the second spatial element in the element passing region is low, on a condition that the second processing unit determines that the first safety condition is not satisfied, the third processing unit searches for a first target trajectory based on the position of a boundary of the element passing region, the first spatial element, the first position, the expanded second spatial element and the second position of the recognition result by the first processing unit, the first target trajectory allowing the first spatial element to avoid contact with the expanded second spatial element in the element passing region, the second processing unit determines whether a second safety condition is satisfied, the second safety condition specifying that the first target trajectory has been searched for and determined by the third processing unit, on a condition that the second processing unit determines that the second safety condition is not satisfied, the third processing unit searches for a second target trajectory based on the position of a boundary of the element passing region, the first spatial element and the first position of the recognition result by the first processing unit, the second target trajectory evaluating a distance between the first spatial element and the boundary of the element passing region as a third distance and causing the first spatial element to approach a boundary of the element passing region preferentially in a direction in which the third distance is small, and the control device controls the operation of the mobile apparatus by regarding the first target trajectory as the target trajectory in a case where the second processing unit determines that the second safety condition is satisfied, whereas the control device controls the operation of the mobile apparatus by regarding the second target trajectory provisionally as the target trajectory and to cause the mobile apparatus to stop moving at a stop position, which is a position corresponding to an end point of the second target trajectory, in a case where the second target trajectory has been searched for and determined by the third processing unit.