GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
node_initializer.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
8#include "node_initializer.h"
9
10#include "divided_map_state.h"
11#include "math_rot_converter.h"
12#include "math_util.h"
13#include "leg_state.h"
14#include "phantomx_mk2_const.h"
15
16
17namespace designlab
18{
19
21 pos_(pos),
22 posture_(posture),
23 move_(move)
24{
25}
26
28{
30
31 // 脚状態.
34 { true, true, true, true, true, true },
38
39
40 const float base_z = 0.0f; // 地面のZ座標.
41 [[maybe_unused]] const float com_z = pos_.z + base_z; // ロボットの重心のZ座標.
42
43 for (int i = 0; i < HexapodConst::kLegNum; i++)
44 {
45 res.leg_pos[i] = res.leg_reference_pos[i] = {
48 -30.0f //-com_z
49 };
50 }
51
53
54 // 座標をランダマイズする.
56 //res.center_of_mass_global_coord.y += math_util::GenerateRandomNumber(-30.f, 30.f);
57
58 // 15 deg
59 //res.leg_pos[0].z -= 20.0f;
60 //res.leg_pos[5].z -= 20.0f;
61 //res.leg_pos[1].z -= 80.0f;
62 //res.leg_pos[4].z -= 80.0f;
63 //res.leg_pos[2].z -= 135.0f;
64 //res.leg_pos[3].z -= 135.0f;
65
66 // 10 deg
67 //res.leg_pos[0].z -= 32.0f;
68 //res.leg_pos[5].z -= 32.0f;
69 //res.leg_pos[1].z -= 74.0f;
70 //res.leg_pos[4].z -= 74.0f;
71 //res.leg_pos[2].z -= 116.0f;
72 //res.leg_pos[3].z -= 116.0f;
73
74 // 5 deg
75 //res.leg_pos[0].z -= 10.0f;
76 //res.leg_pos[5].z -= 10.0f;
77 //res.leg_pos[1].z -= 34.0f;
78 //res.leg_pos[4].z -= 34.0f;
79 //res.leg_pos[2].z -= 57.0f;
80 //res.leg_pos[3].z -= 57.0f;
81
82 // ロールピッチヨーで回転を表現する.ロボットの重心を中心にして回転する.
83 res.posture = ToQuaternion(posture_);
84
85 res.next_move = move_;
86 res.parent_index = -1;
87 res.depth = 0;
88
89 return res;
90}
91
93{
94 DividedMapState divided_map_state;
95 divided_map_state.Init(map, node.center_of_mass_global_coord);
96
97 // ロボットの重心
98 const float map_z = divided_map_state.GetTopZ(divided_map_state.GetDividedMapIndexX(node.center_of_mass_global_coord.x), divided_map_state.GetDividedMapIndexY(node.center_of_mass_global_coord.y));
99
100 RobotStateNode res = node;
102
103
104 return res;
105}
106
107} // namespace designlab
マップを格子状に分割して管理するクラス.
constexpr int GetDividedMapIndexX(const float pos_x) const noexcept
指定した座標を DividedMap のインデックスに変換する. 範囲外の値を指定した場合でも,値を丸めずに返す. そのため,IsInMap で範囲内に存在するかどうかを確認する必要がある.
void Init(const MapState &map_state, const Vector3 global_robot_com)
マップのデータを初期化する. ロボットの重心座標を中心にマップのデータを格子状に分割し, その中に存在する脚設置可能点を集める.
constexpr int GetDividedMapIndexY(const float pos_y) const noexcept
指定した座標を DividedMap のインデックスに変換する. 範囲外の値を指定した場合でも,値を丸めずに返す. そのため,IsInMap で範囲内に存在するかどうかを確認する必要がある.
float GetTopZ(int x_index, int y_index) const
格子状に切り分けられたマップから,最も高いZ座標を返す.
static constexpr int kLegNum
マップを表すクラス.
Definition map_state.h:32
RobotStateNode InitNode() const
ノードの初期化を行う.
RobotStateNode InitNodeForTerrain(const RobotStateNode &node, const MapState map) const
地形に適した初期姿勢を設定する.
NodeInitializer(const Vector3 &pos, const EulerXYZ &posture_, HexapodMove move)
static constexpr std::array< float, kPhantomXLegNum > kCoxaDefaultAngle
第1関節の初期角度[rad]
@ kCenterBack
重心が中央後方にある.逆三角径.
@ kCenter
現在の位置にある.
LegStateBit MakeLegStateBit(const enums::DiscreteComPos discrete_com_pos, const std::array< bool, HexapodConst::kLegNum > &is_ground, const std::array< enums::DiscreteLegPos, HexapodConst::kLegNum > &discretized_leg_pos)
脚状態を作成して返す関数.脚状態は重心パターン, 脚の接地・遊脚,離散化した脚位置のデータが含まれる.
Definition leg_state.cpp:15
T GenerateRandomNumber(T min, T max)
指定した範囲内の乱数を生成する.
Definition math_util.h:102
Quaternion ToQuaternion(const RotationMatrix3x3 &rot)
回転角行列からクォータニオンへの変換.
HexapodMove
ロボットが次にどの動作をするのかを表す列挙体.
XYZオイラー角を用いた回転を表す構造体.
Definition math_euler.h:33
グラフ構造のためのノード(頂点).旧名 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.
Vector3 center_of_mass_global_coord
[4 * 3 = 12byte] グローバル座標系における重心の位置.旧名 GCOM
Quaternion posture
[4 * 4 = 16byte] 姿勢を表すクォータニオン.
std::array< Vector3, HexapodConst::kLegNum > leg_reference_pos
int depth
[4 byte] 自身の深さ.一番上の親が深さ0となる.
3次元の位置ベクトルを表す構造体.
float x
ロボットの正面方向に正.
float z
ロボットの上向きに正.
float y
ロボットの左向きに正.