17 const std::shared_ptr<const IHexapodCoordinateConverter>& converter_ptr)
18 : converter_ptr_(converter_ptr) {}
22 std::array<ComPosAndPolygon, kMakePolygonNum>* output_poly)
const {
23 assert(converter_ptr_ !=
nullptr);
24 assert(output_poly !=
nullptr);
27 std::array<Vector2, HexapodConst::kLegNum> leg_pos_xy;
33 ->ConvertLegToGlobalCoordinate(node.
leg_pos[i], i,
40 MakeCandidateBox(leg_pos_xy, 0, &(*output_poly)[0].polygon);
42 (*output_poly)[0].is_able =
true;
44 MakeCandidateBox(leg_pos_xy, 1, &(*output_poly)[1].polygon);
46 (*output_poly)[1].is_able =
true;
48 MakeCandidateBox(leg_pos_xy, 2, &(*output_poly)[2].polygon);
50 (*output_poly)[2].is_able =
true;
52 MakeCandidateBox(leg_pos_xy, 3, &(*output_poly)[3].polygon);
54 (*output_poly)[3].is_able =
true;
56 MakeCandidateBox(leg_pos_xy, 4, &(*output_poly)[4].polygon);
58 (*output_poly)[4].is_able =
true;
60 MakeCandidateBox(leg_pos_xy, 5, &(*output_poly)[5].polygon);
62 (*output_poly)[5].is_able =
true;
65 MakeCandidateTriangle(leg_pos_xy, &(*output_poly)[6]);
68 if (kDoCheckPolygon) {
70 if (!IsAblePolygon((*output_poly)[i].polygon)) {
71 (*output_poly)[i].is_able =
false;
77void ComCandidatePolygonMaker::MakeCandidateBox(
78 const std::array<Vector2, HexapodConst::kLegNum>& leg_pos,
79 const int start_leg_num,
Polygon2* output_poly)
const {
102 Vector2 intersection_02_14 = leg_line_02.GetIntersection(leg_line_14);
103 Vector2 intersection_02_15 = leg_line_02.GetIntersection(leg_line_15);
104 Vector2 intersection_03_14 = leg_line_03.GetIntersection(leg_line_14);
105 Vector2 intersection_03_15 = leg_line_03.GetIntersection(leg_line_15);
113 (*output_poly).Reset();
115 if (leg_line_0_center.HasIntersection(leg_line_25)) {
117 Vector2 intersection_03_25 = leg_line_03.GetIntersection(leg_line_25);
118 Vector2 intersection_14_25 = leg_line_14.GetIntersection(leg_line_25);
120 (*output_poly).AddVertexCheckForDuplicates(intersection_03_15);
121 (*output_poly).AddVertexCheckForDuplicates(intersection_02_15);
122 (*output_poly).AddVertexCheckForDuplicates(intersection_02_14);
123 (*output_poly).AddVertexCheckForDuplicates(intersection_14_25);
124 (*output_poly).AddVertexCheckForDuplicates(intersection_03_25);
127 (*output_poly).AddVertex(intersection_03_15);
128 (*output_poly).AddVertex(intersection_02_15);
129 (*output_poly).AddVertex(intersection_02_14);
130 (*output_poly).AddVertex(intersection_03_14);
134void ComCandidatePolygonMaker::MakeCandidateTriangle(
135 const std::array<Vector2, HexapodConst::kLegNum>& leg_pos,
136 ComPosAndPolygon* output)
const {
137 LineSegment2 leg_line_03(leg_pos[0], leg_pos[3]);
138 LineSegment2 leg_line_14(leg_pos[1], leg_pos[4]);
139 LineSegment2 leg_line_25(leg_pos[2], leg_pos[5]);
142 Vector2 intersection_03_14 = leg_line_03.GetIntersection(leg_line_14);
143 Vector2 intersection_03_25 = leg_line_03.GetIntersection(leg_line_25);
144 Vector2 intersection_14_25 = leg_line_14.GetIntersection(leg_line_25);
147 output->polygon.Reset();
148 output->polygon.AddVertex(intersection_03_14);
149 output->polygon.AddVertex(intersection_03_25);
150 output->polygon.AddVertex(intersection_14_25);
152 if (intersection_03_14.x > intersection_03_25.x) {
158 output->is_able =
true;
163bool ComCandidatePolygonMaker::IsAblePolygon(
const Polygon2& poly)
const {
165 if (poly.GetVertexNum() == 3 || poly.GetVertexNum() == 4 ||
166 poly.GetVertexNum() == 5) {
168 if (poly.IsConvex()) {
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
重心が中央後方にある.逆三角径.
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] 姿勢を表すクォータニオン.