5 #include <gtest/gtest.h> 14 msgs::StepPlan
genStepPlan(geometry_msgs::Pose start,
unsigned int steps,
unsigned int foot_index = msgs::Foot::LEFT,
unsigned int start_step_index = 0,
bool closing_step =
true)
16 msgs::StepPlan step_plan;
22 step.foot.foot_index = foot_index;
23 step.foot.pose = start;
24 step.step_index = start_step_index;
27 step_plan.steps.push_back(step);
33 for (
unsigned int i = 0; i < steps; i++)
36 if (step.foot.foot_index == msgs::Foot::RIGHT)
38 step.foot.foot_index = msgs::Foot::LEFT;
39 step.foot.pose.position.x += 0.2 * -sin(yaw);
40 step.foot.pose.position.y += 0.2 * cos(yaw);
44 step.foot.foot_index = msgs::Foot::RIGHT;
45 step.foot.pose.position.x += -0.2 * -sin(yaw);
46 step.foot.pose.position.y += -0.2 * cos(yaw);
51 if (!closing_step || i < steps-1)
53 step.foot.pose.position.x += 0.25 * cos(yaw);
54 step.foot.pose.position.y += 0.25 * sin(yaw);
59 step_plan.steps.push_back(step);
67 geometry_msgs::Pose start;
68 start.position.x = 1.0;
69 start.position.z = 1.0;
73 msgs::StepPlan step_plan_1 =
genStepPlan(start, 4, msgs::Foot::LEFT, 0,
false);
76 msgs::StepPlan step_plan_2 =
genStepPlan(step_plan_1.steps.back().foot.pose, 6, msgs::Foot::LEFT);
77 step_plan_2.steps.erase(step_plan_2.steps.begin());
80 StepPlan step_plan_result(step_plan_1);
82 ASSERT_EQ(12, step_plan_result.
size());
86 ASSERT_EQ(12, step_plan_exp.size());
95 geometry_msgs::Pose start;
96 start.position.x = 1.0;
97 start.position.z = 1.0;
101 msgs::StepPlan step_plan_1 =
genStepPlan(start, 6, msgs::Foot::LEFT);
104 msgs::StepPlan step_plan_2 =
genStepPlan(step_plan_1.steps[3].foot.pose, 8, msgs::Foot::RIGHT, 3);
107 StepPlan step_plan_result(step_plan_1);
109 ASSERT_EQ(13, step_plan_result.
size());
113 ASSERT_EQ(13, step_plan_exp.size());
115 for (
size_t i = 3; i < 8; i++)
118 EXPECT_TRUE(step_plan_exp.getStep(step, i));
119 step_plan_exp.updateStep(step);
129 geometry_msgs::Pose start_1;
130 start_1.position.x = 1.0;
131 start_1.position.y = 1.1;
132 start_1.position.z = 1.0;
136 msgs::StepPlan step_plan_1 =
genStepPlan(start_1, 6);
138 geometry_msgs::Pose start_2;
139 start_2.position.x = 2.1;
140 start_2.position.y = 1.0;
141 start_2.position.z = 1.0;
145 msgs::StepPlan step_plan_2 =
genStepPlan(start_2, 6, msgs::Foot::RIGHT, 3);
148 StepPlan step_plan_result(step_plan_1);
150 ASSERT_EQ(11, step_plan_result.
size());
154 ASSERT_EQ(11, step_plan_exp.size());
156 for (
size_t i = 3; i < 8; i++)
159 EXPECT_TRUE(step_plan_exp.getStep(step, i));
160 step_plan_exp.updateStep(step);
static double getYaw(const Quaternion &bt_q)
TEST(StepPlan, appendStepPlan)
msgs::StepPlan genStepPlan(geometry_msgs::Pose start, unsigned int steps, unsigned int foot_index=msgs::Foot::LEFT, unsigned int start_step_index=0, bool closing_step=true)
static geometry_msgs::Quaternion createQuaternionMsgFromYaw(double yaw)