Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add localization utils #59

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9eeb00d
release v0.4.0
mitsudome-r Sep 18, 2020
b092820
Avoid setting CMAKE_BUILD_TYPE=Release in each CMakeLists.txt (#720)
harihitode Aug 2, 2020
ee2a67c
remove ROS1 packages temporarily
mitsudome-r Sep 29, 2020
f71f057
Port autoware_localization_srvs
nnmm Oct 7, 2020
2022661
Add DEPENDENCIES
nnmm Oct 7, 2020
57e5f5a
Revert "remove ROS1 packages temporarily"
mitsudome-r Oct 8, 2020
0f8c701
add COLCON_IGNORE to ros1 packages
mitsudome-r Oct 8, 2020
0b8fc36
Rename launch files to launch.xml (#28)
nnmm Oct 15, 2020
88d6a92
Port pose_initializer to ROS2 (#11)
nnmm Oct 22, 2020
77d8dd0
Fix lint issues (#128)
nnmm Dec 1, 2020
e15b60a
Rename h files to hpp (#142)
nnmm Dec 3, 2020
d93f9fe
Use quotes for includes where appropriate (#144)
nnmm Dec 7, 2020
0f76df9
fixing trasient_local in ROS2 packages (#160)
nik-tier4 Dec 11, 2020
fd33479
[ekf_localizer] [pose_initializer] fix topic message type (#176)
mitsudome-r Dec 15, 2020
f00e1d1
ading linters to pose_initializer (#186)
nik-tier4 Dec 16, 2020
114cf63
adding linters to autoware_localization_srvs (#185)
nik-tier4 Dec 17, 2020
a180609
Port initial-pose-button-panel (#125)
sgermanserrano Dec 21, 2020
65eca76
apply env_var to use_sim_time (#222)
k0suke-murakami Dec 23, 2020
758388a
retry gnss initialize (#1043) (#263)
wep21 Jan 17, 2021
81eca09
Ros2 v0.8.0 initial pose buttion panel (#312)
tkimura4 Feb 5, 2021
58a27ce
modify pose_initialize for foa (#382)
mitsudome-r Mar 2, 2021
de82f8d
Fix missing gnss subscriber (#417)
wep21 Mar 10, 2021
ad80b92
Ros2 fix ndt align srv (#442)
isamu-takagi Mar 23, 2021
afff267
Unify Apache-2.0 license name (#1242)
kmiya Apr 15, 2021
ef33076
Remove use_sim_time for set_parameter (#1260)
wep21 Apr 26, 2021
d728752
Fix dependency type of rosidl_default_generators (#1801)
kenji-miyake Aug 5, 2021
4240607
Fix -Wunused-parameter (#1836)
kenji-miyake Aug 14, 2021
287ad42
Add autoware api (#1979)
isamu-takagi Aug 31, 2021
e7fbcf5
add sort-package-xml hook in pre-commit (#1881)
KeisukeShima Sep 9, 2021
6ffd035
Change formatter to clang-format and black (#2332)
kenji-miyake Nov 2, 2021
6e3209c
Add COLCON_IGNORE (#500)
kenji-miyake Nov 4, 2021
4b7eb2a
Remove COLCON_IGNORE under localization (#553)
IshitaTakeshi Nov 9, 2021
98140a0
Remove 'pose_initializer/COLCON_IGNORE' (#556)
IshitaTakeshi Nov 9, 2021
169765c
add README.md (#623)
takayuki5168 Nov 15, 2021
3a408b9
add readme in pose initializer (#636)
k0suke-murakami Nov 17, 2021
0a608da
move autoware_localization_srvs package (#689)
YamatoAndo Nov 18, 2021
ed38158
Merge branch 'tier4/proposal' into 1-add-localization-utils
1222-takeshi Dec 2, 2021
450c3ca
Merge branch 'tier4/proposal' into 1-add-localization-utils
tkimura4 Dec 3, 2021
7335005
fix: move initial_pose_button_panel directory
1222-takeshi Dec 3, 2021
16cde73
Merge branch 'tier4/proposal' into 1-add-localization-utils
tkimura4 Dec 3, 2021
8fe2401
Merge branch 'tier4/proposal' into 1-add-localization-utils
1222-takeshi Dec 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions localization/initial_pose_button_panel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.5)
project(initial_pose_button_panel)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
set(QT_LIBRARIES Qt5::Widgets)

add_definitions(-DQT_NO_KEYWORDS -g)
set(CMAKE_AUTOMOC ON)

ament_auto_add_library(initial_pose_button_panel SHARED
src/initial_pose_button_panel.cpp)
target_link_libraries(initial_pose_button_panel
${QT_LIBRARIES})

# Export the plugin to be imported by rviz2
pluginlib_export_plugin_description_file(rviz_common plugins/plugin_description.xml)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package(
INSTALL_TO_SHARE
plugins
)
18 changes: 18 additions & 0 deletions localization/initial_pose_button_panel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# initial_pose_button_panel

## Role

`initial_pose_button_panel` is the package to send a request to the localization module to calculate the current ego pose.

It starts calculating the current ego pose by pushing the button on Rviz, implemented as an Rviz plugin.
You can see the button on the right bottom of Rviz.

![initialize_button](./media/initialize_button.png)

## Input / Output

### Input topics

| Name | Type | Description |
| ---------------------------------------------- | --------------------------------------------- | -------------------------------------------------------------- |
| `/sensing/gnss/pose_with_covariance` (default) | geometry_msgs::msg::PoseWithCovarianceStamped | initial pose with covariance to calculate the current ego pose |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions localization/initial_pose_button_panel/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<package format="2">
<name>initial_pose_button_panel</name>
<version>0.1.0</version>
<description>The initial_pose_button_panel package</description>

<maintainer email="yamato.ando@gmail.com">Yamato ANDO</maintainer>
<author>Yamato ANDO</author>

<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<depend>autoware_localization_msgs</depend>
<depend>geometry_msgs</depend>
<depend>libqt5-core</depend>
<depend>libqt5-widgets</depend>
<depend>qtbase5-dev</depend>
<depend>rviz_common</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
<rviz plugin="${prefix}/plugins/plugin_description.xml"/>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<library path="initial_pose_button_panel">
<class name="autoware_localization_rviz_plugin/InitialPoseButtonPanel"
type="autoware_localization_rviz_plugin::InitialPoseButtonPanel"
base_class_type="rviz_common::Panel">
<description>
initial button.
</description>
</class>
</library>
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Copyright 2020 Tier IV, Inc.
//
// 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.

#include "initial_pose_button_panel.hpp"

#include <QFileDialog>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QPainter>
#include <QPushButton>
#include <pluginlib/class_list_macros.hpp>
#include <rviz_common/display_context.hpp>

#include <memory>
#include <string>
#include <thread>
#include <vector>

namespace autoware_localization_rviz_plugin
{
InitialPoseButtonPanel::InitialPoseButtonPanel(QWidget * parent) : rviz_common::Panel(parent)
{
topic_label_ = new QLabel("PoseWithCovarianceStamped ");
topic_label_->setAlignment(Qt::AlignCenter);

topic_edit_ = new QLineEdit("/sensing/gnss/pose_with_covariance");
connect(topic_edit_, SIGNAL(textEdited(QString)), SLOT(editTopic()));

initialize_button_ = new QPushButton("Wait for subscribe topic");
initialize_button_->setEnabled(false);
connect(initialize_button_, SIGNAL(clicked(bool)), SLOT(pushInitializeButton()));

status_label_ = new QLabel("Not Initialize");
status_label_->setAlignment(Qt::AlignCenter);
status_label_->setStyleSheet("QLabel { background-color : gray;}");

QSizePolicy q_size_policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
initialize_button_->setSizePolicy(q_size_policy);

auto * topic_layout = new QHBoxLayout;
topic_layout->addWidget(topic_label_);
topic_layout->addWidget(topic_edit_);

auto * v_layout = new QVBoxLayout;
v_layout->addLayout(topic_layout);
v_layout->addWidget(initialize_button_);
v_layout->addWidget(status_label_);

setLayout(v_layout);
}
void InitialPoseButtonPanel::onInitialize()
{
rclcpp::Node::SharedPtr raw_node =
this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node();

pose_cov_sub_ = raw_node->create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
topic_edit_->text().toStdString(), 10,
std::bind(&InitialPoseButtonPanel::callbackPoseCov, this, std::placeholders::_1));

client_ = raw_node->create_client<autoware_localization_msgs::srv::PoseWithCovarianceStamped>(
"/localization/util/initialize_pose");
}

void InitialPoseButtonPanel::callbackPoseCov(
const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr msg)
{
pose_cov_msg_ = *msg;
initialize_button_->setText("Pose Initializer Let's GO!");
initialize_button_->setEnabled(true);
}

void InitialPoseButtonPanel::editTopic()
{
pose_cov_sub_.reset();
rclcpp::Node::SharedPtr raw_node =
this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node();
pose_cov_sub_ = raw_node->create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
topic_edit_->text().toStdString(), 10,
std::bind(&InitialPoseButtonPanel::callbackPoseCov, this, std::placeholders::_1));
initialize_button_->setText("Wait for subscribe topic");
initialize_button_->setEnabled(false);
}

void InitialPoseButtonPanel::pushInitializeButton()
{
// lock button
initialize_button_->setEnabled(false);

status_label_->setStyleSheet("QLabel { background-color : dodgerblue;}");
status_label_->setText("Initializing...");

std::thread thread([this] {
auto req =
std::make_shared<autoware_localization_msgs::srv::PoseWithCovarianceStamped::Request>();
req->pose_with_covariance = pose_cov_msg_;

client_->async_send_request(
req,
[this](
rclcpp::Client<autoware_localization_msgs::srv::PoseWithCovarianceStamped>::SharedFuture
result) {
status_label_->setStyleSheet("QLabel { background-color : lightgreen;}");
status_label_->setText("OK!!!");

// unlock button
initialize_button_->setEnabled(true);
});
});

thread.detach();
}

} // end namespace autoware_localization_rviz_plugin

PLUGINLIB_EXPORT_CLASS(
autoware_localization_rviz_plugin::InitialPoseButtonPanel, rviz_common::Panel)
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2020 Tier IV, Inc.
//
// 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.

#pragma once

#ifndef INITIAL_POSE_BUTTON_PANEL_HPP_
#define INITIAL_POSE_BUTTON_PANEL_HPP_

#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QSettings>

#include <string>
#ifndef Q_MOC_RUN

#include <rclcpp/rclcpp.hpp>
#include <rviz_common/panel.hpp>
#include <rviz_common/properties/ros_topic_property.hpp>
#endif
#include <autoware_localization_msgs/srv/pose_with_covariance_stamped.hpp>
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>

namespace autoware_localization_rviz_plugin
{
class InitialPoseButtonPanel : public rviz_common::Panel
{
Q_OBJECT

public:
explicit InitialPoseButtonPanel(QWidget * parent = nullptr);
void onInitialize() override;
void callbackPoseCov(const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr msg);

public Q_SLOTS:
void editTopic();
void pushInitializeButton();

protected:
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr pose_cov_sub_;

rclcpp::Client<autoware_localization_msgs::srv::PoseWithCovarianceStamped>::SharedPtr client_;

QLabel * topic_label_;
QLineEdit * topic_edit_;
QPushButton * initialize_button_;
QLabel * status_label_;

geometry_msgs::msg::PoseWithCovarianceStamped pose_cov_msg_;
};

} // end namespace autoware_localization_rviz_plugin

#endif // INITIAL_POSE_BUTTON_PANEL_HPP_
32 changes: 32 additions & 0 deletions localization/pose_initializer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.5)
project(pose_initializer)

### Compile options
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

### Dependencies
find_package(ament_cmake_auto REQUIRED)
find_package(PCL REQUIRED)
ament_auto_find_build_dependencies()

ament_auto_add_executable(pose_initializer
src/pose_initializer_node.cpp
src/pose_initializer_core.cpp
)
target_link_libraries(pose_initializer ${PCL_LIBRARIES})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package(INSTALL_TO_SHARE
launch
)
24 changes: 24 additions & 0 deletions localization/pose_initializer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# pose_initializer

## Purpose

`pose_initializer` is the package to send an initial pose to `ekf_localizer`.
It receives roughly estimated initial pose from GNSS/user.
Passing the pose to `ndt_scan_matcher`, and it gets a calculated ego pose from `ndt_scan_matcher` via service.
Finally, it publishes the initial pose to `ekf_localizer`.

## Input / Output

### Input topics

| Name | Type | Description |
| ------------------------------------ | --------------------------------------------- | ---------------------- |
| `/initialpose` | geometry_msgs::msg::PoseWithCovarianceStamped | initial pose from rviz |
| `/sensing/gnss/pose_with_covariance` | geometry_msgs::msg::PoseWithCovarianceStamped | pose from gnss |
| `/map/pointcloud_map` | sensor_msgs::msg::PointCloud2 | pointcloud map |

### Output topics

| Name | Type | Description |
| ---------------- | --------------------------------------------- | --------------------------- |
| `/initialpose3d` | geometry_msgs::msg::PoseWithCovarianceStamped | calculated initial ego pose |
Loading