# Localization

This page describes the interface of the Localization component. See the [Localization component design](<../../../components/localization/index.md>) for the concepts.

The Localization component estimates the pose, the velocity, and the acceleration of the vehicle. The diagram shows the default setup of [`autoware_launch`](<https://github.com/autowarefoundation/autoware_launch/tree/main/autoware_universe_launch/autoware_localization_launch>): the `ndt` pose source and the `gyro_odom` twist source. Other pose sources are YabLoc, Eagleye, AR tags, and LiDAR markers.

The main nodes and data flows of the Localization component in the default setup.

The pose initializer also calls the NDT scan matcher to align the first pose with the point cloud map.

## Inputs

| Name | Topic or service | Type | Description |
| --- | --- | --- | --- |
| Point cloud map | `/map/get_differential_pointcloud_map` (service) | [autoware\_map\_msgs/srv/GetDifferentialPointCloudMap](<https://github.com/autowarefoundation/autoware_msgs/blob/main/autoware_map_msgs/srv/GetDifferentialPointCloudMap.srv>) | The NDT scan matcher loads the map areas around the vehicle. See the outputs of [Map](<../map/index.md>). |
| Point cloud map | `/map/get_partial_pointcloud_map` (service) | [autoware\_map\_msgs/srv/GetPartialPointCloudMap](<https://github.com/autowarefoundation/autoware_msgs/blob/main/autoware_map_msgs/srv/GetPartialPointCloudMap.srv>) | The pose initializer uses the map to fit the height of a GNSS pose. If the map loader does not enable partial loading, it uses the `/map/pointcloud_map` topic instead. |
| LiDAR point cloud | `/sensing/lidar/concatenated/pointcloud` | [sensor\_msgs/msg/PointCloud2](<https://github.com/ros2/common_interfaces/blob/rolling/sensor_msgs/msg/PointCloud2.msg>) | The point cloud for NDT matching. It must first go through the [point cloud preprocessing](<../../../components/sensing/data-types/point-cloud/index.md>). Localization then crops and downsamples it again. |
| GNSS pose | `/sensing/gnss/pose_with_covariance` | [geometry\_msgs/msg/PoseWithCovarianceStamped](<https://github.com/ros2/common_interfaces/blob/rolling/geometry_msgs/msg/PoseWithCovarianceStamped.msg>) | The pose from GNSS. The pose initializer uses it for automatic initialization, and the NDT scan matcher can use it for regularization. |
| IMU data | `/sensing/imu/imu_data` | [sensor\_msgs/msg/Imu](<https://github.com/ros2/common_interfaces/blob/rolling/sensor_msgs/msg/Imu.msg>) | The angular velocity of the vehicle, after the IMU corrector. |
| Vehicle twist | `/sensing/vehicle_velocity_converter/twist_with_covariance` | [geometry\_msgs/msg/TwistWithCovarianceStamped](<https://github.com/ros2/common_interfaces/blob/rolling/geometry_msgs/msg/TwistWithCovarianceStamped.msg>) | The velocity of the vehicle. `autoware_vehicle_velocity_converter` makes it from `/vehicle/status/velocity_status` (`autoware_vehicle_msgs/msg/VelocityReport`). |
| Initialize | `/localization/initialize` (service) | [autoware\_localization\_msgs/srv/InitializeLocalization](<https://github.com/autowarefoundation/autoware_msgs/blob/main/autoware_localization_msgs/srv/InitializeLocalization.srv>) | A request to initialize the pose. The `AUTO` method aligns the given pose with the NDT scan matcher. If no pose is given, it uses the GNSS pose. The `DIRECT` method uses the given pose as it is. The AD API calls this service. |

The GNSS pose comes from the Sensing component. Its `gnss_poser` node makes it from the GNSS position (`sensor_msgs/msg/NavSatFix`) and the GNSS-INS orientation ([autoware\_sensing\_msgs/msg/GnssInsOrientationStamped](<https://github.com/autowarefoundation/autoware_msgs/blob/main/autoware_sensing_msgs/msg/GnssInsOrientationStamped.msg>)). See [Sensing](<../sensing/index.md>).

In RViz, the **2D Pose Estimate** tool publishes `/initialpose`. The initial pose adaptor of [`autoware_adapi_adaptors`](<https://github.com/autowarefoundation/autoware_core/tree/main/api/autoware_adapi_adaptors>) turns it into a call of the AD API `/api/localization/initialize`. The AD API then calls `/localization/initialize`.

## Outputs

| Name | Topic | Type | Description |
| --- | --- | --- | --- |
| Vehicle kinematic state | `/localization/kinematic_state` | [nav\_msgs/msg/Odometry](<https://github.com/ros2/common_interfaces/blob/rolling/nav_msgs/msg/Odometry.msg>) | The current pose and twist of the vehicle. Planning, Control, Perception, and others use it. |
| Vehicle acceleration | `/localization/acceleration` | [geometry\_msgs/msg/AccelWithCovarianceStamped](<https://github.com/ros2/common_interfaces/blob/rolling/geometry_msgs/msg/AccelWithCovarianceStamped.msg>) | The current acceleration of the vehicle, from the `autoware_twist2accel` node. |
| Vehicle pose | `/localization/pose_with_covariance` | [geometry\_msgs/msg/PoseWithCovarianceStamped](<https://github.com/ros2/common_interfaces/blob/rolling/geometry_msgs/msg/PoseWithCovarianceStamped.msg>) | The current pose of the vehicle, from the EKF localizer. |
| Vehicle twist | `/localization/pose_twist_fusion_filter/twist_with_covariance` | [geometry\_msgs/msg/TwistWithCovarianceStamped](<https://github.com/ros2/common_interfaces/blob/rolling/geometry_msgs/msg/TwistWithCovarianceStamped.msg>) | The current twist of the vehicle, from the EKF localizer. |
| Transform | `/tf` | [tf2\_msgs/msg/TFMessage](<https://github.com/ros2/geometry2/blob/rolling/tf2_msgs/msg/TFMessage.msg>) | The transform from `map` to `base_link`. |
| Initialization state | `/localization/initialization_state` | [autoware\_adapi\_v1\_msgs/msg/LocalizationInitializationState](<https://github.com/autowarefoundation/autoware_adapi_msgs/blob/main/autoware_adapi_v1_msgs/localization/msg/LocalizationInitializationState.msg>) | The state of the pose initialization. |
| Localization accuracy | `/diagnostics` | [diagnostic\_msgs/msg/DiagnosticArray](<https://github.com/ros2/common_interfaces/blob/rolling/diagnostic_msgs/msg/DiagnosticArray.msg>) | The `autoware_localization_error_monitor` node reports when the error ellipse of the pose is too large. |

Use `/localization/kinematic_state` for the pose and the velocity of the vehicle. The [autoware\_localization\_msgs/msg/KinematicState](<https://github.com/autowarefoundation/autoware_msgs/blob/main/autoware_localization_msgs/msg/KinematicState.msg>) message holds a pose, a twist, and an acceleration in one message, but no node in the default setup publishes it.
