GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
node_creator_body_rot.cpp
[詳解]
1
3
4// Copyright(c) 2023-2025 Design Engineering Laboratory, Saitama University
5// Released under the MIT license
6// https://opensource.org/licenses/mit-license.php
7
9
10namespace designlab {
11
13 const DividedMapState& divided_map,
14 const std::shared_ptr<const IHexapodCoordinateConverter>& converter_ptr,
15 const std::shared_ptr<const IHexapodPostureValidator>& checker_ptr,
16 const Vector3& rot_axis, HexapodMove next_move)
17 : map_(divided_map),
18 next_move_(next_move),
19 converter_ptr_(converter_ptr),
20 checker_ptr_(checker_ptr),
21 rot_axis_(rot_axis) {}
22
24 const RobotStateNode& current_node, int current_num,
25 std::vector<RobotStateNode>* output_graph) const {
26 for (int i = 0; i < kBodyYawRotAngleDivNum; ++i) {
27 const Quaternion quat =
28 Quaternion::MakeByAngleAxis(candidate_angle_[i], rot_axis_);
29
30 RobotStateNode node = current_node;
31 node.ChangePosture(converter_ptr_, current_node.posture * quat);
32
33 if (checker_ptr_->IsBodyInterferingWithGround(node, map_)) {
34 continue;
35 }
36
37 bool is_valid = true;
38
39 for (int j = 0; j < HexapodConst::kLegNum; j++) {
40 if (!checker_ptr_->IsLegInRange(j, node.leg_pos[j])) {
41 is_valid = false;
42 break;
43 }
44 }
45
46 if (!is_valid) {
47 continue;
48 }
49
50 node.ChangeToNextNode(current_num, next_move_);
51
52 output_graph->push_back(node);
53 }
54
55 if (output_graph->empty()) {
56 // 1つも回転動作を追加できない場合は,回転しないノードを追加する.
57 RobotStateNode node = current_node;
58 node.ChangeToNextNode(current_num, next_move_);
59
60 output_graph->push_back(node);
61 }
62}
63
64} // namespace designlab
マップを格子状に分割して管理するクラス.
static constexpr int kLegNum
void Create(const RobotStateNode &current_node, int current_num, std::vector< RobotStateNode > *output_graph) const override
現在のノードから次のノード群を生成する.
NodeCreatorBodyRot(const DividedMapState &devide_map, const std::shared_ptr< const IHexapodCoordinateConverter > &converter_ptr, const std::shared_ptr< const IHexapodPostureValidator > &checker_ptr, const Vector3 &rot_axis, HexapodMove next_move)
HexapodMove
ロボットが次にどの動作をするのかを表す列挙体.
クォータニオンを表す構造体.
static Quaternion MakeByAngleAxis(float rad_angle, const Vector3 &axis)
回転軸と回転角からクォータニオンを作成する. q = cos(θ/2) * w + sin(θ/2) * { v.x + v.y + v.z } となる. ノルムは必ず1になる.
グラフ構造のためのノード(頂点).
std::array< Vector3, HexapodConst::kLegNum > leg_pos
[4 * 3 * 6 = 72 byte] 脚先の座標.(coxa(脚の付け根)を原点とする)
constexpr void ChangeToNextNode(const int parent_index_, const HexapodMove next_move_)
次の動作を設定する関数. 深さを一つ深くして,親と次の動作を設定する.
void ChangePosture(const std::shared_ptr< const IHexapodCoordinateConverter > &converter_ptr, const Quaternion &new_posture)
クォータニオンを変更し,胴体を回転させる関数.
Quaternion posture
[4 * 4 = 16byte] 姿勢を表すクォータニオン.
3次元の位置ベクトルを表す構造体.