-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into main
- Loading branch information
Showing
20 changed files
with
753 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (C) 2024 Christian Brommer, Control of Networked Systems, University of Klagenfurt, Austria. | ||
// | ||
// All rights reserved. | ||
// | ||
// This software is licensed under the terms of the BSD-2-Clause-License with | ||
// no commercial use allowed, the full terms of which are made available | ||
// in the LICENSE file. No license in patents is granted. | ||
// | ||
// You can contact the author at <[email protected]> | ||
|
||
#ifndef READ_VELOCITY_DATA_H | ||
#define READ_VELOCITY_DATA_H | ||
|
||
#include <mars/data_utils/read_csv.h> | ||
#include <mars/sensors/velocity/velocity_measurement_type.h> | ||
#include <mars/time.h> | ||
#include <mars/type_definitions/buffer_data_type.h> | ||
#include <mars/type_definitions/buffer_entry_type.h> | ||
#include <Eigen/Dense> | ||
#include <vector> | ||
|
||
namespace mars | ||
{ | ||
class ReadVelocityData | ||
{ | ||
public: | ||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
|
||
ReadVelocityData(std::vector<BufferEntryType>* data_out, std::shared_ptr<SensorAbsClass> sensor, | ||
const std::string& file_path, const double& time_offset = 0) | ||
{ | ||
std::vector<std::string> expect_entry = { "t", "v_x", "v_y", "v_z" }; | ||
|
||
CsvDataType csv_data; | ||
ReadCsv(&csv_data, file_path); | ||
|
||
unsigned long number_of_datapoints = csv_data["t"].size(); | ||
data_out->resize(number_of_datapoints); | ||
|
||
for (size_t k = 0; k < number_of_datapoints; k++) | ||
{ | ||
Time time = csv_data["t"][k] + time_offset; | ||
Eigen::Vector3d velocity(csv_data["v_x"][k], csv_data["v_y"][k], csv_data["v_z"][k]); | ||
|
||
BufferDataType data; | ||
data.set_sensor_data(std::make_shared<VelocityMeasurementType>(velocity)); | ||
|
||
BufferEntryType current_entry(time, data, sensor, BufferMetadataType::measurement); | ||
data_out->at(k) = current_entry; | ||
} | ||
} | ||
}; | ||
} // namespace mars | ||
|
||
#endif // READ_VELOCITY_DATA_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
source/mars/include/mars/sensors/velocity/velocity_measurement_type.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (C) 2024 Christian Brommer, Control of Networked Systems, University of Klagenfurt, | ||
// Austria. | ||
// | ||
// All rights reserved. | ||
// | ||
// This software is licensed under the terms of the BSD-2-Clause-License with | ||
// no commercial use allowed, the full terms of which are made available | ||
// in the LICENSE file. No license in patents is granted. | ||
// | ||
// You can contact the author at <[email protected]> | ||
|
||
#ifndef VELOCITYMEASUREMENTTYPE_H | ||
#define VELOCITYMEASUREMENTTYPE_H | ||
|
||
#include <mars/sensors/measurement_base_class.h> | ||
#include <Eigen/Dense> | ||
#include <utility> | ||
|
||
namespace mars | ||
{ | ||
class VelocityMeasurementType : public BaseMeas | ||
{ | ||
public: | ||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
|
||
Eigen::Vector3d velocity_; ///< Velocity [x y z] | ||
|
||
VelocityMeasurementType() = default; | ||
|
||
VelocityMeasurementType(Eigen::Vector3d velocity) : velocity_(std::move(velocity)) | ||
{ | ||
} | ||
|
||
static std::string get_csv_state_header_string() | ||
{ | ||
std::stringstream os; | ||
os << "t, "; | ||
os << "v_x, v_y, v_z"; | ||
|
||
return os.str(); | ||
} | ||
|
||
std::string to_csv_string(const double& timestamp) const | ||
{ | ||
std::stringstream os; | ||
os.precision(17); | ||
os << timestamp; | ||
|
||
os << ", " << velocity_.x() << ", " << velocity_.y() << ", " << velocity_.z(); | ||
|
||
return os.str(); | ||
} | ||
}; | ||
} // namespace mars | ||
#endif // VELOCITYMEASUREMENTTYPE_H |
Oops, something went wrong.