4#include <spdlog/spdlog.h>
5#include <spdlog/sinks/stdout_color_sinks.h>
6#include <spdlog/fmt/ostr.h>
8#include <box2d/box2d.h>
16#define _USE_MATH_DEFINES
19#if defined(__cpp_lib_span) && __cpp_lib_span >= 202002L
21 template<
class T>
using span_t = std::span<const T>;
24 template<
class T>
using span_t =
const std::vector<T>&;
29extern std::shared_ptr<spdlog::logger>
glogger;
34extern std::random_device
rd;
68[[nodiscard]]
constexpr bool contains(
const std::vector<T>& vec,
70 return std::find(vec.begin(), vec.end(), value) != vec.end();
88[[nodiscard]]
constexpr bool all_true(
const std::vector<bool>& flags) {
89 return std::ranges::all_of(flags, [](
bool v) {
return v; });
Class for managing hierarchical configuration parameters.
Definition configuration.h:64
std::shared_ptr< spdlog::logger > robotlogger
Global logger for robot-specific logging.
Definition utils.cpp:13
std::random_device rd
Random device used for seeding the random generator.
Definition utils.cpp:16
std::shared_ptr< spdlog::logger > glogger
Global logger for general logging.
Definition utils.cpp:12
std::string to_lowercase(std::string const &str)
Converts a string to lowercase.
Definition utils.cpp:82
void seed_random_generators(uint32_t seed)
Seed all simulator RNGs from a single seed value.
Definition utils.cpp:19
constexpr bool all_true(const std::vector< bool > &flags)
Check whether every element in a std::vector<bool> is true.
Definition utils.h:88
bool string_to_bool(std::string const &str)
Converts a string to a boolean value.
Definition utils.cpp:67
std::string resolve_path(const std::string &inputPath)
Resolves an input file path to an absolute path.
Definition utils.cpp:137
uint32_t make_random_seed()
Generate a non-deterministic seed value.
Definition utils.cpp:24
void ensure_directories_exist(const std::string &filename)
Ensures that the directory for a given file exists.
Definition utils.cpp:89
const std::vector< T > & span_t
Definition utils.h:24
std::mt19937 rnd_gen
Random number generator seeded with rd.
void delete_files_with_extension(const std::string &path, const std::string &extension, bool recursive=false)
Deletes files with a specified extension in a given directory.
Definition utils.cpp:103
constexpr bool contains(const std::vector< T > &vec, const T &value)
Check whether a vector contains a given value.
Definition utils.h:68
void init_logger(Configuration &config)
Initializes the global loggers.
Definition utils.cpp:29
void loggers_add_file_sink(std::string const &filename)
Adds a file sink to the global loggers.
Definition utils.cpp:53