From c1fa4ec707fe1c05d91593af880d270574d22ee5 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 3 Feb 2025 17:46:02 -0500 Subject: [PATCH] City10000 header file --- examples/City10000.h | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 examples/City10000.h diff --git a/examples/City10000.h b/examples/City10000.h new file mode 100644 index 000000000..84ef6b4c5 --- /dev/null +++ b/examples/City10000.h @@ -0,0 +1,67 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010-2020, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file City10000.h + * @brief Class for City10000 dataset + * @author Varun Agrawal + * @date February 3, 2025 + */ + +#include + +#include +#include +#include + +using namespace gtsam; +using namespace boost::algorithm; + +class City10000Dataset { + std::ifstream in_; + + public: + City10000Dataset(const std::string& filename) : in_(filename) { + if (!in_.is_open()) { + std::cerr << "Failed to open file: " << filename << std::endl; + } + } + + /// Parse line from file + std::pair, std::pair> parseLine( + const std::string& line) const { + std::vector parts; + split(parts, line, is_any_of(" ")); + + size_t keyS = stoi(parts[1]); + size_t keyT = stoi(parts[3]); + + int numMeasurements = stoi(parts[5]); + std::vector poseArray(numMeasurements); + for (int i = 0; i < numMeasurements; ++i) { + double x = stod(parts[6 + 3 * i]); + double y = stod(parts[7 + 3 * i]); + double rad = stod(parts[8 + 3 * i]); + poseArray[i] = Pose2(x, y, rad); + } + return {poseArray, {keyS, keyT}}; + } + + /// Read and parse the next line. + bool next(std::vector* poseArray, std::pair* keys) { + std::string line; + if (getline(in_, line)) { + std::tie(*poseArray, *keys) = parseLine(line); + return true; + } else + return false; + } +}; \ No newline at end of file