1 #include <gtest/gtest.h> 2 #include <gmock/gmock.h> 6 #include <mbf_abstract_nav/MoveBaseFlexConfig.h> 9 #include <geometry_msgs/PoseStamped.h> 10 #include <geometry_msgs/TwistStamped.h> 11 #include <geometry_msgs/Twist.h> 13 #include <geometry_msgs/TransformStamped.h> 18 using geometry_msgs::PoseStamped;
19 using geometry_msgs::TransformStamped;
20 using geometry_msgs::Twist;
21 using geometry_msgs::TwistStamped;
24 using mbf_abstract_nav::MoveBaseFlexConfig;
26 using testing::Return;
32 typedef std::vector<PoseStamped>
plan_t;
52 TF_PTR, MoveBaseFlexConfig{})
60 if (getState() != NO_LOCAL_CMD)
61 EXPECT_FALSE(isMoving());
77 waitForStateUpdate(boost::chrono::seconds(1));
78 ASSERT_EQ(getState(), NO_PLAN);
87 setNewPlan(
plan_t{},
true, 1, 1);
93 waitForStateUpdate(boost::chrono::seconds(1));
94 ASSERT_EQ(getState(), EMPTY_PLAN);
107 setNewPlan(plan,
true, 1, 1);
110 ASSERT_TRUE(
start());
113 waitForStateUpdate(boost::chrono::seconds(1));
114 ASSERT_EQ(getState(), INVALID_PLAN);
128 setNewPlan(plan,
true, 1, 1);
131 global_frame_ =
"global_frame";
132 robot_frame_ =
"not_global_frame";
135 ASSERT_TRUE(
start());
139 waitForStateUpdate(boost::chrono::seconds(2));
140 ASSERT_EQ(getState(), INTERNAL_ERROR);
149 global_frame_ =
"global_frame";
150 robot_frame_ =
"robot_frame";
157 TransformStamped transform;
159 transform.header.frame_id = global_frame_;
160 transform.child_frame_id = robot_frame_;
161 transform.transform.rotation.w = 1;
164 TF_PTR->setTransform(transform,
"mama");
180 plan.back().header.frame_id = global_frame_;
181 plan.back().pose.orientation.w = 1;
184 setNewPlan(plan,
true, 1e-3, 1e-3);
187 ASSERT_TRUE(
start());
190 waitForStateUpdate(boost::chrono::seconds(1));
191 ASSERT_EQ(getState(), ARRIVED_GOAL);
196 throw std::runtime_error(
"Oh no! Controller throws an Exception");
210 setNewPlan(plan,
true, 1e-3, 1e-3);
213 ASSERT_TRUE(
start());
216 waitForStateUpdate(boost::chrono::seconds(1));
217 ASSERT_EQ(getState(), INTERNAL_ERROR);
234 setNewPlan(plan,
true, 1e-3, 1e-3);
250 ASSERT_TRUE(
start());
253 waitForStateUpdate(boost::chrono::seconds(1));
254 ASSERT_EQ(getState(), NO_LOCAL_CMD);
258 waitForStateUpdate(boost::chrono::seconds(1));
259 ASSERT_EQ(getState(), MAX_RETRIES);
270 ASSERT_TRUE(
start());
273 waitForStateUpdate(boost::chrono::seconds(1));
274 ASSERT_EQ(getState(), NO_LOCAL_CMD);
287 ASSERT_TRUE(
start());
290 waitForStateUpdate(boost::chrono::seconds(1));
291 ASSERT_EQ(getState(), PAT_EXCEEDED);
294 int main(
int argc,
char** argv)
300 GOAL_PUB = nh.
advertise<PoseStamped>(
"pose", 1);
303 TF_PTR.reset(
new TF());
304 TF_PTR->setUsingDedicatedThread(
true);
311 testing::InitGoogleTest(&argc, argv);
312 return RUN_ALL_TESTS();
TEST_F(AbstractControllerExecutionFixture, noPlan)
ROSCONSOLE_DECL void notifyLoggerLevelsChanged()
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::vector< PoseStamped > plan_t
AbstractControllerExecutionFixture()
The AbstractControllerExecution class loads and binds the controller plugin. It contains a thread run...
MOCK_METHOD1(setPlan, bool(const plan_t &))
EXPECT_CALL(action_server, publishResult(_, Field(&mbf_msgs::GetPathResult::outcome, Eq(mbf_msgs::GetPathResult::SUCCESS)))) .Times(1) .WillOnce(Notify(&done_condition_))
virtual bool isGoalReached(double dist_tolerance, double angle_tolerance)=0
MOCK_METHOD2(isGoalReached, bool(double, double))
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
MOCK_METHOD4(computeVelocityCommands, uint32_t(const PoseStamped &, const TwistStamped &, TwistStamped &, std::string &))
virtual uint32_t computeVelocityCommands(const geometry_msgs::PoseStamped &pose, const geometry_msgs::TwistStamped &velocity, geometry_msgs::TwistStamped &cmd_vel, std::string &message)=0
int main(int argc, char **argv)
virtual bool setPlan(const std::vector< geometry_msgs::PoseStamped > &plan)=0
MOCK_METHOD0(cancel, bool())
ACTION(ControllerException)
ROSCONSOLE_DECL bool set_logger_level(const std::string &name, levels::Level level)
#define ROSCONSOLE_DEFAULT_NAME