Computer-implemented method for operating a mobile agent in an environment on the basis of a pose of the mobile agent , wherein a localization of the mobile agent for the operation of the mobile agent is carried out with the following steps: - capturing (S1) sensor data regarding walls and/or objects located in an environment, wherein the sensor data indicate the alignment and distance of the walls and/or objects in an agent-fixed agent coordinate system (A); - determining (S11-S18) the pose of the mobile agent in the environment with the aid of a SLAM algorithm taking into account a Manhattan orientation, wherein the SLAM algorithm provides a minimization of an error function which is dependent on measurement errors of the sensor data and dependent on the Manhattan orientation, wherein the SLAM algorithm corresponds to a graph-based SLAM algorithm on the basis of a SLAM graph having nodes (P) and transformation edges (TK, M), wherein the SLAM graph contains pose nodes (P) that each indicate a pose of the mobile agent determined from the sensor data, and transformation edges (TK) between each two pose nodes (P), wherein the transformation edges (TK) indicate a pose change, determined from the sensor data, between the poses assigned to the respectively two pose nodes (P), characterized in that depending on the Manhattan orientation a Manhattan node (MK) and at least one Manhattan edge (M) between the Manhattan node (MK) and one of the pose nodes (P) are added, wherein the SLAM algorithm uses an error function which is ascertained from the SLAM graph and which takes account of the error probabilities assigned to the nodes (P, MK) and edges (TK, M) in order to determine the corrected poses assigned to the nodes (P, MK) of the SLAM graph. - capturing (S1) sensor data regarding walls and/or objects located in an environment, wherein the sensor data indicate the alignment and distance of the walls and/or objects in an agent-fixed agent coordinate system (A); - determining (S11-S18) the pose of the mobile agent in the environment with the aid of a SLAM algorithm taking into account a Manhattan orientation, wherein the SLAM algorithm provides a minimization of an error function which is dependent on measurement errors of the sensor data and dependent on the Manhattan orientation, wherein the SLAM algorithm corresponds to a graph-based SLAM algorithm on the basis of a SLAM graph having nodes (P) and transformation edges (TK, M), wherein the SLAM graph contains pose nodes (P) that each indicate a pose of the mobile agent determined from the sensor data, and transformation edges (TK) between each two pose nodes (P), wherein the transformation edges (TK) indicate a pose change, determined from the sensor data, between the poses assigned to the respectively two pose nodes (P), characterized in that depending on the Manhattan orientation a Manhattan node (MK) and at least one Manhattan edge (M) between the Manhattan node (MK) and one of the pose nodes (P) are added, wherein the SLAM algorithm uses an error function which is ascertained from the SLAM graph and which takes account of the error probabilities assigned to the nodes (P, MK) and edges (TK, M) in order to determine the corrected poses assigned to the nodes (P, MK) of the SLAM graph. <EOS>