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(geo_pose_projector): use geo_pose_projector in eagleye #5513

Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,13 @@
</group>

<group if="$(var use_eagleye_pose)">
<include file="$(find-pkg-share eagleye_geo_pose_fusion)/launch/geo_pose_fusion.launch.xml"/>
<include file="$(find-pkg-share tier4_localization_launch)/launch/pose_twist_estimator/eagleye/geo_pose_converter.launch.xml">
<arg name="output_pose_with_cov_name" value="$(var output_pose_with_cov_name)"/>
<arg name="geo_pose_topic_name" default="eagleye/geo_pose_with_covariance"/>
<include file="$(find-pkg-share eagleye_geo_pose_fusion)/launch/geo_pose_fusion.launch.xml">
<arg name="output_geo_pose" value="$(var geo_pose_topic_name)"/>
</include>
<include file="$(find-pkg-share geo_pose_projector)/launch/geo_pose_projector.launch.xml">
<arg name="input_geo_pose" value="$(var geo_pose_topic_name)"/>
<arg name="output_pose" value="$(var output_pose_with_cov_name)"/>
</include>
</group>
</launch>

This file was deleted.

2 changes: 1 addition & 1 deletion launch/tier4_localization_launch/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

<exec_depend>ar_tag_based_localizer</exec_depend>
<exec_depend>automatic_pose_initializer</exec_depend>
<exec_depend>eagleye_geo_pose_converter</exec_depend>
<exec_depend>eagleye_geo_pose_fusion</exec_depend>
<exec_depend>eagleye_gnss_converter</exec_depend>
<exec_depend>eagleye_rt</exec_depend>
<exec_depend>ekf_localizer</exec_depend>
<exec_depend>geo_pose_projector</exec_depend>
<exec_depend>gyro_odometer</exec_depend>
<exec_depend>ndt_scan_matcher</exec_depend>
<exec_depend>pointcloud_preprocessor</exec_depend>
Expand Down
17 changes: 17 additions & 0 deletions localization/geo_pose_projector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.14)
project(geo_pose_projector)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_executable(geo_pose_projector
src/geo_pose_projector_node.cpp
src/geo_pose_projector.cpp
)
ament_target_dependencies(geo_pose_projector)

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

## Overview

This node is a simple node that subscribes to the geo-referenced pose topic and publishes the pose in the map frame.

## Subscribed Topics

| Name | Type | Description |
| ------------------------- | ---------------------------------------------------- | ------------------- |
| `input_geo_pose` | `geographic_msgs::msg::GeoPoseWithCovarianceStamped` | geo-referenced pose |
| `/map/map_projector_info` | `tier4_map_msgs::msg::MapProjectedObjectInfo` | map projector info |

## Published Topics

| Name | Type | Description |
| ------------- | ----------------------------------------------- | ----------------- |
| `output_pose` | `geometry_msgs::msg::PoseWithCovarianceStamped` | pose in map frame |

YamatoAndo marked this conversation as resolved.
Show resolved Hide resolved
## Parameters

{{ json_to_markdown("localization/geo_pose_projector/schema/geo_pose_projector.schema.json") }}

## Limitations

The covariance conversion may be incorrect depending on the projection type you are using. The covariance of input topic is expressed in (Latitude, Longitude, Altitude) as a diagonal matrix.
Currently, we assume that the x axis is the east direction and the y axis is the north direction. Thus, the conversion may be incorrect when this assumption breaks, especially when the covariance of latitude and longitude is different.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**:
ros__parameters:
publish_tf: true
parent_frame: "map"
child_frame: "pose_estimator_base_link"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<arg name="input_geo_pose" default="/geo_pose_with_covariance"/>
<arg name="output_pose" default="/pose_with_covariance"/>
<arg name="param_path" default="$(find-pkg-share geo_pose_projector)/config/geo_pose_projector.param.yaml"/>

<node pkg="geo_pose_projector" exec="geo_pose_projector" name="geo_pose_projector" output="screen">
<remap from="input_geo_pose" to="$(var input_geo_pose)"/>
<remap from="output_pose" to="$(var output_pose)"/>

