Skip to content

Commit

Permalink
chore(hesai): lessen log spam, error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Max SCHMELLER <[email protected]>
  • Loading branch information
mojomex committed Oct 29, 2024
1 parent cb93cb3 commit 5cbbe6b
Show file tree
Hide file tree
Showing 8 changed files with 379 additions and 232 deletions.
4 changes: 0 additions & 4 deletions nebula_common/include/nebula_common/hesai/hesai_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,26 +349,22 @@ struct HesaiCorrection : public HesaiCalibrationConfigurationBase
inline nebula::Status save_to_file_from_bytes(
const std::string & correction_file, const std::vector<uint8_t> & buf) override
{
std::cerr << "Saving in: " << correction_file << "\n";
std::ofstream ofs(correction_file, std::ios::trunc | std::ios::binary);
if (!ofs) {
std::cerr << "Could not create file: " << correction_file << "\n";
return Status::CANNOT_SAVE_FILE;
}
std::cerr << "Writing start...." << buf.size() << "\n";
bool sop_received = false;
for (const auto & byte : buf) {
if (!sop_received) {
if (byte == 0xEE) {
std::cerr << "SOP received....\n";
sop_received = true;
}
}
if (sop_received) {
ofs << byte;
}
}
std::cerr << "Closing file\n";
ofs.close();
if (sop_received) return Status::OK;
return Status::INVALID_CALIBRATION_FILE;
Expand Down
19 changes: 19 additions & 0 deletions nebula_common/include/nebula_common/util/string_conversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#pragma once

#include <nlohmann/json.hpp>
#include <nlohmann/json_fwd.hpp>

#include <ostream>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -41,4 +44,20 @@ std::enable_if_t<IsStreamable<T>::value, std::string> to_string(const T & value)
return ss.str();
}

template <size_t N>
std::string to_string(const char value[N])
{
return std::string(value, strnlen(value, N));
}

inline std::string to_string(const nlohmann::ordered_json & j)
{
return j.is_string() ? j.template get<std::string>() : j.dump();
}

inline std::string to_string(const nlohmann::json & j)
{
return to_string(nlohmann::ordered_json(j));
}

} // namespace nebula::util
Loading

0 comments on commit 5cbbe6b

Please sign in to comment.