19 const std::shared_ptr<const IHexapodCoordinateConverter>& converter_ptr) :
20 converter_ptr_(converter_ptr)
26 std::array<ComPosAndPolygon, kMakePolygonNum>* output_poly)
const
28 assert(converter_ptr_ !=
nullptr);
29 assert(output_poly !=
nullptr);
32 std::array<Vector2, HexapodConst::kLegNum> leg_pos_xy;
37 leg_pos_xy[i] = converter_ptr_->ConvertLegToGlobalCoordinate(
46 MakeCandidateBox(leg_pos_xy, 0, &(*output_poly)[0].polygon);
48 (*output_poly)[0].is_able =
true;
50 MakeCandidateBox(leg_pos_xy, 1, &(*output_poly)[1].polygon);
52 (*output_poly)[1].is_able =
true;
54 MakeCandidateBox(leg_pos_xy, 2, &(*output_poly)[2].polygon);
56 (*output_poly)[2].is_able =
true;
58 MakeCandidateBox(leg_pos_xy, 3, &(*output_poly)[3].polygon);
60 (*output_poly)[3].is_able =
true;
62 MakeCandidateBox(leg_pos_xy, 4, &(*output_poly)[4].polygon);
64 (*output_poly)[4].is_able =
true;
66 MakeCandidateBox(leg_pos_xy, 5, &(*output_poly)[5].polygon);
68 (*output_poly)[5].is_able =
true;
71 MakeCandidateTriangle(leg_pos_xy, &(*output_poly)[6]);
78 if (!IsAblePolygon((*output_poly)[i].polygon))
80 (*output_poly)[i].is_able =
false;
86void ComCandidatePolygonMaker::MakeCandidateBox(
87 const std::array<Vector2, HexapodConst::kLegNum>& leg_pos,
88 const int start_leg_num,
113 Vector2 intersection_02_14 = leg_line_02.GetIntersection(leg_line_14);
114 Vector2 intersection_02_15 = leg_line_02.GetIntersection(leg_line_15);
115 Vector2 intersection_03_14 = leg_line_03.GetIntersection(leg_line_14);
116 Vector2 intersection_03_15 = leg_line_03.GetIntersection(leg_line_15);
124 (*output_poly).Reset();
126 if (leg_line_0_center.HasIntersection(leg_line_25))
129 Vector2 intersection_03_25 = leg_line_03.GetIntersection(leg_line_25);
130 Vector2 intersection_14_25 = leg_line_14.GetIntersection(leg_line_25);
132 (*output_poly).AddVertexCheckForDuplicates(intersection_03_15);
133 (*output_poly).AddVertexCheckForDuplicates(intersection_02_15);
134 (*output_poly).AddVertexCheckForDuplicates(intersection_02_14);
135 (*output_poly).AddVertexCheckForDuplicates(intersection_14_25);
136 (*output_poly).AddVertexCheckForDuplicates(intersection_03_25);
141 (*output_poly).AddVertex(intersection_03_15);
142 (*output_poly).AddVertex(intersection_02_15);
143 (*output_poly).AddVertex(intersection_02_14);
144 (*output_poly).AddVertex(intersection_03_14);
148void ComCandidatePolygonMaker::MakeCandidateTriangle(
149 const std::array<Vector2, HexapodConst::kLegNum>& leg_pos,
150 ComPosAndPolygon* output)
const
152 LineSegment2 leg_line_03(leg_pos[0], leg_pos[3]);
153 LineSegment2 leg_line_14(leg_pos[1], leg_pos[4]);
154 LineSegment2 leg_line_25(leg_pos[2], leg_pos[5]);
157 Vector2 intersection_03_14 = leg_line_03.GetIntersection(leg_line_14);
158 Vector2 intersection_03_25 = leg_line_03.GetIntersection(leg_line_25);
159 Vector2 intersection_14_25 = leg_line_14.GetIntersection(leg_line_25);
162 output->polygon.Reset();
163 output->polygon.AddVertex(intersection_03_14);
164 output->polygon.AddVertex(intersection_03_25);
165 output->polygon.AddVertex(intersection_14_25);
167 if (intersection_03_14.x > intersection_03_25.x)
176 output->is_able =
true;
181bool ComCandidatePolygonMaker::IsAblePolygon(
const Polygon2& poly)
const
184 if (poly.GetVertexNum() == 3 ||
185 poly.GetVertexNum() == 4 ||
186 poly.GetVertexNum() == 5)
static constexpr int kMakePolygonNum
作成する多角形の数.
ComCandidatePolygonMaker(const std::shared_ptr< const IHexapodCoordinateConverter > &converter_ptr)
void MakeCandidatePolygon(const RobotStateNode &node, std::array< ComPosAndPolygon, kMakePolygonNum > *output_poly) const
現在のロボットの状態を表すノードから, 重心位置の候補地点を示す多角形を作成する.
static constexpr int kLegNum
@ kCenterFront
重心が中央前方にある.三角形.
@ kCenterBack
重心が中央後方にある.逆三角径.
グラフ構造のためのノード(頂点).旧名 LNODE
std::array< Vector3, HexapodConst::kLegNum > leg_pos
[4 * 3 * 6 = 72 byte] 脚先の座標.(coxa(脚の付け根)を原点とする)
Vector3 center_of_mass_global_coord
[4 * 3 = 12byte] グローバル座標系における重心の位置.旧名 GCOM
Quaternion posture
[4 * 4 = 16byte] 姿勢を表すクォータニオン.