GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
map_creator_by_csv.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 <format>
11#include <filesystem>
12#include <fstream>
13
14#include "cassert_define.h"
15#include "cmdio_util.h"
16#include "map_file_importer.h"
17#include "string_util.h"
18
19
20
21namespace designlab
22{
23
24MapCreatorByCsv::MapCreatorByCsv(const std::string& map_file_path) : map_file_path_(map_file_path)
25{
26 // ファイルが存在するか確認し,なければアサート.
27 const bool is_exist = std::filesystem::exists(map_file_path_);
28
29 if (!is_exist)
30 {
31 std::string error_mes =
32 std::format("map fileが存在しません.ファイルのパスは{}です.({}のコンストラクタ)",
33 map_file_path_, string_util::GetTypeName(*this));
34
36
37 assert(false);
38 }
39}
40
42{
43 std::optional<MapState> map_state;
44 MapFileImporter map_file_importer;
45
46 map_state = map_file_importer.ImportMap(map_file_path_);
47
48 return map_state.value_or(MapState());
49}
50
51void MapCreatorByCsv::UpdateMap([[maybe_unused]] MapState* current_map)
52{
53 // 何もしない.
54}
55
56} // namespace designlab
static void Output(const std::string &str, OutputDetail detail)
コマンドラインに文字を出力する関数. SetOutputLimit() で設定した出力の許可範囲内であれば出力される. 必ず SetOutputLimit() を呼び出してから使うこと.
void UpdateMap(MapState *current_map) override
マップの更新を行う.
MapState InitMap() override
マップの初期化を行う.
MapCreatorByCsv(const std::string &map_file_path)
コンストラクタで作成するマップ情報を与える
マップを csv に出力したものを読み込むクラス. マップには脚接地可能点が羅列されているので,1行ずつ読み込み,それぞれマップに追加する.
std::optional< MapState > ImportMap(const std::string &file_path) const noexcept
マップを csv に出力したものを読み込む.
マップを表すクラス.
Definition map_state.h:32
std::string GetTypeName(const T &type)
@ kError
エラーメッセージ.