Skip to content

Commit 5d6f417

Browse files
1222-takeshimitsudome-rharihitodekenji-miyakennmm
authored
feat: add localization utils (#59)
* release v0.4.0 * Avoid setting CMAKE_BUILD_TYPE=Release in each CMakeLists.txt (#720) * remove set CMAKE_BUILD_TYPE Release in each CMakeLists.txt * remove set CMAKE_BUILD_TYPE Release in ndt_pcl_modified * set compile options for debug in ndt_omp * Fix indent * add warning if -DCMAKE_BUILD_TYPE=Release is not set in ndt_omp Co-authored-by: Kenji Miyake <31987104+kenji-miyake@users.noreply.github.com> * remove ROS1 packages temporarily Signed-off-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> * Port autoware_localization_srvs * Add DEPENDENCIES * Revert "remove ROS1 packages temporarily" This reverts commit ee01a755ac5b22c61f4274ae2ee57b0a18150a78. Signed-off-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> * add COLCON_IGNORE to ros1 packages Signed-off-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> * Rename launch files to launch.xml (#28) * Port pose_initializer to ROS2 (#11) * CMakeLists.txt & package.xml * Compiles * Works * Use callback instead * Reviewer feedback * Add sequence number check * Review feedback * Fix lint issues (#128) * Rename h files to hpp (#142) * Change includes * Rename files * Adjustments to make things compile * Other packages * Use quotes for includes where appropriate (#144) * Use quotes for includes where appropriate * Fix lint tests * Make tests pass hopefully * fixing trasient_local in ROS2 packages (#160) * [ekf_localizer] [pose_initializer] fix topic message type (#176) Co-authored-by: Autoware <autoware@tier4.jp> Co-authored-by: Takamasa Horibe <horibe.takamasa@gmail.com> * ading linters to pose_initializer (#186) * adding linters to autoware_localization_srvs (#185) * Port initial-pose-button-panel (#125) * Port Signed-off-by: Servando German Serrano <servando.german.serrano@linaro.org> * Initialize button when request received Signed-off-by: Servando German Serrano <servando.german.serrano@linaro.org> * Amend buildtool Signed-off-by: Servando German Serrano <servando.german.serrano@linaro.org> * Fix license Signed-off-by: Servando German Serrano <servando.german.serrano@linaro.org> * apply env_var to use_sim_time (#222) * retry gnss initialize (#1043) (#263) Co-authored-by: YamatoAndo <yamato.ando@gmail.com> * Ros2 v0.8.0 initial pose buttion panel (#312) * restore initial pose button panel files for v0.8.0 update * fix typos in localization (#890) * Fix memory leak and remove unused properties (#964) * Revert "restore initial pose button panel files for v0.8.0 update" This reverts commit 01281a2633636f80f241a788f9d35c517a2977e1. * delete unused header * add ament lint test * apply ament_lint * fix bug Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> * modify pose_initialize for foa (#382) * pose_initialize for foa (#1171) * pose_initialize for foa Signed-off-by: Yamato ANDO <yamato.ando@gmail.com> * rename topic Signed-off-by: Yamato ANDO <yamato.ando@gmail.com> * fix topic name Signed-off-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> * Fix missing gnss subscriber (#417) Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> * Ros2 fix ndt align srv (#442) * Add success field to ndt align srv response Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * Apply change of ndt align srv Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * Apply change of ndt align srv Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * Fix lint Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * Unify Apache-2.0 license name (#1242) * Remove use_sim_time for set_parameter (#1260) Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> * Fix dependency type of rosidl_default_generators (#1801) * Fix dependency type of rosidl_default_generators Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Remove unnecessary depends Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Use ament_cmake_auto Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix -Wunused-parameter (#1836) * Fix -Wunused-parameter Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix mistake Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * fix spell * Fix lint issues Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Ignore flake8 warnings Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> Co-authored-by: Hiroki OTA <hiroki.ota@tier4.jp> * Add autoware api (#1979) * add sort-package-xml hook in pre-commit (#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 * Change formatter to clang-format and black (#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 (#500) Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Remove COLCON_IGNORE under localization (#553) * Remove 'pose_initializer/COLCON_IGNORE' (#556) * add README.md (#623) * add README.md * fix typo * minor fix * Update localization/util/autoware_localization_rviz_plugin/initial_pose_button_panel/README.md Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> * Update localization/util/autoware_localization_rviz_plugin/initial_pose_button_panel/README.md Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> * Update localization/util/autoware_localization_rviz_plugin/initial_pose_button_panel/README.md Co-authored-by: Takayuki Murooka <takayuki.murooka@tier4.jp> Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> Co-authored-by: tkimura4 <tomoya.kimura@tier4.jp> * add readme in pose initializer (#636) * add readme in pose initializer Signed-off-by: Kosuke Murakami <kosuke.murakami@tier4.jp> * modify doc Signed-off-by: Kosuke Murakami <kosuke.murakami@tier4.jp> * move autoware_localization_srvs package (#689) * move autoware_localization_srvs package * apply pre-commit * rename pose_with_cov to pose_with_covariance * apply pre-commit * fix: move initial_pose_button_panel directory Co-authored-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> Co-authored-by: Daichi Murakami <harihitode@gmail.com> Co-authored-by: Kenji Miyake <31987104+kenji-miyake@users.noreply.github.com> Co-authored-by: Nikolai Morin <nikolai.morin@apex.ai> Co-authored-by: Nikolai Morin <nnmmgit@gmail.com> Co-authored-by: nik-tier4 <71747268+nik-tier4@users.noreply.github.com> Co-authored-by: Ryohsuke Mitsudome <43976834+mitsudome-r@users.noreply.github.com> Co-authored-by: Autoware <autoware@tier4.jp> Co-authored-by: Takamasa Horibe <horibe.takamasa@gmail.com> Co-authored-by: Servando <43142004+sgermanserrano@users.noreply.github.com> Co-authored-by: Kosuke Murakami <kosuke.murakami@tier4.jp> Co-authored-by: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> Co-authored-by: YamatoAndo <yamato.ando@gmail.com> Co-authored-by: tkimura4 <tomoya.kimura@tier4.jp> Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> Co-authored-by: Takagi, Isamu <43976882+isamu-takagi@users.noreply.github.com> Co-authored-by: Hiroki OTA <hiroki.ota@tier4.jp> Co-authored-by: Keisuke Shima <19993104+KeisukeShima@users.noreply.github.com> Co-authored-by: Takeshi Ishita <ishitah.takeshi@gmail.com> Co-authored-by: Takayuki Murooka <takayuki5168@gmail.com> Co-authored-by: Takayuki Murooka <takayuki.murooka@tier4.jp>
1 parent a200fa4 commit 5d6f417

14 files changed

+748
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(initial_pose_button_panel)
3+
4+
if(NOT CMAKE_CXX_STANDARD)
5+
set(CMAKE_CXX_STANDARD 14)
6+
endif()
7+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
8+
add_compile_options(-Wall -Wextra -Wpedantic)
9+
endif()
10+
11+
find_package(ament_cmake_auto REQUIRED)
12+
ament_auto_find_build_dependencies()
13+
14+
find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
15+
set(QT_LIBRARIES Qt5::Widgets)
16+
17+
add_definitions(-DQT_NO_KEYWORDS -g)
18+
set(CMAKE_AUTOMOC ON)
19+
20+
ament_auto_add_library(initial_pose_button_panel SHARED
21+
src/initial_pose_button_panel.cpp)
22+
target_link_libraries(initial_pose_button_panel
23+
${QT_LIBRARIES})
24+
25+
# Export the plugin to be imported by rviz2
26+
pluginlib_export_plugin_description_file(rviz_common plugins/plugin_description.xml)
27+
28+
if(BUILD_TESTING)
29+
find_package(ament_lint_auto REQUIRED)
30+
ament_lint_auto_find_test_dependencies()
31+
endif()
32+
33+
ament_auto_package(
34+
INSTALL_TO_SHARE
35+
plugins
36+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# initial_pose_button_panel
2+
3+
## Role
4+
5+
`initial_pose_button_panel` is the package to send a request to the localization module to calculate the current ego pose.
6+
7+
It starts calculating the current ego pose by pushing the button on Rviz, implemented as an Rviz plugin.
8+
You can see the button on the right bottom of Rviz.
9+
10+
![initialize_button](./media/initialize_button.png)
11+
12+
## Input / Output
13+
14+
### Input topics
15+
16+
| Name | Type | Description |
17+
| ---------------------------------------------- | --------------------------------------------- | -------------------------------------------------------------- |
18+
| `/sensing/gnss/pose_with_covariance` (default) | geometry_msgs::msg::PoseWithCovarianceStamped | initial pose with covariance to calculate the current ego pose |
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<package format="2">
3+
<name>initial_pose_button_panel</name>
4+
<version>0.1.0</version>
5+
<description>The initial_pose_button_panel package</description>
6+
7+
<maintainer email="yamato.ando@gmail.com">Yamato ANDO</maintainer>
8+
<author>Yamato ANDO</author>
9+
10+
<license>Apache License 2.0</license>
11+
12+
<buildtool_depend>ament_cmake_auto</buildtool_depend>
13+
<depend>autoware_localization_msgs</depend>
14+
<depend>geometry_msgs</depend>
15+
<depend>libqt5-core</depend>
16+
<depend>libqt5-widgets</depend>
17+
<depend>qtbase5-dev</depend>
18+
<depend>rviz_common</depend>
19+
20+
<test_depend>ament_lint_auto</test_depend>
21+
<test_depend>autoware_lint_common</test_depend>
22+
23+
<export>
24+
<build_type>ament_cmake</build_type>
25+
<rviz plugin="${prefix}/plugins/plugin_description.xml"/>
26+
</export>
27+
</package>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<library path="initial_pose_button_panel">
2+
<class name="autoware_localization_rviz_plugin/InitialPoseButtonPanel"
3+
type="autoware_localization_rviz_plugin::InitialPoseButtonPanel"
4+
base_class_type="rviz_common::Panel">
5+
<description>
6+
initial button.
7+
</description>
8+
</class>
9+
</library>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Copyright 2020 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+
#include "initial_pose_button_panel.hpp"
16+
17+
#include <QFileDialog>
18+
#include <QHBoxLayout>
19+
#include <QLineEdit>
20+
#include <QPainter>
21+
#include <QPushButton>
22+
#include <pluginlib/class_list_macros.hpp>
23+
#include <rviz_common/display_context.hpp>
24+
25+
#include <memory>
26+
#include <string>
27+
#include <thread>
28+
#include <vector>
29+
30+
namespace autoware_localization_rviz_plugin
31+
{
32+
InitialPoseButtonPanel::InitialPoseButtonPanel(QWidget * parent) : rviz_common::Panel(parent)
33+
{
34+
topic_label_ = new QLabel("PoseWithCovarianceStamped ");
35+
topic_label_->setAlignment(Qt::AlignCenter);
36+
37+
topic_edit_ = new QLineEdit("/sensing/gnss/pose_with_covariance");
38+
connect(topic_edit_, SIGNAL(textEdited(QString)), SLOT(editTopic()));
39+
40+
initialize_button_ = new QPushButton("Wait for subscribe topic");
41+
initialize_button_->setEnabled(false);
42+
connect(initialize_button_, SIGNAL(clicked(bool)), SLOT(pushInitializeButton()));
43+
44+
status_label_ = new QLabel("Not Initialize");
45+
status_label_->setAlignment(Qt::AlignCenter);
46+
status_label_->setStyleSheet("QLabel { background-color : gray;}");
47+
48+
QSizePolicy q_size_policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
49+
initialize_button_->setSizePolicy(q_size_policy);
50+
51+
auto * topic_layout = new QHBoxLayout;
52+
topic_layout->addWidget(topic_label_);
53+
topic_layout->addWidget(topic_edit_);
54+
55+
auto * v_layout = new QVBoxLayout;
56+
v_layout->addLayout(topic_layout);
57+
v_layout->addWidget(initialize_button_);
58+
v_layout->addWidget(status_label_);
59+
60+
setLayout(v_layout);
61+
}
62+
void InitialPoseButtonPanel::onInitialize()
63+
{
64+
rclcpp::Node::SharedPtr raw_node =
65+
this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node();
66+
67+
pose_cov_sub_ = raw_node->create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
68+
topic_edit_->text().toStdString(), 10,
69+
std::bind(&InitialPoseButtonPanel::callbackPoseCov, this, std::placeholders::_1));
70+
71+
client_ = raw_node->create_client<autoware_localization_msgs::srv::PoseWithCovarianceStamped>(
72+
"/localization/util/initialize_pose");
73+
}
74+
75+
void InitialPoseButtonPanel::callbackPoseCov(
76+
const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr msg)
77+
{
78+
pose_cov_msg_ = *msg;
79+
initialize_button_->setText("Pose Initializer Let's GO!");
80+
initialize_button_->setEnabled(true);
81+
}
82+
83+
void InitialPoseButtonPanel::editTopic()
84+
{
85+
pose_cov_sub_.reset();
86+
rclcpp::Node::SharedPtr raw_node =
87+
this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node();
88+
pose_cov_sub_ = raw_node->create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
89+
topic_edit_->text().toStdString(), 10,
90+
std::bind(&InitialPoseButtonPanel::callbackPoseCov, this, std::placeholders::_1));
91+
initialize_button_->setText("Wait for subscribe topic");
92+
initialize_button_->setEnabled(false);
93+
}
94+
95+
void InitialPoseButtonPanel::pushInitializeButton()
96+
{
97+
// lock button
98+
initialize_button_->setEnabled(false);
99+
100+
status_label_->setStyleSheet("QLabel { background-color : dodgerblue;}");
101+
status_label_->setText("Initializing...");
102+
103+
std::thread thread([this] {
104+
auto req =
105+
std::make_shared<autoware_localization_msgs::srv::PoseWithCovarianceStamped::Request>();
106+
req->pose_with_covariance = pose_cov_msg_;
107+
108+
client_->async_send_request(
109+
req,
110+
[this](
111+
rclcpp::Client<autoware_localization_msgs::srv::PoseWithCovarianceStamped>::SharedFuture
112+
result) {
113+
status_label_->setStyleSheet("QLabel { background-color : lightgreen;}");
114+
status_label_->setText("OK!!!");
115+
116+
// unlock button
117+
initialize_button_->setEnabled(true);
118+
});
119+
});
120+
121+
thread.detach();
122+
}
123+
124+
} // end namespace autoware_localization_rviz_plugin
125+
126+
PLUGINLIB_EXPORT_CLASS(
127+
autoware_localization_rviz_plugin::InitialPoseButtonPanel, rviz_common::Panel)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright 2020 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+
#pragma once
16+
17+
#ifndef INITIAL_POSE_BUTTON_PANEL_HPP_
18+
#define INITIAL_POSE_BUTTON_PANEL_HPP_
19+
20+
#include <QLabel>
21+
#include <QLineEdit>
22+
#include <QPushButton>
23+
#include <QSettings>
24+
25+
#include <string>
26+
#ifndef Q_MOC_RUN
27+
28+
#include <rclcpp/rclcpp.hpp>
29+
#include <rviz_common/panel.hpp>
30+
#include <rviz_common/properties/ros_topic_property.hpp>
31+
#endif
32+
#include <autoware_localization_msgs/srv/pose_with_covariance_stamped.hpp>
33+
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
34+
35+
namespace autoware_localization_rviz_plugin
36+
{
37+
class InitialPoseButtonPanel : public rviz_common::Panel
38+
{
39+
Q_OBJECT
40+
41+
public:
42+
explicit InitialPoseButtonPanel(QWidget * parent = nullptr);
43+
void onInitialize() override;
44+
void callbackPoseCov(const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr msg);
45+
46+
public Q_SLOTS:
47+
void editTopic();
48+
void pushInitializeButton();
49+
50+
protected:
51+
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr pose_cov_sub_;
52+
53+
rclcpp::Client<autoware_localization_msgs::srv::PoseWithCovarianceStamped>::SharedPtr client_;
54+
55+
QLabel * topic_label_;
56+
QLineEdit * topic_edit_;
57+
QPushButton * initialize_button_;
58+
QLabel * status_label_;
59+
60+
geometry_msgs::msg::PoseWithCovarianceStamped pose_cov_msg_;
61+
};
62+
63+
} // end namespace autoware_localization_rviz_plugin
64+
65+
#endif // INITIAL_POSE_BUTTON_PANEL_HPP_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(pose_initializer)
3+
4+
### Compile options
5+
if(NOT CMAKE_CXX_STANDARD)
6+
set(CMAKE_CXX_STANDARD 14)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
set(CMAKE_CXX_EXTENSIONS OFF)
9+
endif()
10+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
11+
add_compile_options(-Wall -Wextra -Wpedantic)
12+
endif()
13+
14+
### Dependencies
15+
find_package(ament_cmake_auto REQUIRED)
16+
find_package(PCL REQUIRED)
17+
ament_auto_find_build_dependencies()
18+
19+
ament_auto_add_executable(pose_initializer
20+
src/pose_initializer_node.cpp
21+
src/pose_initializer_core.cpp
22+
)
23+
target_link_libraries(pose_initializer ${PCL_LIBRARIES})
24+
25+
if(BUILD_TESTING)
26+
find_package(ament_lint_auto REQUIRED)
27+
ament_lint_auto_find_test_dependencies()
28+
endif()
29+
30+
ament_auto_package(INSTALL_TO_SHARE
31+
launch
32+
)
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# pose_initializer
2+
3+
## Purpose
4+
5+
`pose_initializer` is the package to send an initial pose to `ekf_localizer`.
6+
It receives roughly estimated initial pose from GNSS/user.
7+
Passing the pose to `ndt_scan_matcher`, and it gets a calculated ego pose from `ndt_scan_matcher` via service.
8+
Finally, it publishes the initial pose to `ekf_localizer`.
9+
10+
## Input / Output
11+
12+
### Input topics
13+
14+
| Name | Type | Description |
15+
| ------------------------------------ | --------------------------------------------- | ---------------------- |
16+
| `/initialpose` | geometry_msgs::msg::PoseWithCovarianceStamped | initial pose from rviz |
17+
| `/sensing/gnss/pose_with_covariance` | geometry_msgs::msg::PoseWithCovarianceStamped | pose from gnss |
18+
| `/map/pointcloud_map` | sensor_msgs::msg::PointCloud2 | pointcloud map |
19+
20+
### Output topics
21+
22+
| Name | Type | Description |
23+
| ---------------- | --------------------------------------------- | --------------------------- |
24+
| `/initialpose3d` | geometry_msgs::msg::PoseWithCovarianceStamped | calculated initial ego pose |

0 commit comments

Comments
 (0)