+ +```sh +Files: localized_sensors_0.db3 +Bag size: 9.6 MiB +Storage id: sqlite3 +Duration: 76.539s +Start: Jul 8 2022 11:21:41.220 (1657246901.220) +End: Jul 8 2022 11:22:57.759 (1657246977.759) +Messages: 32855 +Topic information: Topic: /localization/pose_estimator/pose_with_covariance | Type: geometry_msgs/msg/PoseWithCovarianceStamped | Count: 2162 | Serialization Format: cdr + Topic: /clock | Type: rosgraph_msgs/msg/Clock | Count: 57309 | Serialization Format: cdr + Topic: /tf_static | Type: tf2_msgs/msg/TFMessage | Count: 2 | Serialization Format: cdr + Topic: /sensing/imu/tamagawa/imu_raw | Type: sensor_msgs/msg/Imu | Count: 8076 | Serialization Format: cdr + Topic: /vehicle/status/velocity_status | Type: autoware_vehicle_msgs/msg/VelocityReport | Count: 8275 | Serialization Format: cdr + +``` + +
++ +```sh +# Validation results +# value: [min, max] +[OK] coef_vx: [0.99538, 0.99593] +[OK] stddev_vx: [0.17192, 0.19161] +[OK] angular_velocity_offset_x: [-0.00742, -0.00727] +[OK] angular_velocity_offset_y: [-0.00119, -0.00115] +[OK] angular_velocity_offset_z: [0.00635, 0.00641] +[OK] angular_velocity_stddev_xx: [0.04151, 0.04258] +[OK] angular_velocity_stddev_yy: [0.04151, 0.04258] +[OK] angular_velocity_stddev_zz: [0.04151, 0.04258] +``` + +
++
+
+
+ +
+ +#### B. Check the compatibility with a threshold in `localization_error_monitor` + +The `deviation_evaluator` also checks the compatibility of the estimated parameters and the threshold in `localization_error_monitor`. + +Concretely, it checks if the two following statement holds: + +1. `localization_error_monitor` would NOT diagnose the system as `WARN` nor `ERROR` as long as the NDT is available. +2. `localization_error_monitor` detects the anomaly with a recall over 0.99. + +Given the result of this validation, the users can verify that the estimated parameters in `deviation_estimator` can be safely applied to Autoware. + +Here, note that the `localization_error_monitor` treat the system as an anomaly if either of error along long-axis of confidence ellipse or error along lateral direction is over threshold. Please refer to the package in autoware.universe for detail. + +### Architecture of `deviation_evaluator` + +The architecture of `deviation_evaluator` is shown below. It launches two `ekf_localizer`, one for ground truth estimation and one for (partially) dead reckoning estimation. Outputs of both `ekf_localizer` will be recorded and analyzed with `deviation_evaluation_visualizer`. + ++ +
+ +### Inputs / Outputs + +#### Input + +| Name | Type | Description | +| ----------------------------- | ----------------------------------------------- | -------------------------- | +| `in_ndt_pose_with_covariance` | `geometry_msgs::msg::PoseWithCovarianceStamped` | Input pose | +| `in_ekf_dr_odom` | `nav_msgs::msg::Odometry` | dead-reckoning EKF outputs | +| `in_ekf_gt_odom` | `nav_msgs::msg::Odometry` | ground-truth EKF outputs | + +#### Output + +| Name | Type | Description | +| ---------------------------------- | ----------------------------------------------- | ------------------------------------------------ | +| `out_pose_with_covariance_dr` | `geometry_msgs::msg::PoseWithCovarianceStamped` | Output pose (for dead reckoning `ekf_localizer`) | +| `out_pose_with_covariance_gt` | `geometry_msgs::msg::PoseWithCovarianceStamped` | Output pose (for ground truth `ekf_localizer`) | +| `out_initial_pose_with_covariance` | `geometry_msgs::msg::PoseWithCovarianceStamped` | Output initial pose (for both `ekf_localizer`) | + +### Parameters for deviation evaluator + +| Name | Type | Description | Default value | +| -------- | ---------- | -------------------------------------------------------------------------- | ----------------------------------------- | +| rviz | bool | Show rviz if true | false | +| map_path | string | Path to the directory where map data (OpenStreetMap or .osm data) is saved | "" | +| save_dir | string | Output directory where figures, parameter files, and scores are saved | "$(env HOME)/deviation_evaluator_sample" | +| period | double [s] | Duration of cycle | 10 (in `config/deviation_evaluator.yaml`) | +| cut | double [s] | Duration of ndt-cut-off | 9 (in `config/deviation_evaluator.yaml`) | + +## 4. Reflect the estimated parameters in Autoware + +The results of `deviation_estimator` is stored in two scripts: + +- `imu_corrector` param file (default: `$HOME/imu_corrector.param.yaml`) +- `vehicle_velocity_converter` param file (default: `$HOME/vehicle_velocity_converter.param.yaml`) + +Please modify your Autoware configuration so that it will launch using the above two parameter files. + +## 5. Known issues + +- The plot of `deviation_evaluator.png` generated by `deviation_evaluation_visualizer` may diverge, possibly due to the large covariance caused by a failure in localization. +- `ekf_localizer` in `deviation_evaluator` may not start properly. As for now, please launch `deviation_evaluator` first and then run `ros2 bag play` to provide pose and twist data. diff --git a/localization/deviation_estimation_tools/deviation_estimator/CMakeLists.txt b/localization/deviation_estimation_tools/deviation_estimator/CMakeLists.txt new file mode 100644 index 00000000..b36d43ad --- /dev/null +++ b/localization/deviation_estimation_tools/deviation_estimator/CMakeLists.txt @@ -0,0 +1,55 @@ +cmake_minimum_required(VERSION 3.5) +project(deviation_estimator) + +find_package(autoware_cmake REQUIRED) +autoware_package() + +ament_auto_add_library(deviation_estimator_lib SHARED + src/deviation_estimator.cpp + src/utils.cpp + src/gyro_bias_module.cpp + src/velocity_coef_module.cpp + src/logger.cpp + src/validation_module.cpp +) + +# as a ros2 node +ament_auto_add_executable(deviation_estimator src/deviation_estimator_node.cpp) +target_compile_options(deviation_estimator PUBLIC -g -Wall -Wextra -Wpedantic -Werror) +target_link_libraries(deviation_estimator deviation_estimator_lib) +target_include_directories(deviation_estimator PUBLIC include) + +# as a static tool +ament_auto_add_executable(deviation_estimator_unit_tool src/deviation_estimator_main.cpp) +target_compile_options(deviation_estimator_unit_tool PUBLIC -g -Wall -Wextra -Wpedantic -Werror) +target_link_libraries(deviation_estimator_unit_tool deviation_estimator_lib) +target_include_directories(deviation_estimator_unit_tool PUBLIC include) + +if(BUILD_TESTING) + function(add_testcase filepath) + get_filename_component(filename ${filepath} NAME) + string(REGEX REPLACE ".cpp" "" test_name ${filename}) + + ament_add_gtest(${test_name} ${filepath}) + target_link_libraries("${test_name}" deviation_estimator_lib) + ament_target_dependencies(${test_name} ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS}) + endfunction() + + find_package(ament_cmake_gtest REQUIRED) + + set(TEST_FILES + test/test_gyro_stddev.cpp + test/test_gyro_bias.cpp + test/test_utils.cpp) + + foreach(filepath ${TEST_FILES}) + add_testcase(${filepath}) + endforeach() +endif() + + +ament_auto_package( + INSTALL_TO_SHARE + launch + config +) diff --git a/localization/deviation_estimation_tools/deviation_estimator/config/deviation_estimator.param.yaml b/localization/deviation_estimation_tools/deviation_estimator/config/deviation_estimator.param.yaml new file mode 100644 index 00000000..1b170510 --- /dev/null +++ b/localization/deviation_estimation_tools/deviation_estimator/config/deviation_estimator.param.yaml @@ -0,0 +1,27 @@ +/**: + ros__parameters: + time_window: 4.0 + vx_threshold: 1.5 + wz_threshold: 0.01 + accel_threshold: 0.3 + output_frame: base_link + gyro_estimation: + only_use_straight: true + only_use_moving: false + only_use_constant_velocity: false + add_bias_uncertainty: false + velocity_estimation: + only_use_straight: true + only_use_moving: true + only_use_constant_velocity: true + add_bias_uncertainty: false + + # Used when adding bias-based uncertainty + dt_design: 10.0 # [s] + dx_design: 30.0 # [m] + + # Used for validating the results of deviation_estimator + thres_coef_vx: 0.01 # [.] + thres_stddev_vx: 0.05 # [.] + thres_bias_gyro: 0.001 # [rad/s] + thres_stddev_gyro: 0.01 # [rad/s] diff --git a/localization/deviation_estimation_tools/deviation_estimator/include/deviation_estimator/deviation_estimator.hpp b/localization/deviation_estimation_tools/deviation_estimator/include/deviation_estimator/deviation_estimator.hpp new file mode 100644 index 00000000..bf773638 --- /dev/null +++ b/localization/deviation_estimation_tools/deviation_estimator/include/deviation_estimator/deviation_estimator.hpp @@ -0,0 +1,124 @@ +// Copyright 2018-2019 Autoware Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DEVIATION_ESTIMATOR__DEVIATION_ESTIMATOR_HPP_ +#define DEVIATION_ESTIMATOR__DEVIATION_ESTIMATOR_HPP_ + +#include "deviation_estimator/gyro_bias_module.hpp" +#include "deviation_estimator/logger.hpp" +#include "deviation_estimator/utils.hpp" +#include "deviation_estimator/validation_module.hpp" +#include "deviation_estimator/velocity_coef_module.hpp" +#include "rclcpp/rclcpp.hpp" +#include "tf2/utils.h" +#include "tier4_autoware_utils/ros/transform_listener.hpp" + +#include "autoware_vehicle_msgs/msg/velocity_report.hpp" +#include "geometry_msgs/msg/pose_with_covariance_stamped.hpp" +#include "geometry_msgs/msg/transform_stamped.hpp" +#include "geometry_msgs/msg/twist_with_covariance_stamped.hpp" +#include "sensor_msgs/msg/imu.hpp" +#include "std_msgs/msg/float64.hpp" +#include "tier4_debug_msgs/msg/float64_stamped.hpp" + +#include