37 #include <global_planner_tests/easy_costmap.h> 38 #include <global_planner_tests/global_planner_tests.h> 41 #include <gtest/gtest.h> 45 const std::string
map_path =
"package://dlux_plugins/test/robert_frost.png";
59 bool pathsEqual(
const nav_2d_msgs::Path2D& path_a,
const nav_2d_msgs::Path2D& path_b)
61 if (path_a.header.frame_id != path_b.header.frame_id || path_a.poses.size() != path_b.poses.size())
65 for (
unsigned int i=0; i < path_a.poses.size(); i++)
67 if (path_a.poses[i].x != path_b.poses[i].x || path_a.poses[i].y != path_b.poses[i].y
68 || path_a.poses[i].theta != path_b.poses[i].theta)
85 bool path_caching =
false,
double improvement_threshold = -1.0)
88 std::shared_ptr<global_planner_tests::EasyCostmap> easy_costmap =
89 std::make_shared<global_planner_tests::EasyCostmap>(
map_path, 1.0);
93 private_nh.
setParam(
"path_caching", path_caching);
94 private_nh.
setParam(
"improvement_threshold", improvement_threshold);
95 private_nh.
setParam(
"potential_calculator",
"dlux_plugins::Dijkstra");
96 private_nh.
setParam(
"traceback",
"dlux_plugins::GridPath");
97 private_nh.
setParam(
"print_statistics",
true);
98 global_planner.
initialize(nh, ns, tf, easy_costmap);
103 nav_2d_msgs::Pose2DStamped start;
104 nav_2d_msgs::Pose2DStamped goal;
106 start.header.frame_id = info.
frame_id;
107 gridToWorld(info, 2, 5, start.pose.x, start.pose.y);
108 goal.header.frame_id = info.
frame_id;
109 gridToWorld(info, 17, 5, goal.pose.x, goal.pose.y);
115 nav_2d_msgs::Path2D first_path = global_planner.
makePlan(start, goal);
121 nav_2d_msgs::Path2D second_path = global_planner.
makePlan(start, goal);
123 if (expect_different)
125 EXPECT_FALSE(
pathsEqual(first_path, second_path));
129 EXPECT_TRUE(
pathsEqual(first_path, second_path));
133 TEST(GlobalPlannerReplanning, no_cache)
139 TEST(GlobalPlannerReplanning, any_cache)
145 TEST(GlobalPlannerReplanning, improve_cache)
151 TEST(GlobalPlannerReplanning, big_improve)
157 int main(
int argc,
char **argv)
159 ros::init(argc, argv,
"global_oscillation_test");
160 testing::InitGoogleTest(&argc, argv);
161 return RUN_ALL_TESTS();
void setBarrier(nav_core2::Costmap &costmap, const unsigned char value)
void replanning_test(const std::string &ns, bool expect_different, bool path_caching=false, double improvement_threshold=-1.0)
Check to see whether path caching is working as expected.
void setCost(const unsigned int x, const unsigned int y, const unsigned char cost)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void gridToWorld(const NavGridInfo &info, int mx, int my, double &wx, double &wy)
TFSIMD_FORCE_INLINE const tfScalar & y() const
const std::string map_path
bool pathsEqual(const nav_2d_msgs::Path2D &path_a, const nav_2d_msgs::Path2D &path_b)
TEST(GlobalPlannerReplanning, no_cache)
nav_2d_msgs::Path2D makePlan(const nav_2d_msgs::Pose2DStamped &start, const nav_2d_msgs::Pose2DStamped &goal) override
NavGridInfo getInfo() const
void initialize(const ros::NodeHandle &parent, const std::string &name, TFListenerPtr tf, nav_core2::Costmap::Ptr costmap) override
int main(int argc, char **argv)
std::shared_ptr< tf::TransformListener > TFListenerPtr
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const