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#include "math_util.h"
13
14namespace designlab {
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 for (size_t i = 0; i < kCandidateDirectionNum; ++i) {
28 const float deg = 360.0f / kCandidateDirectionNum * i +
29 360 / (kCandidateDirectionNum * 2.0f);
30 const float rad = math_util::ConvertDegToRad(deg);
31
32 candidate_directions_[i] = Vector3(std::cos(rad), std::sin(rad), 0.0f);
33 }
34}
35
37 const RobotStateNode& current_node, int current_num,
38 std::vector<RobotStateNode>* output_graph) const {
39 RobotStateNode next_node;
40
41 std::array<Vector3, kCandidateDirectionNum> candidate_directions_rotated;
42
43 for (size_t i = 0; i < kCandidateDirectionNum; ++i) {
44 candidate_directions_rotated[i] =
45 RotateVector3(candidate_directions_[i], current_node.posture);
46 }
47
48 for (size_t i = 0; i < kCandidateDirectionNum; ++i) {
49 bool is_able = false;
50
51 next_node = current_node;
52 int able_count = 0;
53
54 for (float j = kMoveDistanceStep; j <= kMaxMoveDistance;
55 j += kMoveDistanceStep) {
57 current_node.center_of_mass_global_coord +
58 candidate_directions_rotated[i] * j,
59 false);
60
61 // IsLegInRange,IsStable,IsBodyInterfering を確認する.
62 if (checker_ptr_->IsAllLegInRange(next_node.leg_state,
63 next_node.leg_pos) &&
64 checker_ptr_->IsStable(next_node.leg_state, next_node.leg_pos) &&
65 !checker_ptr_->IsBodyInterferingWithGround(next_node, map_)) {
66 is_able = true;
67 able_count = static_cast<int>(j);
68 } else {
69 break;
70 }
71 }
72
73 if (is_able) {
74 // 次のノードの重心座標を更新する.
76 current_node.center_of_mass_global_coord +
77 candidate_directions_rotated[i] * static_cast<float>(able_count),
78 false);
79
80 next_node.ChangeToNextNode(current_num, next_move_);
81
82 // discreate_leg_posを更新する.
83 for (int j = 0; j < HexapodConst::kLegNum; j++) {
85 &next_node.leg_state);
86 }
87
88 output_graph->push_back(next_node);
89 }
90 }
91}
92
93} // 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
現在のノードから次のノード群を生成する.
void ChangeDiscreteLegPos(const int leg_index, const DiscreteLegPos new_discretized_leg_pos, LegStateBit *leg_state)
脚の状態を変更する.遊脚を表すビットはそのまま.
constexpr T ConvertDegToRad(const T deg) noexcept
角度を [deg] から [rad] に変換する関数.
Definition math_util.h:119
@ kCenter
現在の位置にある.
Vector3 RotateVector3(const Vector3 &vec, const EulerXYZ &rot)
回転させたベクトルを返す.三角関数の処理が多く重たいので注意.
HexapodMove
ロボットが次にどの動作をするのかを表す列挙体.
グラフ構造のためのノード(頂点).
std::array< Vector3, HexapodConst::kLegNum > leg_pos
[4 * 3 * 6 = 72 byte] 脚先の座標.(coxa(脚の付け根)を原点とする)
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] 姿勢を表すクォータニオン.
void ChangeGlobalCenterOfMass(const Vector3 &new_com, bool do_change_leg_base_pos)
重心位置を変更する関数.
3次元の位置ベクトルを表す構造体.