GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
map_file_importer.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 "map_file_importer.h"
9
10#include <fstream>
11#include <sstream>
12#include <vector>
13
14#include "cmdio_util.h"
15
16namespace designlab {
17
18using nostd::expected;
19using nostd::unexpected;
20
22 const std::string& file_path) const noexcept {
23 // ファイルを開く.
24 std::ifstream ifs(file_path);
25
26 // ファイルが開けないならば, エラーを返す.
27 if (!ifs.is_open()) {
28 return unexpected("Cannot open file. file name: " + file_path);
29 }
30
31 // ファイルを1行ずつ読み込み,Mapに追加する.
32 std::vector<Vector3> map_point;
33
34 std::string line;
35
36 while (std::getline(ifs, line)) {
37 std::istringstream iss(line);
38
39 try {
40 Vector3 point;
41 iss >> point;
42
43 map_point.push_back(point);
44 } catch (...) {
45 cmdio::Output("読み込むことができないデータがあったため無視します.",
47 }
48 }
49
50 return MapState(map_point);
51}
52
53} // namespace designlab
nostd::expected< MapState, std::string > ImportMap(const std::string &file_path) const noexcept
マップを csv に出力したものを読み込む.
マップを表すクラス.
Definition map_state.h:29
自作の expected クラス
Definition my_expected.h:46
void Output(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. SetOutputLimit 関数で設定した出力の許可範囲内であれば出力される.
@ kWarning
警告メッセージ,エラーではないが注意が必要なメッセージ.
3次元の位置ベクトルを表す構造体.