Skip to content

Commit 3895c0f

Browse files
tkimura4sgk-000kmiyakenji-miyakeKeisukeShima
authored
feat: add autoware_debug_tools packages (autowarefoundation#99)
* Ros2 v0.8.0 autoware debug tools (autowarefoundation#330) * initial commit * fix bug * fix lint * delete setup.py * fix too long line * add copyright * change directory structure * fix tf2pose * fix pose2tf.py * add test self pose listener * format * delete queue size * use timer * fix stop_reason2pose * fix stop_reason2tf * fix topic name on tf2pose * format * Fix typo in common module (autowarefoundation#433) * Unify Apache-2.0 license name (autowarefoundation#1242) * Fix lint errors (autowarefoundation#1378) * Fix lint errors Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix variable names Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * add sort-package-xml hook in pre-commit (autowarefoundation#1881) * add sort xml hook in pre-commit * change retval to exit_status * rename * add prettier plugin-xml * use early return * add license note * add tier4 license * restore prettier * change license order * move local hooks to public repo * move prettier-xml to pre-commit-hooks-ros * update version for bug-fix * apply pre-commit * Add shellcheck (autowarefoundation#2079) * Add shellcheck Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix shellcheck Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Feature/add lateral error publisher (autowarefoundation#2167) * Add CMakeLists, package.xml and base cpp/hpp for lateral_error_publisher Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Implementing ... Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Register lateral_error_publisher node Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Add control/localization lateral error calculation Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Add config file Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Add publisher Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Change RCLCPP_INFO to RCLCPP_DEBUG Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Add readme and fix topic name Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Fix a lateral error publisher overview figure Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Fix code style Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Fix to pre-commit test Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Fix type to reference Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Use MPL2 licence only at eigen library Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Fix comment Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Fix condition Signed-off-by: Makoto Kurihara <mkuri8m@gmail.com> * Change formatter to clang-format and black (autowarefoundation#2332) * Revert "Temporarily comment out pre-commit hooks" This reverts commit 748e9cdb145ce12f8b520bcbd97f5ff899fc28a3. * Replace ament_lint_common with autoware_lint_common Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Remove ament_cmake_uncrustify and ament_clang_format Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Apply Black Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Apply clang-format Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix build errors Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix for cpplint * Fix include double quotes to angle brackets Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Apply clang-format Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix build errors Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Add COLCON_IGNORE (autowarefoundation#500) Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * port autoware_debug_tools (autowarefoundation#509) Co-authored-by: Takayuki Murooka <takayuki.murooka@tier4.jp> * fix readme Co-authored-by: Shigeki Kobayashi <32808802+sgk-000@users.noreply.github.com> Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> Co-authored-by: Kenji Miyake <31987104+kenji-miyake@users.noreply.github.com> Co-authored-by: Keisuke Shima <19993104+KeisukeShima@users.noreply.github.com> Co-authored-by: Makoto Kurihara <mkuri8m@gmail.com> Co-authored-by: Takayuki Murooka <takayuki5168@gmail.com> Co-authored-by: Takayuki Murooka <takayuki.murooka@tier4.jp>
1 parent 5d6f417 commit 3895c0f

14 files changed

+872
-0
lines changed
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(autoware_debug_tools)
3+
4+
if(NOT CMAKE_CXX_STANDARD)
5+
set(CMAKE_CXX_STANDARD 14)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
set(CMAKE_CXX_EXTENSIONS OFF)
8+
endif()
9+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
10+
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
11+
endif()
12+
13+
find_package(ament_cmake_auto REQUIRED)
14+
ament_auto_find_build_dependencies()
15+
16+
find_package(Eigen3 REQUIRED)
17+
18+
#ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR "scripts/")
19+
20+
ament_auto_add_library(lateral_error_publisher SHARED
21+
src/lateral_error_publisher.cpp
22+
)
23+
24+
rclcpp_components_register_node(lateral_error_publisher
25+
PLUGIN "LateralErrorPublisher"
26+
EXECUTABLE lateral_error_publisher_node
27+
)
28+
29+
if(BUILD_TESTING)
30+
find_package(ament_lint_auto REQUIRED)
31+
ament_lint_auto_find_test_dependencies()
32+
endif()
33+
34+
ament_auto_package(
35+
INSTALL_TO_SHARE
36+
config
37+
launch
38+
)
39+
40+
install(PROGRAMS scripts/stop_reason2pose.py scripts/pose2tf.py scripts/tf2pose.py
41+
scripts/case_converter.py scripts/self_pose_listener.py
42+
scripts/stop_reason2tf DESTINATION lib/${PROJECT_NAME})
43+
44+
install(FILES DESTINATION share/${PROJECT_NAME})

common/autoware_debug_tools/README.md

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# autoware_debug_tools
2+
3+
This package provides useful features for debugging Autoware.
4+
5+
## Usage
6+
7+
### tf2pose
8+
9+
This tool converts any `tf` to `pose` topic.
10+
With this tool, for example, you can plot `x` values of `tf` in `rqt_multiplot`.
11+
12+
```sh
13+
ros2 run autoware_debug_tools tf2pose {tf_from} {tf_to} {hz}
14+
```
15+
16+
Example:
17+
18+
```sh
19+
$ ros2 run autoware_debug_tools tf2pose base_link ndt_base_link 100
20+
21+
$ ros2 topic echo /tf2pose/pose -n1
22+
header:
23+
seq: 13
24+
stamp:
25+
secs: 1605168366
26+
nsecs: 549174070
27+
frame_id: "base_link"
28+
pose:
29+
position:
30+
x: 0.0387684271191
31+
y: -0.00320360406477
32+
z: 0.000276674520819
33+
orientation:
34+
x: 0.000335221893885
35+
y: 0.000122020672186
36+
z: -0.00539673212896
37+
w: 0.999985368502
38+
---
39+
```
40+
41+
### pose2tf
42+
43+
This tool converts any `pose` topic to `tf`.
44+
45+
```sh
46+
ros2 run autoware_debug_tools pose2tf {pose_topic_name} {tf_name}
47+
```
48+
49+
Example:
50+
51+
```sh
52+
$ ros2 run autoware_debug_tools pose2tf /localization/pose_estimator/pose ndt_pose
53+
54+
$ ros2 run tf tf_echo ndt_pose ndt_base_link 100
55+
At time 1605168365.449
56+
- Translation: [0.000, 0.000, 0.000]
57+
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
58+
in RPY (radian) [0.000, -0.000, 0.000]
59+
in RPY (degree) [0.000, -0.000, 0.000]
60+
```
61+
62+
### stop_reason2pose
63+
64+
This tool extracts `pose` from `stop_reasons`.
65+
Topics without numbers such as `/stop_reason2pose/pose/detection_area` are the nearest stop_reasons, and topics with numbers are individual stop_reasons that are roughly matched with previous ones.
66+
67+
```sh
68+
ros2 run autoware_debug_tools stop_reason2pose {stop_reason_topic_name}
69+
```
70+
71+
Example:
72+
73+
```sh
74+
$ ros2 run autoware_debug_tools stop_reason2pose /planning/scenario_planning/status/stop_reasons
75+
76+
$ ros2 topic list | ag stop_reason2pose
77+
/stop_reason2pose/pose/detection_area
78+
/stop_reason2pose/pose/detection_area_1
79+
/stop_reason2pose/pose/obstacle_stop
80+
/stop_reason2pose/pose/obstacle_stop_1
81+
82+
$ ros2 topic echo /stop_reason2pose/pose/detection_area -n1
83+
header:
84+
seq: 1
85+
stamp:
86+
secs: 1605168355
87+
nsecs: 821713
88+
frame_id: "map"
89+
pose:
90+
position:
91+
x: 60608.8433457
92+
y: 43886.2410876
93+
z: 44.9078212441
94+
orientation:
95+
x: 0.0
96+
y: 0.0
97+
z: -0.190261378408
98+
w: 0.981733470901
99+
---
100+
```
101+
102+
### stop_reason2tf
103+
104+
This is an all-in-one script that uses `tf2pose`, `pose2tf`, and `stop_reason2pose`.
105+
With this tool, you can view the relative position from base_link to the nearest stop_reason.
106+
107+
```sh
108+
ros2 run autoware_debug_tools stop_reason2tf {stop_reason_name}
109+
```
110+
111+
Example:
112+
113+
```sh
114+
$ ros2 run autoware_debug_tools stop_reason2tf obstacle_stop
115+
At time 1605168359.501
116+
- Translation: [0.291, -0.095, 0.266]
117+
- Rotation: in Quaternion [0.007, 0.011, -0.005, 1.000]
118+
in RPY (radian) [0.014, 0.023, -0.010]
119+
in RPY (degree) [0.825, 1.305, -0.573]
120+
```
121+
122+
### lateral_error_publisher
123+
124+
This node calculate the control error and localization error in the trajectory normal direction as shown in the figure below.
125+
126+
![lateral_error_publisher_overview](./media/lateral_error_publisher.svg)
127+
128+
Set the reference trajectory, vehicle pose and ground truth pose in the launch file.
129+
130+
```sh
131+
ros2 launch autoware_debug_tools lateral_error_publisher.launch.xml
132+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**:
2+
ros__parameters:
3+
yaw_threshold_to_search_closest: 0.785398 # yaw threshold to search closest index [rad]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2021 Tier IV, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef AUTOWARE_DEBUG_TOOLS__LATERAL_ERROR_PUBLISHER_HPP_
16+
#define AUTOWARE_DEBUG_TOOLS__LATERAL_ERROR_PUBLISHER_HPP_
17+
18+
#define EIGEN_MPL2_ONLY
19+
20+
#include <autoware_utils/trajectory/trajectory.hpp>
21+
#include <eigen3/Eigen/Core>
22+
#include <eigen3/Eigen/Geometry>
23+
#include <rclcpp/rclcpp.hpp>
24+
25+
#include <autoware_auto_planning_msgs/msg/trajectory.hpp>
26+
#include <autoware_debug_msgs/msg/float32_stamped.hpp>
27+
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
28+
29+
class LateralErrorPublisher : public rclcpp::Node
30+
{
31+
public:
32+
explicit LateralErrorPublisher(const rclcpp::NodeOptions & node_options);
33+
34+
private:
35+
/* Parameters */
36+
double yaw_threshold_to_search_closest_;
37+
38+
/* States */
39+
autoware_auto_planning_msgs::msg::Trajectory::SharedPtr
40+
current_trajectory_ptr_; //!< @brief reference trajectory
41+
geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr
42+
current_vehicle_pose_ptr_; //!< @brief current EKF pose
43+
geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr
44+
current_ground_truth_pose_ptr_; //!< @brief current GNSS pose
45+
46+
/* Publishers and Subscribers */
47+
rclcpp::Subscription<autoware_auto_planning_msgs::msg::Trajectory>::SharedPtr
48+
sub_trajectory_; //!< @brief subscription for reference trajectory
49+
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr
50+
sub_vehicle_pose_; //!< @brief subscription for vehicle pose
51+
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr
52+
sub_ground_truth_pose_; //!< @brief subscription for gnss pose
53+
rclcpp::Publisher<autoware_debug_msgs::msg::Float32Stamped>::SharedPtr
54+
pub_control_lateral_error_; //!< @brief publisher for control lateral error
55+
rclcpp::Publisher<autoware_debug_msgs::msg::Float32Stamped>::SharedPtr
56+
pub_localization_lateral_error_; //!< @brief publisher for localization lateral error
57+
rclcpp::Publisher<autoware_debug_msgs::msg::Float32Stamped>::SharedPtr
58+
pub_lateral_error_; //!< @brief publisher for lateral error (control + localization)
59+
60+
/**
61+
* @brief set current_trajectory_ with received message
62+
*/
63+
void onTrajectory(const autoware_auto_planning_msgs::msg::Trajectory::SharedPtr);
64+
/**
65+
* @brief set current_vehicle_pose_ with received message
66+
*/
67+
void onVehiclePose(const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg);
68+
/**
69+
* @brief set current_ground_truth_pose_ and calculate lateral error
70+
*/
71+
void onGroundTruthPose(const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg);
72+
};
73+
74+
#endif // AUTOWARE_DEBUG_TOOLS__LATERAL_ERROR_PUBLISHER_HPP_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<launch>
2+
3+
<arg name="lateral_error_publisher_param_path" default="$(find-pkg-share autoware_debug_tools)/config/lateral_error_publisher.param.yaml"/>
4+
5+
<!-- mpc for trajectory following -->
6+
<node pkg="autoware_debug_tools" exec="lateral_error_publisher_node" name="lateral_error_publisher" output="screen">
7+
<param from="$(var lateral_error_publisher_param_path)"/>
8+
<remap from="~/input/reference_trajectory" to="/planning/scenario_planning/trajectory"/>
9+
<remap from="~/input/vehicle_pose_with_covariance" to="/localization/pose_with_covariance"/>
10+
<remap from="~/input/ground_truth_pose_with_covariance" to="/localization/pose_with_covariance"/>
11+
</node>
12+
13+
</launch>

0 commit comments

Comments
 (0)