-
Notifications
You must be signed in to change notification settings - Fork 676
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add_aw_pose_covariance_modifier_node
Signed-off-by: melike <[email protected]>
- Loading branch information
1 parent
871f8f2
commit 61f99da
Showing
10 changed files
with
316 additions
and
8 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
33 changes: 33 additions & 0 deletions
33
localization/aw_pose_covariance_modifier_node/CMakeLists.txt
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,33 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(aw_pose_covariance_modifier_node) | ||
|
||
find_package(autoware_cmake REQUIRED) | ||
autoware_package() | ||
find_package(rclcpp REQUIRED) | ||
find_package(geometry_msgs REQUIRED) | ||
find_package(std_srvs REQUIRED) | ||
|
||
set(NODE_NAME ${PROJECT_NAME}) | ||
set(EXEC_NAME ${PROJECT_NAME}_exe) | ||
|
||
add_executable(${PROJECT_NAME} src/aw_pose_covariance_modifier_node.cpp) | ||
|
||
ament_target_dependencies(${PROJECT_NAME} rclcpp geometry_msgs std_srvs) | ||
|
||
install(TARGETS | ||
${PROJECT_NAME} | ||
DESTINATION lib/${PROJECT_NAME} | ||
) | ||
include_directories(src/include/) | ||
|
||
#ament_auto_add_library(${NODE_NAME} | ||
# src/include/aw_pose_covariance_modifier_node.hpp | ||
# src/aw_pose_covariance_modifier_node.cpp) | ||
|
||
#rclcpp_components_register_node(${NODE_NAME} | ||
# PLUGIN "aw_pose_covariance_modifier_node::AWPoseCovarianceModifierNode" | ||
# EXECUTABLE ${EXEC_NAME}) | ||
|
||
|
||
ament_auto_package(INSTALL_TO_SHARE | ||
launch) |
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 @@ | ||
# aw_pose_covariance_modifier |
12 changes: 12 additions & 0 deletions
12
...ation/aw_pose_covariance_modifier_node/launch/aw_pose_covariance_modifier_node.launch.xml
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<launch> | ||
<arg name="input_trusted_pose_with_cov_topic" default="/sensing/gnss/pose_with_covariance" description="Trusted pose input .. "/> | ||
<arg name="output_pose_with_covariance_topic" default="/localization/pose_estimator/pose_with_covariance" description="Estimated self position with covariance"/> | ||
|
||
|
||
<node pkg="aw_pose_covariance_modifier_node" exec="aw_pose_covariance_modifier_node" name="aw_pose_covariance_modifier_node" output="screen" > | ||
<remap from="input_trusted_pose_with_cov_topic" to="$(var input_trusted_pose_with_cov_topic)"/> | ||
<remap from="output_pose_with_covariance_topic" to="$(var output_pose_with_covariance_topic)"/> | ||
|
||
</node> | ||
</launch> |
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,26 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>aw_pose_covariance_modifier_node</name> | ||
<version>1.0.0</version> | ||
<description>Converts an autoware_msgs message to autoware_auto_msgs version and publishes it.</description> | ||
|
||
<maintainer email="[email protected]">Melike Tanrikulu</maintainer> | ||
|
||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
<buildtool_depend>autoware_cmake</buildtool_depend> | ||
|
||
<build_depend>rosidl_default_generators</build_depend> | ||
|
||
<depend>rclcpp</depend> | ||
<depend>rclcpp_components</depend> | ||
|
||
<depend>geometry_msgs</depend> | ||
<depend>std_srvs</depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
90 changes: 90 additions & 0 deletions
90
localization/aw_pose_covariance_modifier_node/src/aw_pose_covariance_modifier_node.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,90 @@ | ||
// Copyright 2024 The 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. | ||
|
||
#include "include/aw_pose_covariance_modifier_node.hpp" | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
|
||
AWPoseCovarianceModifierNode::AWPoseCovarianceModifierNode() | ||
: Node("AWPoseCovarianceModifierNode") | ||
{ | ||
trusted_pose_with_cov_sub_ = this->create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>( | ||
"input_trusted_pose_with_cov_topic",10000,std::bind(&AWPoseCovarianceModifierNode::trusted_pose_with_cov_callback,this,std::placeholders::_1)); | ||
|
||
|
||
new_pose_estimator_pub_ = this->create_publisher<geometry_msgs::msg::PoseWithCovarianceStamped>("output_pose_with_covariance_topic",10); | ||
|
||
client_ = this->create_client<std_srvs::srv::SetBool>("/localization/pose_estimator/covariance_modifier"); | ||
|
||
startNDTCovModifier = AWPoseCovarianceModifierNode::callNDTCovarianceModifier(); | ||
if(startNDTCovModifier == 1){ | ||
RCLCPP_INFO(get_logger(), "NDT pose covariance modifier activated ..."); | ||
|
||
} | ||
|
||
} | ||
|
||
bool AWPoseCovarianceModifierNode::callNDTCovarianceModifier(){ | ||
|
||
while (!client_->wait_for_service(std::chrono::seconds(1))) { | ||
if (!rclcpp::ok()) { | ||
RCLCPP_ERROR(get_logger(), "Interrupted while waiting for the service. Exiting."); | ||
return false; | ||
} | ||
RCLCPP_INFO(get_logger(), "Service not available, waiting again..."); | ||
} | ||
|
||
auto request = std::make_shared<std_srvs::srv::SetBool::Request>(); | ||
request->data = true; | ||
|
||
auto future_result = client_->async_send_request(request); | ||
if (rclcpp::spin_until_future_complete(get_node_base_interface(), future_result) == | ||
rclcpp::FutureReturnCode::SUCCESS) | ||
{ | ||
auto response = future_result.get(); | ||
RCLCPP_INFO(get_logger(), "Response: %d", response->success); | ||
return true; | ||
} | ||
else { | ||
RCLCPP_ERROR(get_logger(), "Failed to receive response."); | ||
return false; | ||
} | ||
} | ||
void AWPoseCovarianceModifierNode::trusted_pose_with_cov_callback(const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr &msg) { | ||
|
||
geometry_msgs::msg::PoseWithCovarianceStamped pose_estimator_pose = *msg; | ||
|
||
trusted_pose_rmse_ = (std::sqrt(pose_estimator_pose.pose.covariance[0]) + std::sqrt(pose_estimator_pose.pose.covariance[7]) ) / 2; | ||
trusted_pose_yaw_rmse_in_degrees_ = std::sqrt(pose_estimator_pose.pose.covariance[35]) * 180 / M_PI; | ||
|
||
if (trusted_pose_rmse_ > 0.25){ | ||
RCLCPP_INFO(this->get_logger(),"Trusted Pose RMSE is under the threshold. It will not be used as a pose source."); | ||
} | ||
else{ | ||
|
||
if (trusted_pose_yaw_rmse_in_degrees_ >= 0.3){ | ||
pose_estimator_pose.pose.covariance[35] = 1000000; | ||
} | ||
|
||
new_pose_estimator_pub_->publish(pose_estimator_pose); | ||
|
||
} | ||
|
||
} | ||
int main(int argc, char *argv[]) { | ||
rclcpp::init(argc, argv); | ||
rclcpp::spin(std::make_shared<AWPoseCovarianceModifierNode>()); | ||
rclcpp::shutdown(); | ||
return 0; | ||
} |
42 changes: 42 additions & 0 deletions
42
...ization/aw_pose_covariance_modifier_node/src/include/aw_pose_covariance_modifier_node.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,42 @@ | ||
// Copyright 2024 The 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 AW_POSE_COVARIANCE_MODIFIER_NODE_HPP_ | ||
#define AW_POSE_COVARIANCE_MODIFIER_NODE_HPP_ | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
#include <std_srvs/srv/set_bool.hpp> | ||
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp> | ||
#include <string> | ||
|
||
using namespace std::chrono_literals; | ||
|
||
class AWPoseCovarianceModifierNode : public rclcpp::Node | ||
{ | ||
public: | ||
AWPoseCovarianceModifierNode(); | ||
|
||
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr trusted_pose_with_cov_sub_; | ||
rclcpp::Publisher<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr new_pose_estimator_pub_; | ||
rclcpp::Client<std_srvs::srv::SetBool>::SharedPtr client_; | ||
|
||
void trusted_pose_with_cov_callback(const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr &msg); | ||
bool callNDTCovarianceModifier(); | ||
private: | ||
double trusted_pose_rmse_; | ||
double trusted_pose_yaw_rmse_in_degrees_; | ||
bool startNDTCovModifier = 0; | ||
}; | ||
|
||
|
||
#endif // AW_POSE_COVARIANCE_MODIFIER_NODE_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
Oops, something went wrong.