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 "map_state.h"
16
17namespace designlab {
18
20 std::unique_ptr<GraphTreeCreator>&& graph_tree_creator,
21 std::unique_ptr<IGraphSearcher>&& graph_searcher, const int max_depth,
22 const int max_node_num)
23 : graph_tree_creator_ptr_(std::move(graph_tree_creator)),
24 graph_searcher_ptr_(std::move(graph_searcher)),
25 graph_tree_{max_node_num}, // ここでメモリを確保する.
26 max_depth_(max_depth) {
27 assert(graph_tree_creator_ptr_ != nullptr);
28 assert(graph_searcher_ptr_ != nullptr);
29 assert(0 < max_depth_);
30 assert(0 < max_node_num);
31}
32
34 const RobotStateNode& current_node, const MapState& map_state,
35 const RobotOperation& operation, RobotStateNode* output_node) {
36 assert(current_node.IsLootNode());
37 assert(output_node != nullptr);
38 assert(graph_tree_creator_ptr_ != nullptr);
39 assert(graph_searcher_ptr_ != nullptr);
40
41 // 初期化処理を行う.
42 DividedMapState divided_map;
43 divided_map.Init(map_state, current_node.center_of_mass_global_coord);
44
45 graph_tree_creator_ptr_->Init(divided_map);
46
47 // グラフ探索をするための,歩容パターングラフを生成する
48 graph_tree_.Reset();
49 graph_tree_.AddNode(current_node);
50
51 const GraphSearchResult create_result =
52 graph_tree_creator_ptr_->CreateGraphTree(0, max_depth_, &graph_tree_);
53
54 if (create_result.result != enums::Result::kSuccess) {
55 return create_result;
56 }
57
58 // グラフ探索を行う
59 const auto [search_result, _, next_node] =
60 graph_searcher_ptr_->SearchGraphTree(graph_tree_, operation, divided_map,
61 max_depth_);
62
63 if (search_result.result != enums::Result::kSuccess) {
64 return search_result;
65 }
66
67 (*output_node) = next_node;
68
69 return {enums::Result::kSuccess, ""};
70}
71
72} // 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:29
Definition com_type.h:21
グラフ探索の結果を表す構造体.
enums::Result result
成功か失敗か.
探索において目標となる座標や角度,評価する値についてまとめた構造体.
グラフ構造のためのノード(頂点).
constexpr bool IsLootNode() const
自身が根ノードであるか判定する.
Vector3 center_of_mass_global_coord
[4 * 3 = 12byte] グローバル座標系における重心の位置.旧名 GCOM