GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
gait_pattern_generator_basic.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#include <string>
11#include <utility>
12
13#include "cassert_define.h"
14#include "cmdio_util.h"
15#include "graph_search_const.h"
16#include "map_state.h"
17
18
19namespace designlab
20{
21
23 std::unique_ptr<GraphTreeCreator>&& graph_tree_creator,
24 std::unique_ptr<IGraphSearcher>&& graph_searcher,
25 const int max_depth,
26 const int max_node_num) :
27 graph_tree_creator_ptr_(std::move(graph_tree_creator)),
28 graph_searcher_ptr_(std::move(graph_searcher)),
29 graph_tree_{ max_node_num }, // ここでメモリを確保する.
30 max_depth_(max_depth)
31{
32 assert(graph_tree_creator_ptr_ != nullptr);
33 assert(graph_searcher_ptr_ != nullptr);
34 assert(0 < max_depth_);
35 assert(0 < max_node_num);
36}
37
39 const RobotStateNode& current_node,
40 const MapState& map_state,
41 const RobotOperation& operation,
42 RobotStateNode* output_node)
43{
44 assert(current_node.IsLootNode());
45 assert(output_node != nullptr);
46 assert(graph_tree_creator_ptr_ != nullptr);
47 assert(graph_searcher_ptr_ != nullptr);
48
49 // 初期化処理を行う.
50 DividedMapState divided_map;
51 divided_map.Init(map_state, current_node.center_of_mass_global_coord);
52
53 graph_tree_creator_ptr_->Init(divided_map);
54
55
56 // グラフ探索をするための,歩容パターングラフを生成する
57 graph_tree_.Reset();
58 graph_tree_.AddNode(current_node);
59
60 const GraphSearchResult create_result =
61 graph_tree_creator_ptr_->CreateGraphTree(0, max_depth_, &graph_tree_);
62
63 if (create_result.result != enums::Result::kSuccess)
64 {
65 return create_result;
66 }
67
68
69 // グラフ探索を行う
70 const auto [search_result, _, next_node] =
71 graph_searcher_ptr_->SearchGraphTree(
72 graph_tree_, operation, divided_map, max_depth_);
73
74 if (search_result.result != enums::Result::kSuccess)
75 {
76 return search_result;
77 }
78
79 (*output_node) = next_node;
80
81 return { enums::Result::kSuccess, "" };
82}
83
84} // namespace designlab
マップを格子状に分割して管理するクラス.
void Init(const MapState &map_state, const Vector3 global_robot_com)
マップのデータを初期化する. ロボットの重心座標を中心にマップのデータを格子状に分割し, その中に存在する脚設置可能点を集める.
GaitPatternGeneratorBasic(std::unique_ptr< GraphTreeCreator > &&graph_tree_creator_ptr, std::unique_ptr< IGraphSearcher > &&graph_searcher_ptr, int max_depth, int max_node_num)
GraphSearchResult GetNextNodeByGraphSearch(const RobotStateNode &current_node, const MapState &map_ref, const RobotOperation &operation, RobotStateNode *output_node) override
グラフ探索を行い,次の動作として最適なノードを返す.
constexpr void Reset()
グラフをリセットする.
void AddNode(const RobotStateNode &node)
ノードを追加する. 追加するノードは親ノードのインデックスと,depthの指定が適切にされている必要がある. これらが適切にされていない場合,アサーションに引っかかる. また,あらかじめ確保...
マップを表すクラス.
Definition map_state.h:32
Definition com_type.h:24
グラフ探索の結果を表す構造体.
enums::Result result
成功か失敗か.
探索において目標となる座標や角度,評価する値についてまとめた構造体.
グラフ構造のためのノード(頂点).旧名 LNODE
constexpr bool IsLootNode() const
自身が根ノードであるか判定する.
Vector3 center_of_mass_global_coord
[4 * 3 = 12byte] グローバル座標系における重心の位置.旧名 GCOM