GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
node_creator_com_move_straight.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 <numbers>
11
12
13namespace designlab
14{
15
17 const DividedMapState& divided_map,
18 const std::shared_ptr<const IHexapodCoordinateConverter>& converter_ptr,
19 const std::shared_ptr<const IHexapodStatePresenter>& presenter_ptr,
20 const std::shared_ptr<const IHexapodPostureValidator>& checker_ptr,
21 HexapodMove next_move) :
22 map_(divided_map),
23 next_move_(next_move),
24 converter_ptr_(converter_ptr),
25 presenter_ptr_(presenter_ptr),
26 checker_ptr_(checker_ptr)
27{
28 for (size_t i = 0; i < kCandidateDirectionNum; ++i)
29 {
30 const float rad = static_cast<float>(i) * 2.f * std::numbers::pi_v<float> /
31 static_cast<float>(kCandidateDirectionNum);
32
33 candidate_directions_[i] = Vector3(std::cos(rad), std::sin(rad), 0.0f);
34 }
35}
36
38 int current_num,
39 std::vector<RobotStateNode>* output_graph) const
40{
41 RobotStateNode next_node;
42
43 std::array<Vector3, kCandidateDirectionNum> candidate_directions_rotated;
44
45 for (size_t i = 0; i < kCandidateDirectionNum; ++i)
46 {
47 candidate_directions_rotated[i] = RotateVector3(candidate_directions_[i],
48 current_node.posture);
49 }
50
51 for (size_t i = 0; i < kCandidateDirectionNum; ++i)
52 {
53 bool is_able = false;
54
55 next_node = current_node;
56 int able_count = 0;
57
58 for (float j = kMoveDistanceStep; j <= kMaxMoveDistance; j += kMoveDistanceStep)
59 {
61 candidate_directions_rotated[i] * j, false);
62
63 // IsLegInRange,IsStable,IsBodyInterfering を確認する.
64 if (checker_ptr_->IsAllLegInRange(next_node.leg_state, next_node.leg_pos) &&
65 checker_ptr_->IsStable(next_node.leg_state, next_node.leg_pos) &&
66 !checker_ptr_->IsBodyInterferingWithGround(next_node, map_))
67 {
68 is_able = true;
69 able_count = static_cast<int>(j);
70 }
71 else
72 {
73 break;
74 }
75 }
76
77 if (is_able)
78 {
80 candidate_directions_rotated[i] *
81 static_cast<float>(able_count), false);
82
83 next_node.ChangeToNextNode(current_num, next_move_);
84
85 // discreate_leg_posを更新する.
86 for (int j = 0; j < HexapodConst::kLegNum; j++)
87 {
89 &next_node.leg_state);
90 }
91
92 output_graph->push_back(next_node);
93 }
94 }
95}
96
97
98} // namespace designlab
マップを格子状に分割して管理するクラス.
static constexpr int kLegNum
NodeCreatorComMoveStraight(const DividedMapState &devide_map, const std::shared_ptr< const IHexapodCoordinateConverter > &converter_ptr, const std::shared_ptr< const IHexapodStatePresenter > &presenter_ptr, const std::shared_ptr< const IHexapodPostureValidator > &checker_ptr, HexapodMove next_move)
void Create(const RobotStateNode &current_node, int current_num, std::vector< RobotStateNode > *output_graph) const override
現在のノードから次のノード群を生成する.
@ kCenter
現在の位置にある.
void ChangeDiscreteLegPos(const int leg_index, const enums::DiscreteLegPos new_discretized_leg_pos, LegStateBit *leg_state)
脚の状態を変更する.遊脚を表すビットはそのまま.
Vector3 RotateVector3(const Vector3 &vec, const EulerXYZ &rot)
回転させたベクトルを返す.三角関数の処理が多く重たいので注意.
HexapodMove
ロボットが次にどの動作をするのかを表す列挙体.
グラフ構造のためのノード(頂点).旧名 LNODE
std::array< Vector3, HexapodConst::kLegNum > leg_pos
[4 * 3 * 6 = 72 byte] 脚先の座標.(coxa(脚の付け根)を原点とする)
void ChangeGlobalCenterOfMass(const designlab::Vector3 &new_com, bool do_change_leg_base_pos)
重心位置を変更する関数.
leg_func::LegStateBit leg_state
[4 byte] 脚状態,重心パターンを bitで表す.旧名 leg_con.
constexpr void ChangeToNextNode(const int parent_index_, const HexapodMove next_move_)
次の動作を設定する関数. 深さを一つ深くして,親と次の動作を設定する.
Vector3 center_of_mass_global_coord
[4 * 3 = 12byte] グローバル座標系における重心の位置.旧名 GCOM
Quaternion posture
[4 * 4 = 16byte] 姿勢を表すクォータニオン.
3次元の位置ベクトルを表す構造体.