<param from="$(var param_path)"/>
</node>
</launch>
30 changes: 30 additions & 0 deletions localization/geo_pose_projector/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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>geo_pose_projector</name>
<version>0.1.0</version>
<description>The geo_pose_projector package</description>
<maintainer email="[email protected]">Yamato Ando</maintainer>
<maintainer email="[email protected]">Koji Minoda</maintainer>
<license>Apache License 2.0</license>
<author email="[email protected]">Koji Minoda</author>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>component_interface_specs</depend>
<depend>component_interface_utils</depend>
<depend>geographic_msgs</depend>
<depend>geography_utils</depend>
<depend>geometry_msgs</depend>
<depend>rclcpp</depend>
<depend>tf2_geometry_msgs</depend>
<depend>tf2_ros</depend>

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

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Parameters for geo_pose_projector",
"type": "object",
"definitions": {
"geo_pose_projector": {
"type": "object",
"properties": {
"publish_tf": {
"type": "boolean",
"description": "whether to publish tf",
"default": true
},
"parent_frame": {
"type": "string",
"description": "parent frame for published tf",
"default": "map"
},
"child_frame": {
"type": "string",
"description": "child frame for published tf",
"default": "pose_estimator_base_link"
}
},
"required": ["publish_tf", "parent_frame", "child_frame"],
"additionalProperties": false
}
},
"properties": {
"/**": {
"type": "object",
"properties": {
"ros__parameters": {
"$ref": "#/definitions/geo_pose_projector"
}
},
"required": ["ros__parameters"],
"additionalProperties": false
}
},
"required": ["/**"],
"additionalProperties": false
}
103 changes: 103 additions & 0 deletions localization/geo_pose_projector/src/geo_pose_projector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright 2023 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 "geo_pose_projector.hpp"

#include <geography_utils/height.hpp>
#include <geography_utils/projection.hpp>

#ifdef ROS_DISTRO_GALACTIC
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#else
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
#endif

#include <string>

GeoPoseProjector::GeoPoseProjector()
: Node("geo_pose_projector"), publish_tf_(declare_parameter<bool>("publish_tf"))

Check warning on line 29 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L28-L29

Added lines #L28 - L29 were not covered by tests
{
// Subscribe to map_projector_info topic
const auto adaptor = component_interface_utils::NodeAdaptor(this);
adaptor.init_sub(

Check warning on line 33 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L32-L33

Added lines #L32 - L33 were not covered by tests
sub_map_projector_info_,
[this](const MapProjectorInfo::Message::ConstSharedPtr msg) { projector_info_ = *msg; });

Check warning on line 35 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L35

Added line #L35 was not covered by tests

// Subscribe to geo_pose topic
geo_pose_sub_ = create_subscription<GeoPoseWithCovariance>(
"input_geo_pose", 10, [this](const GeoPoseWithCovariance::SharedPtr msg) { on_geo_pose(msg); });

Check warning on line 39 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L38-L39

Added lines #L38 - L39 were not covered by tests

// Publish pose topic
pose_pub_ = create_publisher<PoseWithCovariance>("output_pose", 10);

Check warning on line 42 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L42

Added line #L42 was not covered by tests

// Publish tf
if (publish_tf_) {
tf_broadcaster_ = std::make_unique<tf2_ros::TransformBroadcaster>(this);
parent_frame_ = declare_parameter<std::string>("parent_frame");
child_frame_ = declare_parameter<std::string>("child_frame");

Check warning on line 48 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L45-L48

Added lines #L45 - L48 were not covered by tests
}
}

Check warning on line 50 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L50

Added line #L50 was not covered by tests

void GeoPoseProjector::on_geo_pose(const GeoPoseWithCovariance::SharedPtr msg)

Check warning on line 52 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L52

Added line #L52 was not covered by tests
{
if (!projector_info_) {
RCLCPP_WARN_THROTTLE(

Check warning on line 55 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L54-L55

Added lines #L54 - L55 were not covered by tests
get_logger(), *get_clock(), 1000 /* ms */, "map_projector_info is not received yet.");
return;

Check warning on line 57 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L57

Added line #L57 was not covered by tests
}

// get position
geographic_msgs::msg::GeoPoint gps_point;
gps_point.latitude = msg->pose.pose.position.latitude;
gps_point.longitude = msg->pose.pose.position.longitude;
gps_point.altitude = msg->pose.pose.position.altitude;

Check warning on line 64 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L62-L64

Added lines #L62 - L64 were not covered by tests
geometry_msgs::msg::Point position =
geography_utils::project_forward(gps_point, projector_info_.value());
position.z = geography_utils::convert_height(

Check warning on line 67 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L66-L67

Added lines #L66 - L67 were not covered by tests
position.z, gps_point.latitude, gps_point.longitude, MapProjectorInfo::Message::WGS84,
projector_info_.value().vertical_datum);

Check warning on line 69 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L69

Added line #L69 was not covered by tests

// Convert geo_pose to pose
PoseWithCovariance projected_pose;
projected_pose.header = msg->header;
projected_pose.pose.pose.position = position;
projected_pose.pose.pose.orientation = msg->pose.pose.orientation;
projected_pose.pose.covariance = msg->pose.covariance;

Check warning on line 76 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L74-L76

Added lines #L74 - L76 were not covered by tests

// Covariance in GeoPoseWithCovariance is in Lat/Lon/Alt coordinate.
// TODO(TIER IV): This swap may be invalid when using other projector type.
projected_pose.pose.covariance[0] = msg->pose.covariance[7];
projected_pose.pose.covariance[7] = msg->pose.covariance[0];

Check warning on line 81 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L80-L81

Added lines #L80 - L81 were not covered by tests

pose_pub_->publish(projected_pose);

Check warning on line 83 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L83

Added line #L83 was not covered by tests

// Publish tf
if (publish_tf_) {

Check warning on line 86 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L86

Added line #L86 was not covered by tests
tf2::Transform transform;
transform.setOrigin(tf2::Vector3(
projected_pose.pose.pose.position.x, projected_pose.pose.pose.position.y,
projected_pose.pose.pose.position.z));
const auto localization_quat = tf2::Quaternion(
projected_pose.pose.pose.orientation.x, projected_pose.pose.pose.orientation.y,
projected_pose.pose.pose.orientation.z, projected_pose.pose.pose.orientation.w);
transform.setRotation(localization_quat);

geometry_msgs::msg::TransformStamped transform_stamped;

Check warning on line 96 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L96

Added line #L96 was not covered by tests
transform_stamped.header = msg->header;
transform_stamped.header.frame_id = parent_frame_;
transform_stamped.child_frame_id = child_frame_;
transform_stamped.transform = tf2::toMsg(transform);
tf_broadcaster_->sendTransform(transform_stamped);
}

Check warning on line 102 in localization/geo_pose_projector/src/geo_pose_projector.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector.cpp#L98-L102

Added lines #L98 - L102 were not covered by tests
}
58 changes: 58 additions & 0 deletions localization/geo_pose_projector/src/geo_pose_projector.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2023 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 GEO_POSE_PROJECTOR_HPP_
#define GEO_POSE_PROJECTOR_HPP_

#include <component_interface_specs/map.hpp>
#include <component_interface_utils/rclcpp.hpp>
#include <rclcpp/rclcpp.hpp>

#include <geographic_msgs/msg/geo_pose_with_covariance_stamped.hpp>
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>

#include <tf2_ros/transform_broadcaster.h>

#include <memory>
#include <optional>
#include <string>

class GeoPoseProjector : public rclcpp::Node
{
private:
using GeoPoseWithCovariance = geographic_msgs::msg::GeoPoseWithCovarianceStamped;
using PoseWithCovariance = geometry_msgs::msg::PoseWithCovarianceStamped;
using MapProjectorInfo = map_interface::MapProjectorInfo;

public:
GeoPoseProjector();

private:
void on_geo_pose(const GeoPoseWithCovariance::SharedPtr msg);

component_interface_utils::Subscription<MapProjectorInfo>::SharedPtr sub_map_projector_info_;
rclcpp::Subscription<GeoPoseWithCovariance>::SharedPtr geo_pose_sub_;
rclcpp::Publisher<PoseWithCovariance>::SharedPtr pose_pub_;

std::unique_ptr<tf2_ros::TransformBroadcaster> tf_broadcaster_;

std::optional<MapProjectorInfo::Message> projector_info_ = std::nullopt;

const bool publish_tf_;

std::string parent_frame_;
std::string child_frame_;
};

#endif // GEO_POSE_PROJECTOR_HPP_
29 changes: 29 additions & 0 deletions localization/geo_pose_projector/src/geo_pose_projector_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023 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 "geo_pose_projector.hpp"

#include <rclcpp/rclcpp.hpp>

#include <memory>

int main(int argc, char ** argv)

Check warning on line 21 in localization/geo_pose_projector/src/geo_pose_projector_node.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector_node.cpp#L21

Added line #L21 was not covered by tests
{
rclcpp::init(argc, argv);

Check warning on line 23 in localization/geo_pose_projector/src/geo_pose_projector_node.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector_node.cpp#L23

Added line #L23 was not covered by tests

rclcpp::spin(std::make_shared<GeoPoseProjector>());
rclcpp::shutdown();

Check warning on line 26 in localization/geo_pose_projector/src/geo_pose_projector_node.cpp

View check run for this annotation

Codecov / codecov/patch

localization/geo_pose_projector/src/geo_pose_projector_node.cpp#L25-L26

Added lines #L25 - L26 were not covered by tests

return 0;
}
Loading