GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
simulation_map_parameter.h
[詳解]
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#ifndef DESIGNLAB_SIMULATION_MAP_PARAMETER_H_
9#define DESIGNLAB_SIMULATION_MAP_PARAMETER_H_
10
11#include <vector>
12
13#include "cassert_define.h"
14#include "string_util.h"
16
17namespace designlab {
18
21enum class SimulationMapMode : int {
22 kFlat = 0,
26 kMesh,
28 kCircle,
29 kDonut,
30};
31
38enum class SimulationMapOption : unsigned int {
39 // 1 << x は 2^x を表す.
40
41 kNone = 0,
42 kPerforated = 1 << 0,
43 kStep = 1 << 1,
44 kSlope = 1 << 2,
45 kTilt = 1 << 3,
46 kRough = 1 << 4,
47 kRadiation = 1 << 5,
48};
49
53 public:
56 option(static_cast<unsigned int>(SimulationMapOption::kNone)) {}
57
60 constexpr void SetMode(const SimulationMapMode create_mode) {
61 mode = create_mode;
62 }
63
70 void SetOption(const std::vector<SimulationMapOption> create_options) {
71 assert(!create_options.empty());
72
73 for (const auto& i : create_options) {
74 option |= static_cast<unsigned int>(i);
75 }
76 }
77
85 constexpr void SetMapSize(const float max_x, const float min_x,
86 const float max_y, const float min_y,
87 const float start_rough_x, const float map_base_z) {
88 assert(min_x < max_x);
89 assert(min_y < max_y);
90 assert(min_x < start_rough_x);
91 assert(start_rough_x < max_x);
92
93 map_max_x = max_x;
94 map_min_x = min_x;
95 map_max_y = max_y;
96 map_min_y = min_y;
97 map_start_rough_x = start_rough_x;
98 base_z = map_base_z;
99 }
100
101 constexpr void SetStripeInterval(const int interval) {
102 assert(0 < interval);
103
104 stripe_interval = interval;
105 }
106
107 constexpr void SetHoleRate(const int rate) {
108 assert(0 <= rate);
109 assert(rate <= 100);
110
111 hole_rate = rate;
112 }
113
114 constexpr void SetStepValue(const float height, const float length) {
115 assert(0 < length);
116
117 step_height = height;
118 step_length = length;
119 }
120
121 constexpr void SetTiltAngle(const float angle) { tilt_angle = angle; }
122
123 constexpr void SetSlopeAngle(const float angle) { slope_angle = angle; }
124
125 constexpr void SetRouthHeight(const float height_min,
126 const float height_max) {
127 assert(height_min < height_max);
128
129 rough_min_height = height_min;
130 rough_max_height = height_max;
131 }
132
135 unsigned int option{0};
136
137 float base_z{0.0f};
138 float map_max_x{2600.f};
139 float map_min_x{-400.f};
140 float map_max_y{2000.f};
141 float map_min_y{-2000.f};
142 float map_start_rough_x{400.f};
143
146
147 int hole_rate{20};
148 float step_height{100.f};
149 float step_length{600.f};
150 float slope_angle{10.f};
151 float tilt_angle{5.f};
152 float rough_max_height{30.f};
153 float rough_min_height{-30.f};
154
155 Vector3 circle_center{0.f, 0.f, 0.f};
156 float circle_radius{1000.f};
157 float donut_radius{200.f};
158
163};
164
167
169
172 "生成するマップの種類.(\"" +
174 "\")");
177 "マップ生成のオプション.複数指定したいならば足し合わせて指定すること.("
178 " " +
180
182 "マップの基準となるZ座標.");
184 "マップのX座標の最大値.");
186 "マップのX座標の最小値.");
188 "マップのY座標の最大値.");
190 "マップのY座標の最小値.");
191 DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(map_start_rough_x, "Basic",
192 "不整地が始まるX座標.");
193
195 stripe_interval, "Stripe",
196 "各種模様や穴を作成する際,これで指定したマス分(1マス20[mm])の1辺を持つ"
197 "正方形状にあなをあける.0より大きくすること.");
198
200 hole_rate, "Perforated",
201 "不整地上の足場を除外する割合.ホール率[%].0~100の間にすること.");
202
204 step_height, "Step", "段差高さ[mm].負の値にすると下りの階段になる.");
206 step_length, "Step", "階段の奥行[mm].正の値にすること.");
207
209 "斜面の傾斜角[deg].");
210
212 "地形を傾ける角度[deg].");
213
215 rough_max_height, "Rough",
216 "デコボコな地形の最大高さ[mm].最小値より大きい値にすること.");
217 DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(rough_min_height, "Rough",
218 "デコボコな地形の最小高さ[mm]");
219
220 DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(circle_center, "Circle",
221 "円 / ドーナツの中心座標.");
222 DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(circle_radius, "Circle",
223 "円 / ドーナツの半径.");
224 DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(donut_radius, "Circle",
225 "ドーナツの内側の半径.");
226
227 DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(radial_center, "Radial",
228 "放射状の地形の中心座標.");
229 DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(radial_division, "Radial",
230 "放射状の地形の分割数.");
231 DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(radial_hole_rate, "Radial",
232 "放射状の地形のホール率[%].");
234 radial_angle_offset, "Radial", "放射状の地形の角度オフセット[deg].");
235};
236
237} // namespace designlab
238
240 base_z, map_max_x, map_min_x, map_max_y, map_min_y,
241 map_start_rough_x, stripe_interval, hole_rate,
242 step_height, step_length, slope_angle, tilt_angle,
243 rough_max_height, rough_min_height, circle_center,
244 circle_radius, donut_radius, radial_center,
245 radial_division, radial_hole_rate,
246 radial_angle_offset);
247
248#endif // DESIGNLAB_SIMULATION_MAP_PARAMETER_H_
std::string EnumValuesToString(const std::string separator)
enum型を渡すと,その要素を列挙した文字列を返す関数.
Definition string_util.h:72
SimulationMapOption
getMap関数のマップ生成のオプションを指定する列挙体. bit演算を利用して複数指定できる. 例えば穴あきかつ,階段状にしたいならば, MapCreateOption::kPerforated ...
@ kTilt
縦軸を中心軸として回転させた地形に変化させる.
@ kRough
凸凹の地形に変化させる.
@ kRadiation
放射状の地形に変化させる.
@ kPerforated
穴の空いたマップに変化させる.
@ kStep
階段状の地形に変化させる.
@ kSlope
スロープ状の地形に変化させる.
SimulationMapMode
getMap関数のマップ生成のモードを指定する列挙体.
@ kHorizontalStripe
横じまの面を生成する.
@ kVerticalStripe
縦じまの面を生成する.
@ kLatticePoint
格子点の面を生成する.網目状の逆.
@ kFlat
普通の平らな面を生成する.
@ kMesh
格子状の面を生成する.網目状の地形ともいっていい.
@ kDiagonalStripe
斜めじまの面を生成する.
@ kCircle
円形の面を生成する.
@ kDonut
ドーナツ状の面を生成する.
@ kNone
何も動作をしない.
マップ生成時のモードとオプションを指定する構造体.
int radial_hole_rate
放射状の地形のホール率[%].
int radial_division
放射状の地形の分割数.
float map_max_y
マップのY座標の最大値.
int stripe_interval
各種模様や穴を作成する際,これで指定したマス分の1辺を持つ正方形状にあなをあける.
float map_min_x
マップのX座標の最小値.
float map_start_rough_x
不整地が始まるX座標.
constexpr void SetTiltAngle(const float angle)
float circle_radius
円 / ドーナツの半径.
float radial_angle_offset
放射状の地形の角度オフセット[deg].
float map_min_y
マップのY座標の最小値.
constexpr void SetHoleRate(const int rate)
float donut_radius
ドーナツの内側の半径.
constexpr void SetMode(const SimulationMapMode create_mode)
マップ生成のモードを指定する.
unsigned int option
マップ生成のオプションを指定するbit.
Vector2 radial_center
放射状の地形の中心座標.
float step_height
段差高さ[mm].負の値にすると下りの階段になる.
constexpr void SetMapSize(const float max_x, const float min_x, const float max_y, const float min_y, const float start_rough_x, const float map_base_z)
マップの大きさを指定する.
float rough_min_height
デコボコな地形の最小高さ[mm]
float map_max_x
マップのX座標の最大値.
float slope_angle
斜面の傾斜角[deg]
float rough_max_height
デコボコな地形の最大高さ[mm]
float tilt_angle
地形を傾ける角度[deg]
constexpr void SetStripeInterval(const int interval)
float base_z
マップの基準となるZ座標.
constexpr void SetSlopeAngle(const float angle)
Vector3 circle_center
円 / ドーナツの中心座標.
constexpr void SetStepValue(const float height, const float length)
int hole_rate
不整地上の足場を除外する割合。ホール率[%]
void SetOption(const std::vector< SimulationMapOption > create_options)
マップ生成のオプションを指定する. この関数を呼んだあと,その他のSet~関数を呼ぶと,段差の高さや,傾斜角を指定できる.
constexpr void SetRouthHeight(const float height_min, const float height_max)
マップ生成のモードを指定する列挙体.
2次元の位置ベクトルを表す構造体.
3次元の位置ベクトルを表す構造体.
#define DESIGNLAB_TOML11_SERIALIZE(NAME,...)
tomlファイルのシリアライズ/デシリアライズを行うためのマクロ. TOML11_DEFINE_CONVERSION_NON_INTRUSIVEをラッパしたもの....
#define DESIGNLAB_TOML11_NO_TABLE
tomlファイルに追加する変数をテーブルに追加しないことを示すためのマクロ.
#define DESIGNLAB_TOML11_DESCRIPTION_CLASS(CLASS)
tomlファイルに説明を追加するためのクラスの宣言を行うためのマクロ.
#define DESIGNLAB_TOML11_FILE_NO_DESCRIPTION()
tomlファイルにファイルの説明を追加しないことを示す文字列. DESIGNLAB_TOML11_DESCRIPTION_CLASS内に必ず記述する必要がある.
#define DESIGNLAB_TOML11_TABLE_NO_DESCRIPTION()
tomlファイルに追加するテーブルにコメントを追加しないことを示すマクロ. DESIGNLAB_TOML11_DESCRIPTION_CLASS内に必ず記述する必要がある.
#define DESIGNLAB_TOML11_VARIABLE_ADD_DESCRIPTION(VARIABLE, TABLE, DESCRIPTION)
tomlファイルに変数とファイルの説明を追加するためのマクロ.