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 twist_estimator packages #57

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b72ff63
release v0.4.0
mitsudome-r Sep 18, 2020
4f0179a
Avoid setting CMAKE_BUILD_TYPE=Release in each CMakeLists.txt (#720)
harihitode Aug 2, 2020
779a391
remove ROS1 packages temporarily
mitsudome-r Sep 29, 2020
17121dd
Revert "remove ROS1 packages temporarily"
mitsudome-r Oct 8, 2020
cf6c33f
add COLCON_IGNORE to ros1 packages
mitsudome-r Oct 8, 2020
0bf2127
Rename launch files to launch.xml (#28)
nnmm Oct 15, 2020
69fdf87
ROS2 Porting: gyro_odometer (#39)
jilaada Oct 20, 2020
496a353
ported pose2twist from ROS1 to ROS2 (#19)
nik-tier4 Oct 21, 2020
f82043e
Add geometry2 to repos (#76)
mitsudome-r Nov 2, 2020
3b752fa
Revert "Add geometry2 to repos (#76)" (#96)
nnmm Nov 16, 2020
4c683b4
Rename h files to hpp (#142)
nnmm Dec 3, 2020
c5d60f6
Adjust copyright notice on 532 out of 699 source files (#143)
nnmm Dec 3, 2020
1095652
Use quotes for includes where appropriate (#144)
nnmm Dec 7, 2020
61cf44a
Run uncrustify on the entire Pilot.Auto codebase (#151)
nnmm Dec 8, 2020
6214653
adding linters to pose2twist (#193)
nik-tier4 Dec 14, 2020
92ccb83
adding linters to gyro_odometer (#192)
nik-tier4 Dec 14, 2020
8e5db1c
apply env_var to use_sim_time (#222)
k0suke-murakami Dec 23, 2020
11245c7
Fix dt in pose2twist (#289)
k0suke-murakami Jan 22, 2021
8c35b07
fix covariance (#875) (#267)
wep21 Jan 17, 2021
00204ca
rm std_msgs (#359)
taikitanaka3 Feb 25, 2021
0faafd6
rm_std_msgs (#402)
taikitanaka3 Mar 5, 2021
37bed8f
Fix rolling build errors (#1225)
kenji-miyake Apr 5, 2021
ab9d0ad
Sync public repo (#1228)
mitsudome-r Apr 5, 2021
f612e42
Fix for rolling (#1226)
kenji-miyake Apr 8, 2021
8741612
Unify Apache-2.0 license name (#1242)
kmiya Apr 15, 2021
a06c694
Remove use_sim_time for set_parameter (#1260)
wep21 Apr 26, 2021
8fecf0c
Feature/gyro odometer add twist with cov input (#1586)
YamatoAndo Jul 26, 2021
87c7eac
add description for gyro_odometer package #1819
h-ohta Aug 12, 2021
9eff52c
Fix -Wunused-parameter (#1836)
kenji-miyake Aug 14, 2021
da6525e
Invoke code formatter at pre-commit (#1935)
IshitaTakeshi Sep 1, 2021
dcdbedd
Feature/add stop filter ros2 (#1575)
kminoda Sep 2, 2021
cb56df5
revert imu yaw bias (#2040) (#2043)
tier4-autoware-private-bot[bot] Sep 7, 2021
0a520dc
add sort-package-xml hook in pre-commit (#1881)
KeisukeShima Sep 9, 2021
e236761
Change formatter to clang-format and black (#2332)
kenji-miyake Nov 2, 2021
bac2271
Add COLCON_IGNORE (#500)
kenji-miyake Nov 4, 2021
b607039
Remove COLCON_IGNORE under localization (#553)
IshitaTakeshi Nov 9, 2021
2b61ef6
[gyro_odometer]add readme (#625)
kyoichi-sugahara Nov 16, 2021
fb952dc
add readme in pose2twist (#662)
TakaHoribe Nov 16, 2021
a3c9c80
fix readme (#669)
TakaHoribe Nov 17, 2021
7662061
convert VehicleReport to Twist msgs (#657)
RyuYamamoto Nov 18, 2021
979a8b6
[gyro_odometer] remove input twist (#706)
RyuYamamoto Nov 24, 2021
ff6ccfc
fix: move README.md directory
1222-takeshi Dec 1, 2021
f4a7abd
Merge branch 'tier4/proposal' into 1-add-twist-estimator-packages
1222-takeshi Dec 2, 2021
f7f2b87
Merge branch 'tier4/proposal' into 1-add-twist-estimator-packages
tkimura4 Dec 3, 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
35 changes: 35 additions & 0 deletions localization/gyro_odometer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.5)
project(gyro_odometer)

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()

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

set(GYRO_ODOMETER_SRC
src/gyro_odometer_core.cpp)

set(GYRO_ODOMETER_HEADERS
include/gyro_odometer/gyro_odometer_core.hpp)

ament_auto_add_executable(${PROJECT_NAME}
src/gyro_odometer_node.cpp
${GYRO_ODOMETER_SRC}
${GYRO_ODOMETER_HEADERS}
)

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

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

## Purpose

`gyro_odometer` is the package to estimate twist by combining imu and vehicle speed.

## Inputs / Outputs

### Input

| Name | Type | Description |
| ------------------------------- | ------------------------------------------------ | ---------------------------------- |
| `vehicle/twist_with_covariance` | `geometry_msgs::msg::TwistWithCovarianceStamped` | twist with covariance from vehicle |
| `imu` | `sensor_msgs::msg::Imu` | imu from sensor |

### Output

| Name | Type | Description |
| ----------------------- | ------------------------------------------------ | ------------------------------- |
| `twist` | `geometry_msgs::msg::TwistStamped` | estimated twist |
| `twist_with_covariance` | `geometry_msgs::msg::TwistWithCovarianceStamped` | estimated twist with covariance |

## Parameters

| Parameter | Type | Description |
| -------------- | ------ | ----------------- |
| `output_frame` | String | output's frame id |

## Assumptions / Known limits

TBD.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2015-2019 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 GYRO_ODOMETER__GYRO_ODOMETER_CORE_HPP_
#define GYRO_ODOMETER__GYRO_ODOMETER_CORE_HPP_

#include <rclcpp/rclcpp.hpp>

#include <geometry_msgs/msg/twist_stamped.hpp>
#include <geometry_msgs/msg/twist_with_covariance_stamped.hpp>
#include <sensor_msgs/msg/imu.hpp>

#include <tf2/transform_datatypes.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_listener.h>

#include <string>

class GyroOdometer : public rclcpp::Node
{
public:
GyroOdometer();
~GyroOdometer();

private:
void callbackTwistWithCovariance(
const geometry_msgs::msg::TwistWithCovarianceStamped::ConstSharedPtr twist_with_cov_msg_ptr);
void callbackImu(const sensor_msgs::msg::Imu::ConstSharedPtr imu_msg_ptr);
bool getTransform(
const std::string & target_frame, const std::string & source_frame,
const geometry_msgs::msg::TransformStamped::SharedPtr transform_stamped_ptr);

rclcpp::Subscription<geometry_msgs::msg::TwistWithCovarianceStamped>::SharedPtr
vehicle_twist_with_cov_sub_;
rclcpp::Subscription<sensor_msgs::msg::Imu>::SharedPtr imu_sub_;

rclcpp::Publisher<geometry_msgs::msg::TwistStamped>::SharedPtr twist_pub_;
rclcpp::Publisher<geometry_msgs::msg::TwistWithCovarianceStamped>::SharedPtr
twist_with_covariance_pub_;

tf2_ros::Buffer tf_buffer_;
tf2_ros::TransformListener tf_listener_;

std::string output_frame_;
geometry_msgs::msg::TwistWithCovarianceStamped::ConstSharedPtr twist_with_cov_msg_ptr_;
};

#endif // GYRO_ODOMETER__GYRO_ODOMETER_CORE_HPP_
22 changes: 22 additions & 0 deletions localization/gyro_odometer/launch/gyro_odometer.launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<launch>
<arg name="input_vehicle_twist_with_covariance_topic" default="/vehicle/status/twist_with_covariance" description="input twist with covariance topic name from vehicle"/>

<arg name="input_imu_topic" default="/sensing/imu/imu_data" description="input imu topic name" />

<arg name="output_twist_topic" default="gyro_twist" description="output twist topic name"/>
<arg name="output_twist_with_covariance_topic" default="gyro_twist_with_covariance" description="output twist with covariance topic name"/>

<arg name="output_frame" default="base_link" description="output frame id"/>

<node pkg="gyro_odometer" exec="gyro_odometer" name="gyro_odometer" output="screen">

<remap from="vehicle/twist_with_covariance" to="$(var input_vehicle_twist_with_covariance_topic)" />

<remap from="imu" to="$(var input_imu_topic)" />

<remap from="twist" to="$(var output_twist_topic)" />
<remap from="twist_with_covariance" to="$(var output_twist_with_covariance_topic)" />

<param name="output_frame" value="$(var output_frame)" />
</node>
</launch>
27 changes: 27 additions & 0 deletions localization/gyro_odometer/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>gyro_odometer</name>
<version>0.1.0</version>
<description>The gyro_odometer package as a ROS2 node</description>
<maintainer email="yamato.ando@gmail.com">Yamato Ando</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<depend>geometry_msgs</depend>
<depend>sensor_msgs</depend>
<depend>std_msgs</depend>
<depend>tf2</depend>
<depend>tf2_geometry_msgs</depend>
<depend>tf2_ros</depend>

<exec_depend>rclcpp</exec_depend>
<exec_depend>rclcpp_components</exec_depend>

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

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
145 changes: 145 additions & 0 deletions localization/gyro_odometer/src/gyro_odometer_core.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Copyright 2015-2019 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 "gyro_odometer/gyro_odometer_core.hpp"

#include <tf2_geometry_msgs/tf2_geometry_msgs.h>

#include <cmath>
#include <memory>
#include <string>

GyroOdometer::GyroOdometer()
: Node("gyro_odometer"),
tf_buffer_(this->get_clock()),
tf_listener_(tf_buffer_),
output_frame_(declare_parameter("base_link", "base_link"))
{
vehicle_twist_with_cov_sub_ = create_subscription<geometry_msgs::msg::TwistWithCovarianceStamped>(
"vehicle/twist_with_covariance", rclcpp::QoS{100},
std::bind(&GyroOdometer::callbackTwistWithCovariance, this, std::placeholders::_1));

imu_sub_ = create_subscription<sensor_msgs::msg::Imu>(
"imu", rclcpp::QoS{100}, std::bind(&GyroOdometer::callbackImu, this, std::placeholders::_1));

twist_pub_ = create_publisher<geometry_msgs::msg::TwistStamped>("twist", rclcpp::QoS{10});
twist_with_covariance_pub_ = create_publisher<geometry_msgs::msg::TwistWithCovarianceStamped>(
"twist_with_covariance", rclcpp::QoS{10});

// TODO(YamatoAndo) createTimer
}

GyroOdometer::~GyroOdometer() {}

void GyroOdometer::callbackTwistWithCovariance(
const geometry_msgs::msg::TwistWithCovarianceStamped::ConstSharedPtr twist_with_cov_msg_ptr)
{
// TODO(YamatoAndo) trans from twist_with_cov_msg_ptr->header to base_frame
twist_with_cov_msg_ptr_ = twist_with_cov_msg_ptr;
}

void GyroOdometer::callbackImu(const sensor_msgs::msg::Imu::ConstSharedPtr imu_msg_ptr)
{
if (!twist_with_cov_msg_ptr_) {
return;
}

geometry_msgs::msg::TransformStamped::SharedPtr tf_base2imu_ptr =
std::make_shared<geometry_msgs::msg::TransformStamped>();
getTransform(output_frame_, imu_msg_ptr->header.frame_id, tf_base2imu_ptr);

geometry_msgs::msg::Vector3Stamped angular_velocity;
angular_velocity.header = imu_msg_ptr->header;
angular_velocity.vector = imu_msg_ptr->angular_velocity;

geometry_msgs::msg::Vector3Stamped transformed_angular_velocity;
transformed_angular_velocity.header = tf_base2imu_ptr->header;

tf2::doTransform(angular_velocity, transformed_angular_velocity, *tf_base2imu_ptr);

// clear imu yaw bias if vehicle is stopped
if (
std::fabs(transformed_angular_velocity.vector.z) < 0.01 &&
std::fabs(twist_with_cov_msg_ptr_->twist.twist.linear.x) < 0.01) {
transformed_angular_velocity.vector.z = 0.0;
}

// TODO(YamatoAndo) move code
geometry_msgs::msg::TwistStamped twist;
twist.header.stamp = imu_msg_ptr->header.stamp;
twist.header.frame_id = output_frame_;
twist.twist.linear = twist_with_cov_msg_ptr_->twist.twist.linear;
twist.twist.angular.z = transformed_angular_velocity.vector.z; // TODO(YamatoAndo) yaw_rate only
twist_pub_->publish(twist);

geometry_msgs::msg::TwistWithCovarianceStamped twist_with_covariance;
twist_with_covariance.header.stamp = imu_msg_ptr->header.stamp;
twist_with_covariance.header.frame_id = output_frame_;
twist_with_covariance.twist.twist.linear = twist_with_cov_msg_ptr_->twist.twist.linear;
twist_with_covariance.twist.twist.angular.z =
transformed_angular_velocity.vector.z; // TODO(YamatoAndo) yaw_rate only

// NOTE
// linear.y, linear.z, angular.x, and angular.y are not measured values.
// Therefore, they should be assigned large variance values.
twist_with_covariance.twist.covariance[0] = twist_with_cov_msg_ptr_->twist.covariance[0];
twist_with_covariance.twist.covariance[7] = 10000.0;
twist_with_covariance.twist.covariance[14] = 10000.0;
twist_with_covariance.twist.covariance[21] = 10000.0;
twist_with_covariance.twist.covariance[28] = 10000.0;
twist_with_covariance.twist.covariance[35] = imu_msg_ptr->angular_velocity_covariance[8];

twist_with_covariance_pub_->publish(twist_with_covariance);
}

bool GyroOdometer::getTransform(
const std::string & target_frame, const std::string & source_frame,
const geometry_msgs::msg::TransformStamped::SharedPtr transform_stamped_ptr)
{
if (target_frame == source_frame) {
transform_stamped_ptr->header.stamp = this->get_clock()->now();
transform_stamped_ptr->header.frame_id = target_frame;
transform_stamped_ptr->child_frame_id = source_frame;
transform_stamped_ptr->transform.translation.x = 0.0;
transform_stamped_ptr->transform.translation.y = 0.0;
transform_stamped_ptr->transform.translation.z = 0.0;
transform_stamped_ptr->transform.rotation.x = 0.0;
transform_stamped_ptr->transform.rotation.y = 0.0;
transform_stamped_ptr->transform.rotation.z = 0.0;
transform_stamped_ptr->transform.rotation.w = 1.0;
return true;
}

try {
*transform_stamped_ptr =
tf_buffer_.lookupTransform(target_frame, source_frame, tf2::TimePointZero);
} catch (tf2::TransformException & ex) {
RCLCPP_WARN(this->get_logger(), "%s", ex.what());
RCLCPP_ERROR(
this->get_logger(), "Please publish TF %s to %s", target_frame.c_str(), source_frame.c_str());

transform_stamped_ptr->header.stamp = this->get_clock()->now();
transform_stamped_ptr->header.frame_id = target_frame;
transform_stamped_ptr->child_frame_id = source_frame;
transform_stamped_ptr->transform.translation.x = 0.0;
transform_stamped_ptr->transform.translation.y = 0.0;
transform_stamped_ptr->transform.translation.z = 0.0;
transform_stamped_ptr->transform.rotation.x = 0.0;
transform_stamped_ptr->transform.rotation.y = 0.0;
transform_stamped_ptr->transform.rotation.z = 0.0;
transform_stamped_ptr->transform.rotation.w = 1.0;
return false;
}
return true;
}
29 changes: 29 additions & 0 deletions localization/gyro_odometer/src/gyro_odometer_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2015-2019 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 "gyro_odometer/gyro_odometer_core.hpp"

#include <rclcpp/rclcpp.hpp>

#include <memory>

int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);
auto node = std::make_shared<GyroOdometer>();
rclcpp::spin(node);
rclcpp::shutdown();

return 0;
}
26 changes: 26 additions & 0 deletions localization/pose2twist/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.5)
project(pose2twist)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

ament_auto_add_executable(pose2twist
src/pose2twist_node.cpp
src/pose2twist_core.cpp
)

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

ament_auto_package(
INSTALL_TO_SHARE
launch
)
Loading