Skip to content

Commit

Permalink
style(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jan 17, 2025
1 parent f915dd8 commit 505f558
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 38 deletions.
2 changes: 1 addition & 1 deletion build_depends.repos
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ repositories:
autoware_internal_msgs:
type: git
url: https://github.com/autowarefoundation/autoware_internal_msgs.git
version: main
version: main
28 changes: 14 additions & 14 deletions sensing/autoware_gnss_poser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ If the transformation from `base_link` to the antenna cannot be obtained, it out

| Name | Type | Description |
| ------------------------------ | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `/map/map_projector_info` | `autoware_map_msgs::msg::MapProjectorInfo` | map projection info |
| `/map/map_projector_info` | `autoware_map_msgs::msg::MapProjectorInfo` | map projection info |
| `~/input/fix` | `sensor_msgs::msg::NavSatFix` | gnss status message |
| `~/input/autoware_orientation` | `autoware_sensing_msgs::msg::GnssInsOrientationStamped` | orientation [click here for more details](https://github.com/autowarefoundation/autoware_msgs/tree/main/autoware_sensing_msgs) |

### Output

| Name | Type | Description |
| ------------------------ | ----------------------------------------------- | -------------------------------------------------------------- |
| `~/output/pose` | `geometry_msgs::msg::PoseStamped` | vehicle pose calculated from gnss sensing data |
| `~/output/gnss_pose_cov` | `geometry_msgs::msg::PoseWithCovarianceStamped` | vehicle pose with covariance calculated from gnss sensing data |
| `~/output/gnss_fixed` | `autoware_internal_debug_msgs::msg::BoolStamped` | gnss fix status |
| Name | Type | Description |
| ------------------------ | ------------------------------------------------ | -------------------------------------------------------------- |
| `~/output/pose` | `geometry_msgs::msg::PoseStamped` | vehicle pose calculated from gnss sensing data |
| `~/output/gnss_pose_cov` | `geometry_msgs::msg::PoseWithCovarianceStamped` | vehicle pose with covariance calculated from gnss sensing data |
| `~/output/gnss_fixed` | `autoware_internal_debug_msgs::msg::BoolStamped` | gnss fix status |

## Parameters

Parameters in below table

| Name | Type | Default | Description |
| ------------------------ | -----------------------| ------------------------ | -------------------------------------------------------------- |
| `base_frame` | `string` | `base_link` | frame id for base_frame |
| `gnss_base_frame` | `string` | `gnss_base_link` | frame id for gnss_base_frame |
| `map_frame` | `string` | `map` | frame id for map_frame |
| `use_gnss_ins_orientation` | `boolean` | `true` | use Gnss-Ins orientation |
| `gnss_pose_pub_method` | `integer` | `0` | 0: Instant Value 1: Average Value 2: Median Value. If `buffer_epoch` is set to 0, `gnss_pose_pub_method` loses affect. Range: 0~2. |
| `buff_epoch` | `integer` | `1` | Buffer epoch. Range: 0~inf. |
| Name | Type | Default | Description |
| -------------------------- | --------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `base_frame` | `string` | `base_link` | frame id for base_frame |
| `gnss_base_frame` | `string` | `gnss_base_link` | frame id for gnss_base_frame |
| `map_frame` | `string` | `map` | frame id for map_frame |
| `use_gnss_ins_orientation` | `boolean` | `true` | use Gnss-Ins orientation |
| `gnss_pose_pub_method` | `integer` | `0` | 0: Instant Value 1: Average Value 2: Median Value. If `buffer_epoch` is set to 0, `gnss_pose_pub_method` loses affect. Range: 0~2. |
| `buff_epoch` | `integer` | `1` | Buffer epoch. Range: 0~inf. |

All above parameters can be changed in config file [gnss_poser.param.yaml](./config/gnss_poser.param.yaml "Click here to open config file") .
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#ifndef AUTOWARE__GNSS_POSER__GNSS_POSER_NODE_HPP_
#define AUTOWARE__GNSS_POSER__GNSS_POSER_NODE_HPP_

#include <autoware_map_msgs/msg/map_projector_info.hpp>
#include <rclcpp/rclcpp.hpp>

#include <autoware_internal_debug_msgs/msg/bool_stamped.hpp>
#include <autoware_map_msgs/msg/map_projector_info.hpp>
#include <autoware_sensing_msgs/msg/gnss_ins_orientation_stamped.hpp>
#include <geometry_msgs/msg/pose_stamped.hpp>
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
#include <sensor_msgs/msg/nav_sat_fix.hpp>
#include <autoware_internal_debug_msgs/msg/bool_stamped.hpp>

#include <boost/circular_buffer.hpp>

Expand All @@ -46,7 +46,8 @@ class GNSSPoser : public rclcpp::Node
explicit GNSSPoser(const rclcpp::NodeOptions & node_options);

private:
void callback_map_projector_info(const autoware_map_msgs::msg::MapProjectorInfo::ConstSharedPtr msg);
void callback_map_projector_info(
const autoware_map_msgs::msg::MapProjectorInfo::ConstSharedPtr msg);
void callback_nav_sat_fix(const sensor_msgs::msg::NavSatFix::ConstSharedPtr nav_sat_fix_msg_ptr);
void callback_gnss_ins_orientation_stamped(
const autoware_sensing_msgs::msg::GnssInsOrientationStamped::ConstSharedPtr msg);
Expand Down
4 changes: 2 additions & 2 deletions sensing/autoware_gnss_poser/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

<build_depend>libboost-dev</build_depend>

<depend>autoware_map_msgs</depend>
<depend>autoware_geography_utils</depend>
<depend>autoware_internal_debug_msgs</depend>
<depend>autoware_map_msgs</depend>
<depend>autoware_sensing_msgs</depend>
<depend>geographic_msgs</depend>
<depend>geographiclib</depend>
Expand All @@ -32,7 +33,6 @@
<depend>tf2</depend>
<depend>tf2_geometry_msgs</depend>
<depend>tf2_ros</depend>
<depend>autoware_internal_debug_msgs</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>
Expand Down
10 changes: 6 additions & 4 deletions sensing/autoware_gnss_poser/src/gnss_poser_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ GNSSPoser::GNSSPoser(const rclcpp::NodeOptions & node_options)
pose_pub_ = create_publisher<geometry_msgs::msg::PoseStamped>("gnss_pose", rclcpp::QoS{1});
pose_cov_pub_ = create_publisher<geometry_msgs::msg::PoseWithCovarianceStamped>(
"gnss_pose_cov", rclcpp::QoS{1});
fixed_pub_ = create_publisher<autoware_internal_debug_msgs::msg::BoolStamped>("gnss_fixed", rclcpp::QoS{1});
fixed_pub_ =
create_publisher<autoware_internal_debug_msgs::msg::BoolStamped>("gnss_fixed", rclcpp::QoS{1});

// Set msg_gnss_ins_orientation_stamped_ with temporary values (not to publish zero value
// covariances)
Expand All @@ -68,7 +69,8 @@ GNSSPoser::GNSSPoser(const rclcpp::NodeOptions & node_options)
msg_gnss_ins_orientation_stamped_->orientation.rmse_rotation_z = 1.0;
}

void GNSSPoser::callback_map_projector_info(const autoware_map_msgs::msg::MapProjectorInfo::ConstSharedPtr msg)
void GNSSPoser::callback_map_projector_info(

Check warning on line 72 in sensing/autoware_gnss_poser/src/gnss_poser_node.cpp

View check run for this annotation

Codecov / codecov/patch

sensing/autoware_gnss_poser/src/gnss_poser_node.cpp#L72

Added line #L72 was not covered by tests
const autoware_map_msgs::msg::MapProjectorInfo::ConstSharedPtr msg)
{
projector_info_ = *msg;
received_map_projector_info_ = true;
Expand Down Expand Up @@ -117,8 +119,8 @@ void GNSSPoser::callback_nav_sat_fix(
geometry_msgs::msg::Point position =
autoware::geography_utils::project_forward(gps_point, projector_info_);

Check warning on line 120 in sensing/autoware_gnss_poser/src/gnss_poser_node.cpp

View check run for this annotation

Codecov / codecov/patch

sensing/autoware_gnss_poser/src/gnss_poser_node.cpp#L120

Added line #L120 was not covered by tests
position.z = autoware::geography_utils::convert_height(
position.z, gps_point.latitude, gps_point.longitude, autoware_map_msgs::msg::MapProjectorInfo::WGS84,
projector_info_.vertical_datum);
position.z, gps_point.latitude, gps_point.longitude,
autoware_map_msgs::msg::MapProjectorInfo::WGS84, projector_info_.vertical_datum);

Check warning on line 123 in sensing/autoware_gnss_poser/src/gnss_poser_node.cpp

View check run for this annotation

Codecov / codecov/patch

sensing/autoware_gnss_poser/src/gnss_poser_node.cpp#L123

Added line #L123 was not covered by tests

geometry_msgs::msg::Pose gnss_antenna_pose{};

Expand Down
47 changes: 33 additions & 14 deletions sensing/autoware_gnss_poser/test/test_gnss_poser_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gtest/gtest.h>
#include <rclcpp/rclcpp.hpp>

#include <gtest/gtest.h>

#include <memory>
#include <vector>

Expand Down Expand Up @@ -67,9 +69,15 @@ TEST_F(GNSSPoserTest, GetMedianPositionTest)
{
boost::circular_buffer<geometry_msgs::msg::Point> buffer(3);
geometry_msgs::msg::Point p1, p2, p3;
p1.x = 1.0; p1.y = 2.0; p1.z = 3.0;
p2.x = 4.0; p2.y = 5.0; p2.z = 6.0;
p3.x = 7.0; p3.y = 8.0; p3.z = 9.0;
p1.x = 1.0;
p1.y = 2.0;
p1.z = 3.0;
p2.x = 4.0;
p2.y = 5.0;
p2.z = 6.0;
p3.x = 7.0;
p3.y = 8.0;
p3.z = 9.0;

buffer.push_back(p1);
buffer.push_back(p2);
Expand All @@ -86,9 +94,15 @@ TEST_F(GNSSPoserTest, GetAveragePositionTest)
{
boost::circular_buffer<geometry_msgs::msg::Point> buffer(3);
geometry_msgs::msg::Point p1, p2, p3;
p1.x = 1.0; p1.y = 2.0; p1.z = 3.0;
p2.x = 4.0; p2.y = 5.0; p2.z = 6.0;
p3.x = 7.0; p3.y = 8.0; p3.z = 9.0;
p1.x = 1.0;
p1.y = 2.0;
p1.z = 3.0;
p2.x = 4.0;
p2.y = 5.0;
p2.z = 6.0;
p3.x = 7.0;
p3.y = 8.0;
p3.z = 9.0;

buffer.push_back(p1);
buffer.push_back(p2);
Expand All @@ -104,21 +118,26 @@ TEST_F(GNSSPoserTest, GetAveragePositionTest)
TEST_F(GNSSPoserTest, GetQuaternionByPositionDifferenceTest)
{
geometry_msgs::msg::Point point, prev_point;
point.x = 1.0; point.y = 1.0; point.z = 0.0;
prev_point.x = 0.0; prev_point.y = 0.0; prev_point.z = 0.0;

geometry_msgs::msg::Quaternion orientation = autoware::gnss_poser::GNSSPoser::get_quaternion_by_position_difference(point, prev_point);
point.x = 1.0;
point.y = 1.0;
point.z = 0.0;
prev_point.x = 0.0;
prev_point.y = 0.0;
prev_point.z = 0.0;

geometry_msgs::msg::Quaternion orientation =
autoware::gnss_poser::GNSSPoser::get_quaternion_by_position_difference(point, prev_point);
tf2::Quaternion tf_orientation;
tf2::fromMsg(orientation, tf_orientation);

EXPECT_DOUBLE_EQ(tf_orientation.getAngle(), M_PI_4); // 45 degrees in radians
EXPECT_DOUBLE_EQ(tf_orientation.getAngle(), M_PI_4); // 45 degrees in radians
}

int main(int argc, char **argv)
int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);
::testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
rclcpp::shutdown();
return result;
}
}

0 comments on commit 505f558

Please sign in to comment.