34 #include <diagnostic_msgs/DiagnosticArray.h> 35 #include <geometry_msgs/PoseStamped.h> 36 #include <nav_msgs/Path.h> 38 #include <costmap_cspace_msgs/CSpace3DUpdate.h> 39 #include <planner_cspace_msgs/PlannerStatus.h> 41 #include <gtest/gtest.h> 43 TEST(Planner3D, CostmapWatchdog)
46 planner_cspace_msgs::PlannerStatus::ConstPtr status;
47 nav_msgs::Path::ConstPtr path;
48 diagnostic_msgs::DiagnosticArray::ConstPtr diag;
50 const boost::function<void(const planner_cspace_msgs::PlannerStatus::ConstPtr&)> cb_status =
51 [&status, &cnt](
const planner_cspace_msgs::PlannerStatus::ConstPtr&
msg) ->
void 56 const boost::function<void(const nav_msgs::Path::ConstPtr&)> cb_path =
57 [&path](
const nav_msgs::Path::ConstPtr&
msg) ->
void 61 const boost::function<void(const diagnostic_msgs::DiagnosticArray::ConstPtr&)> cb_diag =
62 [&diag](
const diagnostic_msgs::DiagnosticArray::ConstPtr&
msg) ->
void 74 geometry_msgs::PoseStamped goal;
75 goal.header.frame_id =
"map";
76 goal.pose.position.x = 1.9;
77 goal.pose.position.y = 2.8;
78 goal.pose.orientation.w = 1.0;
85 if (cnt == 0 || cnt > 8)
87 costmap_cspace_msgs::CSpace3DUpdate
update;
89 update.header.frame_id =
"map";
90 update.width = update.height = update.angle = 0;
91 pub_cost_update.publish(update);
100 if (5 < cnt && cnt < 8)
102 ASSERT_EQ(status->error, planner_cspace_msgs::PlannerStatus::DATA_MISSING);
104 ASSERT_TRUE(static_cast<bool>(path));
105 ASSERT_EQ(path->poses.size(), 0u);
107 ASSERT_TRUE(static_cast<bool>(diag));
108 ASSERT_EQ(diag->status.size(), 1u);
109 ASSERT_EQ(diag->status[0].level, diagnostic_msgs::DiagnosticStatus::ERROR);
110 ASSERT_NE(diag->status[0].message.find(
"missing"), std::string::npos);
112 else if (10 < cnt && cnt < 13)
114 ASSERT_EQ(status->status, planner_cspace_msgs::PlannerStatus::DOING);
115 ASSERT_EQ(status->error, planner_cspace_msgs::PlannerStatus::GOING_WELL);
117 ASSERT_EQ(diag->status.size(), 1u);
118 ASSERT_EQ(diag->status[0].level, diagnostic_msgs::DiagnosticStatus::OK);
119 ASSERT_NE(diag->status[0].message.find(
"well"), std::string::npos);
129 int main(
int argc,
char** argv)
131 testing::InitGoogleTest(&argc, argv);
134 return RUN_ALL_TESTS();
TEST(Planner3D, CostmapWatchdog)
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
ROSCPP_DECL void spinOnce()