mars_lib  0.1.0.3dc76ee85e09
Modular and Robust Sensor-Fusion
Static Public Member Functions | List of all members
mars::WriteCsv Class Reference

#include </home/runner/work/mars_lib/mars_lib/source/mars/include/mars/data_utils/write_csv.h>

+ Collaboration diagram for mars::WriteCsv:

Static Public Member Functions

static std::string vec_to_csv (const Eigen::VectorXd &a)
 
static std::string cov_mat_to_csv (const Eigen::MatrixXd &cov)
 get_csv_state_with_cov_header_string generate string with state and upper triangular covariance More...
 
static std::string get_cov_header_string (const int &num_states)
 

Member Function Documentation

◆ vec_to_csv()

static std::string mars::WriteCsv::vec_to_csv ( const Eigen::VectorXd &  a)
inlinestatic
24  {
25  std::stringstream os;
26  for (int k = 0; k < a.size(); k++)
27  {
28  os << ", " << a(k);
29  }
30  return os.str();
31  }

◆ cov_mat_to_csv()

static std::string mars::WriteCsv::cov_mat_to_csv ( const Eigen::MatrixXd &  cov)
inlinestatic

get_csv_state_with_cov_header_string generate string with state and upper triangular covariance

Returns
38  {
39  if (cov.rows() != cov.cols())
40  {
41  std::cout << "Cov Mat to CSV: Cov matrix non-squared. No line written." << std::endl;
42  return std::string("");
43  }
44 
45  std::stringstream os;
46  const int num_cov_state = static_cast<int>(cov.rows());
47 
48  for (int k = 0; k < num_cov_state; k++)
49  {
50  int row_count = k * num_cov_state + k;
51  int col_count = num_cov_state - k; // Size relative to row_count
52  os << vec_to_csv(Eigen::Map<const Eigen::VectorXd>(cov.data() + row_count, col_count));
53  }
54 
55  return os.str();
56  }

◆ get_cov_header_string()

static std::string mars::WriteCsv::get_cov_header_string ( const int &  num_states)
inlinestatic
59  {
60  std::stringstream os;
61 
62  const std::string var("p_");
63  for (int row = 1; row <= num_states; row++)
64  {
65  for (int col = row; col <= num_states; col++)
66  {
67  os << ", " << var << row << "_" << col;
68  }
69  }
70 
71  return os.str();
72  }

The documentation for this class was generated from the following file: