forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request autowarefoundation#3 from SKT-r/feat/add_nerf_init…
…ializer feat: add initializer to nerf
- Loading branch information
Showing
10 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
localization/pose_initializer/src/pose_initializer/nerf_module.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// | ||
// 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 "nerf_module.hpp" | ||
|
||
#include <component_interface_specs/localization.hpp> | ||
#include <component_interface_utils/rclcpp/exceptions.hpp> | ||
|
||
#include <memory> | ||
|
||
using ServiceException = component_interface_utils::ServiceException; | ||
using Initialize = localization_interface::Initialize; | ||
using PoseWithCovarianceStamped = geometry_msgs::msg::PoseWithCovarianceStamped; | ||
|
||
NeRFModule::NeRFModule(rclcpp::Node * node) : logger_(node->get_logger()) | ||
{ | ||
cli_align_ = node->create_client<RequestPoseAlignment>("nerf_align"); | ||
} | ||
|
||
PoseWithCovarianceStamped NeRFModule::align_pose(const PoseWithCovarianceStamped & pose) | ||
{ | ||
const auto req = std::make_shared<RequestPoseAlignment::Request>(); | ||
req->pose_with_covariance = pose; | ||
|
||
if (!cli_align_->service_is_ready()) { | ||
throw component_interface_utils::ServiceUnready("NeRF align server is not ready."); | ||
} | ||
|
||
RCLCPP_INFO(logger_, "Call NeRF align server."); | ||
const auto res = cli_align_->async_send_request(req).get(); | ||
if (!res->success) { | ||
throw ServiceException( | ||
Initialize::Service::Response::ERROR_ESTIMATION, "NeRF align server failed."); | ||
} | ||
RCLCPP_INFO(logger_, "NeRF align server succeeded."); | ||
|
||
// Overwrite the covariance. | ||
return res->pose_with_covariance; | ||
} |
38 changes: 38 additions & 0 deletions
38
localization/pose_initializer/src/pose_initializer/nerf_module.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2022 The Autoware Contributors | ||
// | ||
// 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 POSE_INITIALIZER__NERF_MODULE_HPP_ | ||
#define POSE_INITIALIZER__NERF_MODULE_HPP_ | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp> | ||
#include <tier4_localization_msgs/srv/pose_with_covariance_stamped.hpp> | ||
|
||
class NeRFModule | ||
{ | ||
private: | ||
using PoseWithCovarianceStamped = geometry_msgs::msg::PoseWithCovarianceStamped; | ||
using RequestPoseAlignment = tier4_localization_msgs::srv::PoseWithCovarianceStamped; | ||
|
||
public: | ||
explicit NeRFModule(rclcpp::Node * node); | ||
PoseWithCovarianceStamped align_pose(const PoseWithCovarianceStamped & pose); | ||
|
||
private: | ||
rclcpp::Logger logger_; | ||
rclcpp::Client<RequestPoseAlignment>::SharedPtr cli_align_; | ||
}; | ||
|
||
#endif // POSE_INITIALIZER__NERF_MODULE_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters