# How do robots know where they are?

In this post, we’ll cover how a robot knows where it is which allows it to move around its environment and specifically to a goal destination. Additionally we provide numerous image representations of how a robot represents the world and navigates with in it. So, how do robots know where they are?

When a robot moves around in the world, it normally moves in an environment it has seen before. From our previous post, robots can see the world around them using sensors such as cameras or LiDARs. A robot can save information about where it can and cannot go in a map. In robotics, mapping is how a robot estimates positions of features in the environment and saves them so it can easily move around in that environment in the future. Below is an example of a robot map, with the environment on the left, and the map on the right, with the robot highlighted in blue:

An example map for a robot is known as an occupancy grid, a common format for robots navigating in a 2-D space, with grid cells indicating if a robot can move there (free space) or is blocked by an obstacle (such as a wall):

The process of how a robot figures out where it is on the map is known as localization: knowledge of position of a robot given features of a known position. The term for where exactly the robot is on the map and in space is the pose: representation of position and orientation. A 2D Pose is (x, y, theta), where theta is the angle the robot is facing. Consider car on grid graph, if it starts one way and we want it to end another way, we need to describe where it is (x,y) and which direction it is facing (theta) within a coordinate frame (term that describes the relative position of the robot):

While a robot can know where it is (its pose) in a given a map of the environment, its also important for a robot to be able to navigate in new, unfamiliar environments. When a robot doesn’t have a map already, it needs to create a map. A map can be created by sensing the environment and saving key landmark features that it sees, such as walls or doors. The process by which the robot can learn its environment and know where it is while building its map is known as SLAM: Simultaneous localization & mapping. We can visualize SLAM below, notice as the robot moves around the space, it uses its sensors to both avoid walls and detect/save where they are: