-
Notifications
You must be signed in to change notification settings - Fork 691
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 imu_corrector package #28
Merged
taikitanaka3
merged 11 commits into
autowarefoundation:tier4/proposal
from
1222-takeshi:1-add-imu-package
Dec 6, 2021
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e5c38d4
Feature/imu corrector (#1587)
YamatoAndo 4db03fd
imu corrector param units and link (#1791)
YamatoAndo 615c792
Fix -Wunused-parameter (#1836)
kenji-miyake d34ca70
Change formatter to clang-format and black (#2332)
kenji-miyake ed877e5
Add COLCON_IGNORE (#500)
kenji-miyake 9eb6656
remove COLCON_IGNORE (#515)
satoshi-ota 6c76585
Remove template comments from node documents (#608)
satoshi-ota 6db92ac
Merge branch 'tier4/proposal' into 1-add-imu-package
taikitanaka3 bd778d5
Merge branch 'tier4/proposal' into 1-add-imu-package
1222-takeshi 8bf0f34
Merge branch 'tier4/proposal' into 1-add-imu-package
tkimura4 106b30a
Merge branch 'tier4/proposal' into 1-add-imu-package
taikitanaka3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(imu_corrector) | ||
|
||
### 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() | ||
|
||
find_package(ament_cmake_auto REQUIRED) | ||
ament_auto_find_build_dependencies() | ||
|
||
ament_auto_add_library(imu_corrector_node SHARED | ||
src/imu_corrector_core.cpp | ||
include/imu_corrector/imu_corrector_core.hpp | ||
) | ||
|
||
rclcpp_components_register_node(imu_corrector_node | ||
PLUGIN "imu_corrector::ImuCorrector" | ||
EXECUTABLE imu_corrector | ||
) | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_auto_package(INSTALL_TO_SHARE | ||
launch | ||
config | ||
) |
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,43 @@ | ||
# imu_corrector | ||
|
||
## Purpose | ||
|
||
`imu_corrector_node` is a node that correct imu data. | ||
|
||
1. Correct yaw rate offset by reading the parameter. | ||
2. Correct yaw rate standard deviation by reading the parameter. | ||
|
||
Use the value estimated by [deviation_estimator](https://github.com/tier4/calibration_tools/tree/main/localization/deviation_estimation_tools) as the parameters for this node. | ||
|
||
## Inputs / Outputs | ||
|
||
### Input | ||
|
||
| Name | Type | Description | | ||
| -------- | ----------------------- | ------------ | | ||
| `~input` | `sensor_msgs::msg::Imu` | raw imu data | | ||
|
||
### Output | ||
|
||
| Name | Type | Description | | ||
| --------- | ----------------------- | ------------------ | | ||
| `~output` | `sensor_msgs::msg::Imu` | corrected imu data | | ||
|
||
## Parameters | ||
|
||
### Core Parameters | ||
|
||
| Name | Type | Description | | ||
| ---------------------------- | ------ | ----------------------------------- | | ||
| `angular_velocity_offset_z` | double | yaw rate offset [rad/s] | | ||
| `angular_velocity_stddev_zz` | double | yaw rate standard deviation [rad/s] | | ||
|
||
## Assumptions / Known limits | ||
|
||
## (Optional) Error detection and handling | ||
|
||
## (Optional) Performance characterization | ||
|
||
## (Optional) References/External links | ||
|
||
## (Optional) Future extensions / Unimplemented parts |
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,4 @@ | ||
/**: | ||
ros__parameters: | ||
angular_velocity_offset_z: 0.0 # [rad/s] | ||
angular_velocity_stddev_zz: 0.03 # [rad/s] |
41 changes: 41 additions & 0 deletions
41
sensing/imu_corrector/include/imu_corrector/imu_corrector_core.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,41 @@ | ||
// 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. | ||
#ifndef IMU_CORRECTOR__IMU_CORRECTOR_CORE_HPP_ | ||
#define IMU_CORRECTOR__IMU_CORRECTOR_CORE_HPP_ | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <sensor_msgs/msg/imu.hpp> | ||
|
||
namespace imu_corrector | ||
{ | ||
class ImuCorrector : public rclcpp::Node | ||
{ | ||
public: | ||
explicit ImuCorrector(const rclcpp::NodeOptions & node_options); | ||
|
||
private: | ||
void callbackImu(const sensor_msgs::msg::Imu::ConstSharedPtr imu_msg_ptr); | ||
|
||
rclcpp::Subscription<sensor_msgs::msg::Imu>::SharedPtr imu_sub_; | ||
|
||
rclcpp::Publisher<sensor_msgs::msg::Imu>::SharedPtr imu_pub_; | ||
|
||
double angular_velocity_offset_z_; | ||
|
||
double angular_velocity_stddev_zz_; | ||
}; | ||
} // namespace imu_corrector | ||
|
||
#endif // IMU_CORRECTOR__IMU_CORRECTOR_CORE_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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<launch> | ||
|
||
<arg name="input_topic" default="imu_raw" /> | ||
<arg name="output_topic" default="imu_data" /> | ||
<arg name="param_file" default="$(find-pkg-share imu_corrector)/config/imu_corrector.param.yaml" /> | ||
|
||
<node pkg="imu_corrector" exec="imu_corrector" name="imu_corrector" output="screen"> | ||
<remap from="input" to="$(var input_topic)" /> | ||
<remap from="output" to="$(var output_topic)" /> | ||
<param from="$(var param_file)" /> | ||
</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,22 @@ | ||
<?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>imu_corrector</name> | ||
<version>1.0.0</version> | ||
<description>The ROS2 imu_corrector package</description> | ||
<maintainer email="yamato.ando@gmail.com">Yamato Ando</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
|
||
<depend>rclcpp</depend> | ||
<depend>rclcpp_components</depend> | ||
<depend>sensor_msgs</depend> | ||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>autoware_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
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,48 @@ | ||
// 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 "imu_corrector/imu_corrector_core.hpp" | ||
|
||
namespace imu_corrector | ||
{ | ||
ImuCorrector::ImuCorrector(const rclcpp::NodeOptions & node_options) | ||
: Node("imu_corrector", node_options) | ||
{ | ||
angular_velocity_offset_z_ = declare_parameter<double>("angular_velocity_offset_z", 0.0); | ||
|
||
angular_velocity_stddev_zz_ = declare_parameter<double>("angular_velocity_stddev_zz", 0.03); | ||
|
||
imu_sub_ = create_subscription<sensor_msgs::msg::Imu>( | ||
"input", rclcpp::QoS{1}, std::bind(&ImuCorrector::callbackImu, this, std::placeholders::_1)); | ||
|
||
imu_pub_ = create_publisher<sensor_msgs::msg::Imu>("output", rclcpp::QoS{10}); | ||
} | ||
|
||
void ImuCorrector::callbackImu(const sensor_msgs::msg::Imu::ConstSharedPtr imu_msg_ptr) | ||
{ | ||
sensor_msgs::msg::Imu imu_msg; | ||
imu_msg = *imu_msg_ptr; | ||
|
||
imu_msg.angular_velocity.z += angular_velocity_offset_z_; | ||
|
||
imu_msg.angular_velocity_covariance[8] = | ||
angular_velocity_stddev_zz_ * angular_velocity_stddev_zz_; | ||
|
||
imu_pub_->publish(imu_msg); | ||
} | ||
|
||
} // namespace imu_corrector | ||
|
||
#include <rclcpp_components/register_node_macro.hpp> | ||
RCLCPP_COMPONENTS_REGISTER_NODE(imu_corrector::ImuCorrector) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
change URL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkimura4
Oh, this URL repository is private.
I think I can delete the URL, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK!