-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add GeoPoint Validation * Add ament_lint_common * Fix linter violations Signed-off-by: Ryan Friedman <[email protected]> * Downgrade CMake to 3.13, remove GNUInstallDirs, Add licenses Signed-off-by: Ryan Friedman <[email protected]> * Match upstream common_interfaces implementation Signed-off-by: Ryan Friedman <[email protected]> * Change case to match ROS convention Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Ryan Friedman <[email protected]> * Fix licensing problems * Only run the linters we need * Disable ament_copyright by not using ament_lint_common Signed-off-by: Ryan Friedman <[email protected]> --------- Signed-off-by: Ryan Friedman <[email protected]> Co-authored-by: Ryan Friedman <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
- Loading branch information
1 parent
1137998
commit 2a0ae99
Showing
8 changed files
with
161 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
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,5 @@ | ||
target_include_directories(validation | ||
INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> | ||
$<INSTALL_INTERFACE:include> | ||
) |
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,18 @@ | ||
// Copyright 2024 Ryan Friedman | ||
#pragma once | ||
#include <geographic_msgs/msg/geo_point.hpp> | ||
|
||
namespace geographic_msgs | ||
{ | ||
|
||
//! @brief Return whether a GeoPoint has latitude and longitude within expected bounds. | ||
[[nodiscard]] inline static bool horizontalPositionValid(const geographic_msgs::msg::GeoPoint point) | ||
{ | ||
auto const lat_valid = point.latitude <= 90.0 && point.latitude >= -90.0; | ||
auto const lng_valid = point.longitude <= 180.0 && point.longitude >= -180.0; | ||
|
||
return lat_valid && lng_valid; | ||
} | ||
|
||
|
||
} // namespace geographic_msgs |
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
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
</description> | ||
<maintainer email="[email protected]">Jack O'Quin</maintainer> | ||
<maintainer email="[email protected]">Steve Macenski</maintainer> | ||
<author>Jack O'Quin</author> | ||
<license>BSD</license> | ||
|
||
<url>http://wiki.ros.org/geographic_msgs</url> | ||
|
@@ -25,6 +24,20 @@ | |
<depend>std_msgs</depend> | ||
<depend>unique_identifier_msgs</depend> | ||
|
||
<test_depend>ament_cmake_gtest</test_depend> | ||
<test_depend>ament_lint_auto</test_depend> | ||
<!-- | ||
Skip using ament_lint_auto because ament_lint_copyright does not support "BSD" license. | ||
https://robotics.stackexchange.com/questions/109592/how-to-use-ament-lint-commons-ament-copyright-on-a-bsd-licensed-package-such | ||
For now, the C++, CMake, and XML linters are enabled. | ||
--> | ||
<test_depend>ament_cmake_cppcheck</test_depend> | ||
<test_depend>ament_cmake_cpplint</test_depend> | ||
<test_depend>ament_cmake_lint_cmake</test_depend> | ||
<test_depend>ament_cmake_uncrustify</test_depend> | ||
<test_depend>ament_cmake_xmllint</test_depend> | ||
|
||
|
||
<member_of_group>rosidl_interface_packages</member_of_group> | ||
<export> | ||
<build_type>ament_cmake</build_type> | ||
|
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,5 @@ | ||
if(TARGET "${cpp_typesupport_target}") | ||
find_package(ament_cmake_gtest CONFIG REQUIRED) | ||
ament_add_gtest(validation_test test_validation.cpp) | ||
target_link_libraries(validation_test ${PROJECT_NAME}::validation) | ||
endif() |
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,78 @@ | ||
// Copyright 2024 Ryan Friedman | ||
|
||
#include <gtest/gtest.h> | ||
#include <geographic_msgs/msg/geo_point.hpp> | ||
#include <geographic_msgs/validation.hpp> | ||
|
||
|
||
TEST(ElevationServerCore, ValidPoints) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = 1.0; | ||
point.longitude = 10.0; | ||
EXPECT_TRUE(geographic_msgs::horizontalPositionValid(point)); | ||
} | ||
|
||
TEST(ElevationServerCore, TooFarNorth) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = 90.01; | ||
point.longitude = 0.0; | ||
EXPECT_FALSE(geographic_msgs::horizontalPositionValid(point)); | ||
} | ||
|
||
TEST(ElevationServerCore, TooFarSouth) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = -90.01; | ||
point.longitude = 0.0; | ||
EXPECT_FALSE(geographic_msgs::horizontalPositionValid(point)); | ||
} | ||
|
||
TEST(ElevationServerCore, TooFarWest) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = 0.0; | ||
point.longitude = -180.1; | ||
EXPECT_FALSE(geographic_msgs::horizontalPositionValid(point)); | ||
} | ||
|
||
TEST(ElevationServerCore, TooFarEast) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = 0.0; | ||
point.longitude = 180.1; | ||
EXPECT_FALSE(geographic_msgs::horizontalPositionValid(point)); | ||
} | ||
|
||
TEST(ElevationServerCore, NorthPole) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = 90.0; | ||
point.longitude = 42.0; | ||
EXPECT_TRUE(geographic_msgs::horizontalPositionValid(point)); | ||
} | ||
|
||
TEST(ElevationServerCore, SouthPole) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = -90.0; | ||
point.longitude = 42.0; | ||
EXPECT_TRUE(geographic_msgs::horizontalPositionValid(point)); | ||
} | ||
|
||
TEST(ElevationServerCore, NorthPoleInvalidLng) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = 90.0; | ||
point.longitude = 999.0; | ||
EXPECT_FALSE(geographic_msgs::horizontalPositionValid(point)); | ||
} | ||
|
||
TEST(ElevationServerCore, SouthPoleInvalidLng) | ||
{ | ||
geographic_msgs::msg::GeoPoint point; | ||
point.latitude = -90.0; | ||
point.longitude = -999.0; | ||
EXPECT_FALSE(geographic_msgs::horizontalPositionValid(point)); | ||
} |