44 const std::shared_ptr<const IHexapodCoordinateConverter>& converter_ptr,
56 converter_ptr->ConvertLegToRobotCoordinate(
leg_pos[i], i);
58 leg_pos[i] = converter_ptr->ConvertRobotToLegCoordinate(leg_pos_robot_coord, i);
60 Vector3 leg_reference_pos_robot_coord =
62 leg_reference_pos_robot_coord =
65 converter_ptr->ConvertRobotToLegCoordinate(leg_reference_pos_robot_coord, i);
77 res +=
"Leg State Bit : " +
leg_state.to_string() +
"\n";
83 "(" + std::to_string(
static_cast<int>(com)) +
")\n";
96 res +=
"Hierarchy : ";
102 "(" + std::to_string(
static_cast<int>(dis_leg_pos)) +
") ";
108 res +=
"Leg Position : \n";
112 res +=
" " + std::to_string(i) +
":" +
leg_pos[i].ToString() +
"\n";
115 res +=
"Leg Base Position : \n";
132 res +=
"(Depth : " + std::to_string(
depth) + std::string(
")\n");
133 res +=
"(parent number : " + std::to_string(
parent_index) + std::string(
")\n");
140 std::stringstream ss;
157 res.
leg_state = std::bitset<leg_func::kLegStateBitNum>(data[cnt++]);
163 Vector3{ std::stof(data[cnt++]), std::stof(data[cnt++]), std::stof(data[cnt++]) };
170 Vector3{ std::stof(data[cnt++]), std::stof(data[cnt++]), std::stof(data[cnt++]) };
175 Vector3{ std::stof(data[cnt++]), std::stof(data[cnt++]), std::stof(data[cnt++]) };
180 std::stof(data[cnt++]), std::stof(data[cnt++]), std::stof(data[cnt++]) };
183 res.
next_move = magic_enum::enum_cast<HexapodMove>(data[cnt++]).value();
189 res.
depth = std::stoi(data[cnt++]);
static constexpr int kLegNum
DiscreteLegPos
離散化された脚位置を表す列挙体. 先行研究では 1~7の int型の数値で表現されているが, 可読性を上げるために列挙体にした. 離散化された脚位置は 3bit (0 ~ 7)の範囲で表現される...
bool IsGrounded(const LegStateBit &leg_state, const int leg_index)
脚番号 leg_index 0 ~ 5 に応じて,その脚が接地しているかを調べる. 脚は右前脚を0番として,時計回りに0,1,2,3,4,5となる.左前足が5番.
enums::DiscreteComPos GetDiscreteComPos(const LegStateBit &leg_state)
現在の脚状態から重心パターンを取得する.
enums::DiscreteLegPos GetDiscreteLegPos(const LegStateBit &leg_state, const int leg_index)
脚状態を取得する.
std::vector< std::string > Split(const std::string &str, const std::string &separator)
文字列を分割する関数.指定した文字で文字列を分割する. 分割した結果,空白が含まれる場合や文字列がない場合は,そのまま返す. 最後が区切り文字で終わる場合は,それを無視する.
std::string EnumToStringRemoveTopK(const T &enum_value)
enumを文字列に変換する関数. Google C++ coding style だと enumの要素は 先頭にkをつけてキャメルケースで書くことが推奨されている. 例えば,
Vector3 RotateVector3(const Vector3 &vec, const EulerXYZ &rot)
回転させたベクトルを返す.三角関数の処理が多く重たいので注意.
std::string ToString() const
クォータニオンを文字列に変換する. w, x, y, z の順で出力する.
constexpr Quaternion GetConjugate() const noexcept
クォータニオンの共役を返す. 共役なクォータニオンとは,ベクトル成分の符号を反転させたもの q = w + xi + yj + zk とすると, qの共役は w - xi - yj - zk となる...
グラフ構造のためのノード(頂点).旧名 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.
std::string ToCsvString() const
ノードの情報を csv形式の文字列に変換する関数. カンマ区切りで出力する.
static RobotStateNode FromString(const std::string &str)
文字列をノードの情報に変換する関数.
void ChangePosture(const std::shared_ptr< const IHexapodCoordinateConverter > &converter_ptr, const designlab::Quaternion &new_posture)
クォータニオンを変更し,胴体を回転させる関数.
Vector3 center_of_mass_global_coord
[4 * 3 = 12byte] グローバル座標系における重心の位置.旧名 GCOM
std::string ToString() const
ノードの情報を文字列に変換する関数. デバッグ用に詳細な情報を出力する.
Quaternion posture
[4 * 4 = 16byte] 姿勢を表すクォータニオン.
std::array< Vector3, HexapodConst::kLegNum > leg_reference_pos
int depth
[4 byte] 自身の深さ.一番上の親が深さ0となる.
std::string ToString() const
このベクトルを文字列にして返す. (x, y, z) の形式,小数点以下3桁まで.