22 const std::shared_ptr<const IHexapodCoordinateConverter>& converter_ptr,
23 const std::shared_ptr<const IHexapodStatePresenter>& presenter_ptr,
24 const std::shared_ptr<const IHexapodPostureValidator>& checker_ptr,
27 converter_ptr_(converter_ptr),
28 presenter_ptr_(presenter_ptr),
29 checker_ptr_(checker_ptr),
30 next_move_(next_move) {}
34 std::vector<RobotStateNode>* output_graph)
const {
39 float map_highest_z = -100000;
42 const int map_index_x =
44 const int map_index_y =
46 map_highest_z = map_.
GetTopZ(map_index_x, map_index_y);
51 const Vector3 kCoxaVec = converter_ptr_->ConvertRobotToGlobalCoordinate(
52 presenter_ptr_->GetLegBasePosRobotCoordinate(i),
58 map_highest_z = (std::max)(map_.
GetTopZ(kCoxaX, kCoxaY), map_highest_z);
64 float highest_body_pos_z =
65 map_highest_z + presenter_ptr_->GetGroundHeightMarginMax();
66 float lowest_body_pos_z =
67 map_highest_z + presenter_ptr_->GetGroundHeightMarginMin();
77 const float edge_b = current_node.
leg_pos[i].ProjectedXY().GetLength() -
92 pushNodeByMaxAndMinPosZ(current_node, current_num, highest_body_pos_z,
93 lowest_body_pos_z, output_graph);
96void NodeCreatorComUpDown::pushNodeByMaxAndMinPosZ(
97 const RobotStateNode& current_node,
const int current_num,
const float high,
98 const float low, std::vector<RobotStateNode>* output_graph)
const {
102 const float kDivZ = (high - low) /
static_cast<float>(kDiscretization);
105 for (
int i = 0; i < kDiscretization + 1; ++i) {
106 bool is_valid =
true;
112 new_com.
z = low + kDivZ * i;
117 if (!checker_ptr_->IsLegInRange(j, new_node.
leg_pos[j])) {
127 (*output_graph).emplace_back(new_node);
132 RobotStateNode same_node = current_node;
136 (*output_graph).emplace_back(same_node);
constexpr bool IsInMap(const float x, const float y) const noexcept
指定した座標がマップの範囲内に存在するかどうかを返す.
constexpr int GetDividedMapIndexX(const float pos_x) const noexcept
指定した座標を DividedMap のインデックスに変換する. 範囲外の値を指定した場合でも,値を丸めずに返す. そのため,IsInMap で範囲内に存在するかどうかを確認する必要がある.
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
NodeCreatorComUpDown(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 ¤t_node, int current_num, std::vector< RobotStateNode > *output_graph) const override
現在のノードから次のノード群を生成する.
static constexpr float kFemurLength
第2関節部の長さ[mm].
static constexpr float kCoxaLength
第1関節部の長さ[mm].
static constexpr float kTibiaLength
第3関節部の長さ[mm].
bool IsGrounded(const LegStateBit &leg_state, const int leg_index)
脚番号 leg_index 0 ~ 5 に応じて,その脚が接地しているかを調べる. 脚は右前脚を0番として,時計回りに0,1,2,3,4,5となる.左前足が5番.
constexpr T Squared(const T num) noexcept
2乗した値を返す関数.
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)
重心位置を変更する関数.