forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(radar_tracks_noise_filter): add unit test (autowarefoundation#6113)
* feat/test_radar_tracks_noise_filter Signed-off-by: N-Eiki <[email protected]> * change file name Signed-off-by: N-Eiki <[email protected]> --------- Signed-off-by: N-Eiki <[email protected]> Co-authored-by: Satoshi Tanaka <[email protected]>
- Loading branch information
1 parent
a1adbea
commit d7ad651
Showing
4 changed files
with
129 additions
and
0 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
95 changes: 95 additions & 0 deletions
95
...s_noise_filter/test/radar_tracks_noise_filter/test_radar_tracks_noise_filter_is_noise.cpp
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,95 @@ | ||
// Copyright 2023 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 "radar_tracks_noise_filter/radar_tracks_noise_filter_node.hpp" | ||
|
||
#include <radar_msgs/msg/radar_scan.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
std::shared_ptr<radar_tracks_noise_filter::RadarTrackCrossingNoiseFilterNode> get_node( | ||
float velocity_y_threshold) | ||
{ | ||
rclcpp::NodeOptions node_options; | ||
node_options.parameter_overrides({ | ||
{"node_params.is_amplitude_filter", true}, | ||
{"velocity_y_threshold", velocity_y_threshold}, | ||
}); | ||
|
||
auto node = | ||
std::make_shared<radar_tracks_noise_filter::RadarTrackCrossingNoiseFilterNode>(node_options); | ||
return node; | ||
} | ||
|
||
radar_msgs::msg::RadarTrack getRadarTrack(float velocity_x, float velocity_y) | ||
{ | ||
radar_msgs::msg::RadarTrack radar_track; | ||
geometry_msgs::msg::Vector3 vector_msg; | ||
vector_msg.x = velocity_x; | ||
vector_msg.y = velocity_y; | ||
vector_msg.z = 0.0; | ||
radar_track.velocity = vector_msg; | ||
return radar_track; | ||
} | ||
|
||
TEST(RadarTracksNoiseFilter, isNoise) | ||
{ | ||
using radar_msgs::msg::RadarTrack; | ||
using radar_tracks_noise_filter::RadarTrackCrossingNoiseFilterNode; | ||
rclcpp::init(0, nullptr); | ||
{ | ||
float velocity_node_threshold = 0.0; | ||
float y_velocity = 0.0; | ||
float x_velocity = 10.0; | ||
std::shared_ptr<RadarTrackCrossingNoiseFilterNode> node = get_node(velocity_node_threshold); | ||
RadarTrack radar_track = getRadarTrack(x_velocity, y_velocity); | ||
EXPECT_TRUE(node->isNoise(radar_track)); | ||
} | ||
|
||
{ | ||
float velocity_node_threshold = -1.0; | ||
float y_velocity = 3.0; | ||
float x_velocity = 10.0; | ||
std::shared_ptr<RadarTrackCrossingNoiseFilterNode> node = get_node(velocity_node_threshold); | ||
RadarTrack radar_track = getRadarTrack(x_velocity, y_velocity); | ||
EXPECT_TRUE(node->isNoise(radar_track)); | ||
} | ||
|
||
{ | ||
float velocity_node_threshold = -1.0; | ||
float y_velocity = 3.0; | ||
float x_velocity = 100.0; | ||
std::shared_ptr<RadarTrackCrossingNoiseFilterNode> node = get_node(velocity_node_threshold); | ||
RadarTrack radar_track = getRadarTrack(x_velocity, y_velocity); | ||
EXPECT_TRUE(node->isNoise(radar_track)); | ||
} | ||
|
||
{ | ||
float velocity_node_threshold = 3.0; | ||
float y_velocity = 1.0; | ||
float x_velocity = 10.0; | ||
std::shared_ptr<RadarTrackCrossingNoiseFilterNode> node = get_node(velocity_node_threshold); | ||
RadarTrack radar_track = getRadarTrack(x_velocity, y_velocity); | ||
EXPECT_FALSE(node->isNoise(radar_track)); | ||
} | ||
|
||
{ | ||
float velocity_node_threshold = 3.0; | ||
float y_velocity = 1.0; | ||
float x_velocity = -10.0; | ||
std::shared_ptr<RadarTrackCrossingNoiseFilterNode> node = get_node(velocity_node_threshold); | ||
RadarTrack radar_track = getRadarTrack(x_velocity, y_velocity); | ||
EXPECT_FALSE(node->isNoise(radar_track)); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
sensing/radar_tracks_noise_filter/test/test_radar_tracks_noise_filter.cpp
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,26 @@ | ||
// Copyright 2023 TierIV | ||
// | ||
// 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 <rclcpp/rclcpp.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
rclcpp::init(argc, argv); | ||
bool result = RUN_ALL_TESTS(); | ||
rclcpp::shutdown(); | ||
return result; | ||
} |