GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
graph_search_result_record.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 <sstream>
11
12#include "string_util.h"
13
14
15namespace designlab
16{
17
18std::string GraphSearchResult::ToString() const
19{
21}
22
24{
25 // std::boolalphaを使うと,bool値を文字列に変換できる.
26 // excelにおいて,数値を文字列として扱うためには,
27 // 数値の前にシングルクォーテーション ' をつける必要がある.
28
29 std::stringstream stream;
30
31 stream << "'" << result_node.leg_state.to_string() << ",";
32
33 for (int i = 0; i < HexapodConst::kLegNum; i++)
34 {
35 stream << std::boolalpha << leg_func::IsGrounded(result_node.leg_state, i) << ",";
36 }
37
38 for (int i = 0; i < HexapodConst::kLegNum; i++)
39 {
42 }
43
46
48 stream << result_node.posture << ",";
49
50 for (int i = 0; i < HexapodConst::kLegNum; i++)
51 {
52 stream << result_node.leg_pos[i] << ",";
53 }
54
55 for (int i = 0; i < HexapodConst::kLegNum; i++)
56 {
57 stream << result_node.leg_reference_pos[i] << ",";
58 }
59
62 stream << graph_search_result.ToString();
63
64 return stream.str();
65}
66
68{
69 std::stringstream stream;
70
71 stream << ",";
72 stream << "Leg State Bit,";
73 stream << "Is Grounded, , , , , , ";
74 stream << "Discretized Leg Pos, , , , , , ";
75 stream << "Discretized Com Pos,";
76 stream << "Center of Mass[mm], , ,";
77 stream << "Quaternion, , , ,";
78 stream << "Leg Pos 0[mm], , ,Leg Pos 1[mm], , ,Leg Pos 2[mm], , ,";
79 stream << "Leg Pos 3[mm], , ,Leg Pos 4[mm], , ,Leg Pos 5[mm], , , ";
80 stream << "Reference Pos 0[mm],,,Reference Pos 1[mm],,,Reference Pos 2[mm],,,";
81 stream << "Reference Pos 3[mm],,,Reference Pos 4[mm],,,Reference Pos 5[mm],,,";
82 stream << "Next Move,";
83 stream << "Time[milli sec],";
84 stream << "Graph Search Result" << std::endl;
85
86 stream << ",";
87 stream << ",";
88 stream << "leg0,leg1,leg2,leg3,leg4,leg5,";
89 stream << "leg0,leg1,leg2,leg3,leg4,leg5,";
90 stream << ",";
91 stream << "x,y,z,";
92 stream << "w,v-x,v-y,v-z,";
93 stream << "x,y,z,x,y,z,x,y,z,x,y,z,x,y,z,x,y,z,";
94 stream << "x,y,z,x,y,z,x,y,z,x,y,z,x,y,z,x,y,z,";
95 stream << ",";
96 stream << ",";
97 stream << ",";
98
99 return stream.str();
100}
101
102} // namespace designlab
static constexpr int kLegNum
bool IsGrounded(const LegStateBit &leg_state, const int leg_index)
脚番号 leg_index 0 ~ 5 に応じて,その脚が接地しているかを調べる. 脚は右前脚を0番として,時計回りに0,1,2,3,4,5となる.左前足が5番.
Definition leg_state.cpp:43
enums::DiscreteComPos GetDiscreteComPos(const LegStateBit &leg_state)
現在の脚状態から重心パターンを取得する.
enums::DiscreteLegPos GetDiscreteLegPos(const LegStateBit &leg_state, const int leg_index)
脚状態を取得する.
std::string FloatingPointNumToString(const T num, const int digit=kDigit, const int width=kWidth)
小数を文字列に変換する関数. C++ では C のフォーマットのように %3.3f とかで小数を文字列に変換できないため自作する.
Definition math_util.h:161
std::string EnumToStringRemoveTopK(const T &enum_value)
enumを文字列に変換する関数. Google C++ coding style だと enumの要素は 先頭にkをつけてキャメルケースで書くことが推奨されている. 例えば,
Definition string_util.h:54
std::string message
成功時・失敗時のメッセージ.
enums::Result result
成功か失敗か.
static std::string GetCsvHeader()
CSV形式のヘッダを返す.
GraphSearchResult graph_search_result
グラフ探索の結果,成功か失敗か.
double computation_time
グラフ探索にかかった計算時間 [milli sec]
std::string ToCsvString() const
構造体の内容をCSV形式の文字列にして返す. , (カンマ) で区切られる.
RobotStateNode result_node
グラフ探索によって選択されたノード.
std::array< Vector3, HexapodConst::kLegNum > leg_pos
[4 * 3 * 6 = 72 byte] 脚先の座標.(coxa(脚の付け根)を原点とする)
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