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
10
11namespace designlab
12{
13
15 const DividedMapState& divided_map,
16 const std::shared_ptr<const IHexapodCoordinateConverter>& converter_ptr,
17 const std::shared_ptr<const IHexapodPostureValidator>& checker_ptr,
18 const ::designlab::Vector3& rot_axis,
19 HexapodMove next_move) :
20 map_(divided_map),
21 next_move_(next_move),
22 converter_ptr_(converter_ptr),
23 checker_ptr_(checker_ptr),
24 rot_axis_(rot_axis)
25{
26}
27
29 int current_num, std::vector<RobotStateNode>* output_graph) const
30{
31 for (int i = 0; i < kBodyYawRotAngleDivNum; ++i)
32 {
33 const Quaternion quat = Quaternion::MakeByAngleAxis(candidate_angle_[i], rot_axis_);
34
35 RobotStateNode node = current_node;
36 node.ChangePosture(converter_ptr_, current_node.posture * quat);
37
38 if (checker_ptr_->IsBodyInterferingWithGround(node, map_))
39 {
40 continue;
41 }
42
43 bool is_valid = true;
44
45 for (int j = 0; j < HexapodConst::kLegNum; j++)
46 {
47 if (!checker_ptr_->IsLegInRange(j, node.leg_pos[j]))
48 {
49 is_valid = false;
50 break;
51 }
52 }
53
54 if (!is_valid) { continue; }
55
56 node.ChangeToNextNode(current_num, next_move_);
57
58 output_graph->push_back(node);
59 }
60
61 if (output_graph->empty())
62 {
63 // 1つも回転動作を追加できない場合は,回転しないノードを追加する.
64 RobotStateNode node = current_node;
65 node.ChangeToNextNode(current_num, next_move_);
66
67 output_graph->push_back(node);
68 }
69}
70
71} // 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になる.
グラフ構造のためのノード(頂点).旧名 LNODE
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 designlab::Quaternion &new_posture)
クォータニオンを変更し,胴体を回転させる関数.
Quaternion posture
[4 * 4 = 16byte] 姿勢を表すクォータニオン.