33 #include <boost/thread.hpp> 37 #include <gtest/gtest.h> 46 omp_set_num_threads(2);
48 const auto cb_cost = [](
49 const Vec&, Vec&,
const Vec&,
const Vec&) ->
float 53 const auto cb_cost_estim = [](
const Vec&,
const Vec&) ->
float 57 std::vector<Vec>
search[16];
58 for (
int i = 1; i < 15; ++i)
60 search[0].push_back(Vec(i));
61 for (
int j = 1; j < 15; ++j)
65 search[i].push_back(Vec(j));
67 search[i].push_back(Vec(15));
70 const auto cb_search = [&search](
71 const Vec& p,
const Vec&,
const Vec&) -> std::vector<Vec>&
75 const auto cb_progress = [](
const std::list<Vec>&)
80 for (
int i = 0; i < 1000; ++i)
85 Vec(0), Vec(15), path,
86 cb_cost, cb_cost_estim, cb_search, cb_progress,
88 ASSERT_EQ(path.size(), 3u);
89 ASSERT_EQ(path.front(), Vec(0));
90 ASSERT_EQ(path.back(), Vec(15));
121 const auto timeout_func = []()
125 boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
127 catch (boost::thread_interrupted&)
131 EXPECT_TRUE(
false) <<
"Looks entered endless loop. Test will be aborted.";
134 boost::thread timeout(timeout_func);
160 ASSERT_EQ(path.size(), 3u);
161 auto it = path.cbegin();
162 ASSERT_EQ(*(it++),
Vec(0));
163 ASSERT_EQ(*(it++),
Vec(1));
164 ASSERT_EQ(*it,
Vec(2));
167 int main(
int argc,
char** argv)
169 testing::InitGoogleTest(&argc, argv);
171 return RUN_ALL_TESTS();
void setSearchTaskNum(const size_t &search_task_num)
bool findPath(const Vec &s, const Vec &e, std::list< Vec > &path)
CyclicVecInt< DIM, NONCYCLIC > Vec
bool search(const Vec &s, const Vec &e, std::list< Vec > &path, std::function< float(const Vec &, Vec &, const Vec &, const Vec &)> cb_cost, std::function< float(const Vec &, const Vec &)> cb_cost_estim, std::function< std::vector< Vec > &(const Vec &, const Vec &, const Vec &)> cb_search, std::function< bool(const std::list< Vec > &)> cb_progress, const float cost_leave, const float progress_interval, const bool return_best=false)
GridAstarTestWrapper(const Vec &size)
std::unordered_map< Vec, Vec, Vec > parents_
int main(int argc, char **argv)
TEST(GridAstar, ParallelSearch)
ROSCPP_DECL bool search(const std::string &ns, const std::string &key, std::string &result)
bool findPath(const Vec &s, const Vec &e, std::list< Vec > &path)
std::unordered_map< Vec, Vec, Vec > & parentMap()