Skip to content

Commit

Permalink
formatting and clang-tidy fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Timm Ruppert <[email protected]>
  • Loading branch information
TimmRuppert committed Nov 13, 2024
1 parent bb70dc2 commit 880a967
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
9 changes: 4 additions & 5 deletions examples/example_mcap_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "osi_version.pb.h"

std::string GenerateTempFilePath() {
const auto path = std::filesystem::temp_directory_path() / "sv_example.mcap";
const auto path = std::filesystem::temp_directory_path() / "sv_example.mcap"; // add sv to indicate sensor view as required by the OSI-specification
return path.string();
}

Expand All @@ -26,11 +26,10 @@ int main(int argc, const char** argv) {

// add OSI-specification mandatory metadata for the entire trace file
std::unordered_map<std::string, std::string> metadata_entries;
metadata_entries["timestamp"] = trace_file_writer.GetCurrentTimeAsString();
metadata_entries["zero_time"] = trace_file_writer.GetCurrentTimeAsString();
metadata_entries["timestamp"] = osi3::MCAPTraceFileWriter::GetCurrentTimeAsString();
metadata_entries["zero_time"] = osi3::MCAPTraceFileWriter::GetCurrentTimeAsString();
trace_file_writer.SetMetadata("asam_osi", metadata_entries);


// add a channel to store some data
const std::string topic = "Sensor_1_Input";
const std::unordered_map<std::string, std::string> channel_metadata = {{"description", "This channel contains the input data (SensorView) for sensor 1"}};
Expand Down Expand Up @@ -59,7 +58,7 @@ int main(int argc, const char** argv) {
for (int i = 0; i < 10; ++i) {
// manipulate the data so not every message is the same
auto timestamp = sensor_view_1.timestamp().seconds() * 1000000000 + sensor_view_1.timestamp().nanos();
timestamp += kTimeStepSizeS*1000000000;
timestamp += kTimeStepSizeS * 1000000000;
sensor_view_1.mutable_timestamp()->set_nanos(timestamp % 1000000000);
sensor_view_1.mutable_timestamp()->set_seconds(timestamp / 1000000000);
ground_truth_1->mutable_timestamp()->set_nanos(timestamp % 1000000000);
Expand Down
8 changes: 4 additions & 4 deletions examples/example_native_binary_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

std::string GetCurrentTimeAsString() {
const auto now = std::chrono::system_clock::now();
const auto now_in_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
const auto timer = std::chrono::system_clock::to_time_t(now);
const std::tm utc_time_structure = *std::gmtime(&timer); // Greenwich Mean Time (GMT) is in Coordinated Universal Time (UTC) zone
const std::tm utc_time_structure = *std::gmtime(&timer); // Greenwich Mean Time (GMT) is in Coordinated Universal Time (UTC) zone
std::ostringstream oss;
oss << std::put_time(&utc_time_structure, "%Y%m%dT%H%M%S");
oss << "Z"; // As GMT is used as a reference time zone, add Z to indicate UTC (+00:00)
return oss.str();
}

std::string GenerateTempFilePath() {
// create a path which follows the OSI specification recommendation
std::string file_name = GetCurrentTimeAsString();
const auto osi_version = osi3::InterfaceVersion::descriptor()->file()->options().GetExtension(osi3::current_interface_version);
file_name += "_" + std::to_string(osi_version.version_major()) + "." + std::to_string(osi_version.version_minor()) + "." + std::to_string(osi_version.version_patch());
file_name += "_" + google::protobuf::internal::VersionString(GOOGLE_PROTOBUF_VERSION);
file_name += "_10"; // 10 frames
file_name += "_10"; // 10 frames
file_name += "_example-native-binary-writer.osi";
const auto path = std::filesystem::temp_directory_path() / file_name;
return path.string();
Expand Down Expand Up @@ -64,7 +64,7 @@ int main(int argc, const char** argv) {
for (int i = 0; i < 10; ++i) {
// manipulate the data so not every message is the same
auto timestamp = sensor_view.timestamp().seconds() * 1000000000 + sensor_view.timestamp().nanos();
timestamp += kTimeStepSizeS*1000000000; // 100000000;
timestamp += kTimeStepSizeS * 1000000000; // 100000000;
sensor_view.mutable_timestamp()->set_nanos(timestamp % 1000000000);
sensor_view.mutable_timestamp()->set_seconds(timestamp / 1000000000);
ground_truth->mutable_timestamp()->set_nanos(timestamp % 1000000000);
Expand Down
9 changes: 5 additions & 4 deletions examples/example_txth_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// SPDX-License-Identifier: MPL-2.0
//

#include <osi-utilities/tracefile/writer/TXTHTraceFileWriter.h>

#include <filesystem>
Expand All @@ -11,21 +12,21 @@

std::string GetCurrentTimeAsString() {
const auto now = std::chrono::system_clock::now();
const auto now_in_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
const auto timer = std::chrono::system_clock::to_time_t(now);
const std::tm utc_time_structure = *std::gmtime(&timer); // Greenwich Mean Time (GMT) is in Coordinated Universal Time (UTC) zone
const std::tm utc_time_structure = *std::gmtime(&timer); // Greenwich Mean Time (GMT) is in Coordinated Universal Time (UTC) zone
std::ostringstream oss;
oss << std::put_time(&utc_time_structure, "%Y%m%dT%H%M%S");
oss << "Z"; // As GMT is used as a reference time zone, add Z to indicate UTC (+00:00)
return oss.str();
}

std::string GenerateTempFilePath() {
// create a path which follows the OSI specification recommendation
std::string file_name = GetCurrentTimeAsString();
const auto osi_version = osi3::InterfaceVersion::descriptor()->file()->options().GetExtension(osi3::current_interface_version);
file_name += "_" + std::to_string(osi_version.version_major()) + "." + std::to_string(osi_version.version_minor()) + "." + std::to_string(osi_version.version_patch());
file_name += "_" + google::protobuf::internal::VersionString(GOOGLE_PROTOBUF_VERSION);
file_name += "_10"; // 10 frames
file_name += "_10"; // 10 frames
file_name += "_example-txth-writer.txth";
const auto path = std::filesystem::temp_directory_path() / file_name;
return path.string();
Expand Down Expand Up @@ -63,7 +64,7 @@ int main(int argc, const char** argv) {
for (int i = 0; i < 10; ++i) {
// manipulate the data so not every message is the same
auto timestamp = sensor_view.timestamp().seconds() * 1000000000 + sensor_view.timestamp().nanos();
timestamp += kTimeStepSizeS*1000000000;
timestamp += kTimeStepSizeS * 1000000000;
sensor_view.mutable_timestamp()->set_nanos(timestamp % 1000000000);
sensor_view.mutable_timestamp()->set_seconds(timestamp / 1000000000);
ground_truth->mutable_timestamp()->set_nanos(timestamp % 1000000000);
Expand Down

0 comments on commit 880a967

Please sign in to comment.