diff --git a/.clang-tidy b/.clang-tidy index fbc3eddc..6be3161b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -29,10 +29,7 @@ Checks: '-*, cppcoreguidelines-*, clang-analyzer-*, google-*, - -google-runtime-references, - -google-readability-todo, hicpp-*, - -hicpp-uppercase-literal-suffix, -hicpp-avoid-c-arrays, # duplicates cppcoreguidelines-avoid-c-arrays, -hicpp-no-array-decay, # duplicates cppcoreguidelines-pro-bounds-array-to-pointer-decay, -hicpp-special-member-functions, # duplicates cppcoreguidelines-special-member-functions, @@ -44,13 +41,6 @@ Checks: '-*, performance-*, -performance-move-const-arg, # duplicates hicpp-move-const-arg readability-*, - -readability-uppercase-literal-suffix, - -readability-simplify-boolean-expr, - -readability-magic-numbers, - -readability-function-cognitive-complexity, - -readability-redundant-access-specifiers, - -readability-identifier-length, - -readability-braces-around-statements ' # Upgrade warnings to errors diff --git a/docs/02_roadmap.md b/docs/02_roadmap.md index 372b040b..b97e3a6f 100644 --- a/docs/02_roadmap.md +++ b/docs/02_roadmap.md @@ -1,80 +1,65 @@ # Roadmap -## Phase 1 - Base +## Completed -- :done: Versioning -- :done: Exception definitions -- :done: Command line flags parsing -- :done: Logging library -- :done: Scripting library -- :done: Message passing -- :done: Realtime services +- Versioning +- Exception definitions +- Command line flags parsing +- Logging library +- Scripting library +- Message passing +- Realtime services +- Serialization -## Phase 2 - Multimodal data logging and visualisation - part 1 +## TODO -- :done: Implement `probe::Controller` -- :done: Implement `probe::Monitor` PoC -- :done: Serialization - -## Phase 3 - grapecam +### grapecam - Implement grape::app. ([README](../modules/common/app/README.md)) - Implement [grapecam](https://github.com/cvilas/grapecam) -## Phase 4 - Multimodel data logging and visualisation - part 2 - -- Generic plotting api - - Requirements analysis - - Implement PoC with [Qt6 Graphs](https://doc.qt.io/qt-6/qtgraphs-index.html) +### Plotting + +- Requirements analysis +- Generic plotting API and `plottable`concept +- Implement PoC with [Qt6 Graphs](https://doc.qt.io/qt-6/qtgraphs-index.html) + +### Generalise IPC API + +- Implement queryable/query API +- Avoid copy in createDataCallback() by using SpliceIterator +- Implement liveliness API +- Implement shared memory API +- Implement caching API +- Define topics for matched example programs in a single place +- Consider implementing pub-sub match callbacks +- Implement PutOptions and subscriber Sample fields + - Support attachments + - Support timestamping + - Resolve how we can combine congestion control, priority and reliability settings in a coherent way to offer fewer choices at the user API layer? + - See [discord](https://discord.com/channels/914168414178779197/940584045287460885/1311629493445853206) + - Consider supporting sample kind (put/delete) +- Understand the point of on_drop callback in subscriber and support it if necessary +- Documentation cleanup: examples +- Understand hybrid logical clocks +- Support hybrid logical clocks implementation - Disk recording and playback for time-series multi-modal data ([README](../modules/common/recorder/README.md)) - -## Phase 5 - Generalise IPC API - -- :done: Phase 1: Basic implementation of Session, Publisher, Subscriber -- :done: Phase 2: router, client, throughput and latency examples -- Phase 3 - - Implement queryable/query API - - Avoid copy in createDataCallback() by using SpliceIterator - - Implement liveliness API - - Implement shared memory API - - Implement caching API - - Define topics for matched examples in a single place - - Raise MR -- Phase 4 - - Convert 'router' to a IPC application (hide zenoh internal details) - - Consider implementing match callbacks - - Implement PutOptions and subscriber Sample fields - - Support attachments - - Support timestamping - - Resolve how we can combine congestion control, priority and reliability settings in a coherent way to offer fewer choices at the user API layer? - - See [discord](https://discord.com/channels/914168414178779197/940584045287460885/1311629493445853206) - - Consider supporting sample kind (put/delete) - - Understand the point of on_drop callback in subscriber and support it if necessary - - Documentation cleanup - - Understand hybrid logical clocks - - Support hybrid logical clocks implementation - - Unit tests - - Lua utilities: hostname - Fix zenoh examples: pull, shm pub/sub - New zenoh examples: Router interceptors (downsampling), authentication, access control, serdes (ZBytes) -- PoC IPC experiments - - Case 1: pub-peer on PC1, sub-peer on PC2, router on PC3, multicast scouting off. Confirm data transfer from PC1 to PC2, no data transfer through PC3. - - Case 2: pub-peer + router on PC1, sub-peer + router on PC2, router on PC3, multicast scouting off. Confirm data transfer from PC1 to PC2, no data transfer through PC3. - - Case 3: Extend case2 by adding a PC4 with router and sub-client. Confirm sub-client on PC4 receives data from pub-peer on PC1. -## Phase 6 - Robotics core +### Robotics core +- HW IO + - CANopen + - joystick + - midi - Configure Raspberry Pi5 for [low latency](https://ubuntu.com/blog/real-time-kernel-tuning). Document it. - Study - [Robotics at compile time](https://youtu.be/Y6AUsB3RUhA) - - [reflect-cpp](https://github.com/getml/reflect-cpp) + - [cactus-rt](https://github.com/cactusdynamics/cactus-rt/) on ROS2 interop - Shared memory - Single producer multiple consumer queue using externally specified memory (heap or shared memory) - Consider removing `MPSCQueue`. It's unused. Rename `FIFOBuffer` to `MPSCQueue` -- HW IO - - CANopen - - joystick - - midi - Math library - Delay line - Low pass filter @@ -82,13 +67,14 @@ - Integrator - Matrix operations - Behaviour trees: Consider building from first principles -- FSM: introspectable, visualise state transition graph using graphviz. +- FSM: introspectable, visualisable state transition graph using graphviz. - Introduce [RTSan](https://clang.llvm.org/docs/RealtimeSanitizer.html) -- ROS2 interop - - Study how [cactus-rt](https://github.com/cactusdynamics/cactus-rt/) does it - - Propose a design +- Refactor thread class out of realtime and put it in 'grape' + - Insert logging to capture timer overruns in the loop +- `reinterpret_cast` from `const T*` and then modifying it later is undefined behaviour. Fix `probe::PinConfig::pin`. Consider `std::start_lifetime_as` instead. +- replace `grape::realtime::SystemError` with `std::errc` -## Phase 7 - 3D graphics +### 3D visualisation - Study - [2D Game Engine](https://pikuma.com/courses/cpp-2d-game-engine-development) @@ -106,17 +92,11 @@ - Implement PoC using Qt3D. See [scratch](https://github.com/cvilas/scratch)/3dvis/qt - Implement a basic scenegraph example and check performance in MacOS and Linux -## Phase 8 - Refactor - -- Support external dependencies on examples and tests that the main project does not depend on -- Study [Quill](https://github.com/odygrd/quill) on how to reduce logging overhead -- Refactor thread class out of realtime and put it in 'grape' - - Insert logging to capture timer overruns in the loop -- `reinterpret_cast` from `const T*` and then modifying it later is undefined behaviour. Fix `probe::PinConfig::pin`. Consider `std::start_lifetime_as` instead. -- replace `grape::realtime::SystemError` with `std::errc` - -## Phase 9 - CI +### CI and build robustness +- Fix GCC builds + - `std::expected` not available with -DENABLE_LINTER=ON + - sccache breaks build with -DENABLE_CACHE=ON - Setup configuration presets for developer and CI builds - Incorporate lessons from https://youtu.be/UI_QayAb9U0 - Fail the CI if clang-format changes code @@ -124,45 +104,20 @@ - Develop github CI build file - Document the usage in install instructions - Implement CI build using github workflow -- Integrate cpack to generate artifacts +- Integrate cpack to generate artifacts - Integrate [ninjatracing](https://github.com/nico/ninjatracing) -- Review all negated checks in `.clang-tidy` -## Phase 10 - Demo applications +### Demo applications - Office environment (CO2, temperature, light) dashboard -- Network camera and viewer for industrial monitoring, diagnostics +- Network camera and viewer for industrial monitoring - Zenoh interop with C++ publisher and Python subscriber, demonstrating data serialisation/deserialisation +- Improvements to `probe::Monitor` (See TODO in [README](../modules/probe/monitor/README.md)) - [MuJoCoPy Bootcamp](https://pab47.github.io/mujocopy.html) LQR sim from lesson 13, demonstrating integration of MujoCo, plotting and control - [Rover](https://github.com/nasa-jpl/open-source-rover) demonstrating joystick teleop, FPV and mission control - -## Phase 11 - Utilities - -- utility: hostaddress, isportinuse, execute, flag_set -- file cache -- md5sum -- factory using crtp (see scratch) - -## Others - - Implement advanced streaming - Choose backend for audio/video device handling and stream processing - Implement AV streaming server and client -- External deps: Replace git clone with direct download of tarballs -- Improvements to `probe::Monitor` (See TODO in [README](../modules/probe/monitor/README.md)) - -## Notes - -- Use C++23 or newer features in development - -```c++ -// hello world in C++23 -import std; -auto main() -> int { - std::println("Hello World!"); - return EXIT_SUCCESS; -} -``` ## References @@ -172,4 +127,3 @@ auto main() -> int { - Practical [C++26 Reflection](https://youtu.be/cqQ7v6xdZRw) - Interfaces with C++20 concept: - Clean code: -- IoC containers for dependency injection, especially for mocking in tests: . For why we should use it, see `clean code` video above diff --git a/modules/common/base/src/exception.cpp b/modules/common/base/src/exception.cpp index af3cf4e6..4f3aab2c 100644 --- a/modules/common/base/src/exception.cpp +++ b/modules/common/base/src/exception.cpp @@ -25,7 +25,7 @@ void Exception::print() noexcept { loc.function_name(), // static_cast(loc_fname.length()), loc_fname.data(), loc.line()); std::ignore = fprintf(stderr, "\nBacktrace:"); - auto i = 0u; + auto i = 0U; for (const auto& s : ex.trace().trace()) { std::ignore = fprintf(stderr, "\n#%u: %s", i++, s.c_str()); } diff --git a/modules/common/ipc/examples/liveliness_get.cpp b/modules/common/ipc/examples/liveliness_get.cpp index 088d3876..5094e78a 100644 --- a/modules/common/ipc/examples/liveliness_get.cpp +++ b/modules/common/ipc/examples/liveliness_get.cpp @@ -41,7 +41,7 @@ auto main(int argc, const char* argv[]) -> int { const auto key = args.getOptionOrThrow("key"); std::println("Sending liveliness query for '{}'...", key); - static constexpr auto FIFO_LENGTH = 16u; + static constexpr auto FIFO_LENGTH = 16U; auto replies = session.liveliness_get(key, zenoh::channels::FifoChannel(FIFO_LENGTH)); for (auto res = replies.recv(); std::holds_alternative(res); diff --git a/modules/common/ipc/examples/pub_shm.cpp b/modules/common/ipc/examples/pub_shm.cpp index 21ee5d9a..2fbe474e 100644 --- a/modules/common/ipc/examples/pub_shm.cpp +++ b/modules/common/ipc/examples/pub_shm.cpp @@ -44,7 +44,7 @@ auto main(int argc, const char* argv[]) -> int { auto config = zenoh::Config::create_default(); //----------------------------------------- - // TODO: Review and confirm shared memory configuration is correct + // TODO(vilas): Review and confirm shared memory configuration is correct //----------------------------------------- // Enable the publisher to operate over shared-memory. Note that shared-memory should also be @@ -67,8 +67,8 @@ auto main(int argc, const char* argv[]) -> int { auto pub = session.declare_publisher(key); std::println("Creating shared-memory manager..."); - static constexpr auto SHM_SIZE = 65536u; - static constexpr auto SHM_ALIGN = 2u; + static constexpr auto SHM_SIZE = 65536U; + static constexpr auto SHM_ALIGN = 2U; auto shm_provider = zenoh::PosixShmProvider( zenoh::MemoryLayout(SHM_SIZE, zenoh::AllocAlignment({ SHM_ALIGN }))); diff --git a/modules/common/ipc/examples/sub_shm.cpp b/modules/common/ipc/examples/sub_shm.cpp index 8bf13421..0253815c 100644 --- a/modules/common/ipc/examples/sub_shm.cpp +++ b/modules/common/ipc/examples/sub_shm.cpp @@ -41,7 +41,7 @@ auto main(int argc, const char* argv[]) -> int { auto config = zenoh::Config::create_default(); //----------------------------------------- - // TODO: Review and confirm shared memory configuration is correct + // TODO(vilas): Review and confirm shared memory configuration is correct //----------------------------------------- // Enable shared-memory on the subscriber to take advantage of publishers on the same host who diff --git a/modules/common/ipc/include/grape/ipc/common.h b/modules/common/ipc/include/grape/ipc/common.h index a71104f8..83cd41f3 100644 --- a/modules/common/ipc/include/grape/ipc/common.h +++ b/modules/common/ipc/include/grape/ipc/common.h @@ -39,7 +39,7 @@ struct [[nodiscard]] Locator { //================================================================================================= /// Unique identifier struct [[nodiscard]] UUID { - static constexpr auto LENGTH = 16u; + static constexpr auto LENGTH = 16U; std::array bytes; }; diff --git a/modules/common/ipc/src/session.cpp b/modules/common/ipc/src/session.cpp index a2d80047..ea7d6834 100644 --- a/modules/common/ipc/src/session.cpp +++ b/modules/common/ipc/src/session.cpp @@ -20,7 +20,7 @@ auto transform(const grape::ipc::Session::Config& config) -> zenoh::Config { if (is_router_specified) { zconfig.insert_json5(Z_CONFIG_CONNECT_KEY, std::format(R"(["{}"])", toString(*config.router))); } - // TODO: + // TODO(vilas): //- enable timestamp (optional) //- enable cache history (optional) //- enable shared memory (optional) @@ -46,7 +46,7 @@ auto createDataCallback(grape::ipc::DataCallback&& user_cb) return nullptr; } return [cb = std::move(user_cb)](const zenoh::Sample& sample) -> void { - // TODO: Avoid copy. use SpliceIterator instead + // TODO(vilas): Avoid copy. use SpliceIterator instead const auto data = sample.get_payload().as_vector(); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) cb({ reinterpret_cast(data.data()), data.size() }); diff --git a/modules/common/log/include/grape/log/config.h b/modules/common/log/include/grape/log/config.h index 8da61350..6ae389ac 100644 --- a/modules/common/log/include/grape/log/config.h +++ b/modules/common/log/include/grape/log/config.h @@ -12,7 +12,7 @@ namespace grape::log { /// @brief Logger configuration struct Config { - static constexpr auto DEFAULT_QUEUE_CAPACITY = 1000u; + static constexpr auto DEFAULT_QUEUE_CAPACITY = 1000U; static constexpr auto DEFAULT_FLUSH_PERIOD = std::chrono::microseconds(1000); using Sink = std::function; diff --git a/modules/common/log/tests/tests.cpp b/modules/common/log/tests/tests.cpp index 469694f8..ba94a0bd 100644 --- a/modules/common/log/tests/tests.cpp +++ b/modules/common/log/tests/tests.cpp @@ -14,7 +14,7 @@ namespace { TEST_CASE("Basic logging api works", "[log]") { std::string stream; - static constexpr auto QUEUE_CAPACITY = 10u; + static constexpr auto QUEUE_CAPACITY = 10U; auto config = grape::log::Config(); config.threshold = grape::log::Severity::Debug; @@ -26,7 +26,7 @@ TEST_CASE("Basic logging api works", "[log]") { auto logger = grape::log::Logger(std::move(config)); /// Explicitly specify variadic template arguments types list - grape::log::Log(logger, grape::log::Severity::Info, "{} {}", 5, 3.14f, + grape::log::Log(logger, grape::log::Severity::Info, "{} {}", 5, 3.14F, std::source_location::current()); /// Use the deduction guide for arguments with defaulted source location @@ -36,7 +36,7 @@ TEST_CASE("Basic logging api works", "[log]") { //------------------------------------------------------------------------------------------------- TEST_CASE("Custom sink and threshold settings are respected", "[log]") { std::string stream; - static constexpr auto QUEUE_CAPACITY = 10u; + static constexpr auto QUEUE_CAPACITY = 10U; auto config = grape::log::Config(); config.threshold = grape::log::Severity::Note; @@ -60,7 +60,7 @@ TEST_CASE("Queue capacity and flush period are respected", "[log]") { using namespace std::chrono_literals; static constexpr auto FLUSH_PERIOD = 1s; static constexpr auto FLUSH_WAIT_PERIOD = FLUSH_PERIOD + 500ms; - static constexpr auto QUEUE_CAPACITY = 5u; + static constexpr auto QUEUE_CAPACITY = 5U; std::atomic_size_t num_logs{ 0 }; auto config = grape::log::Config(); config.threshold = grape::log::Severity::Debug; diff --git a/modules/common/realtime/examples/schedule_example.cpp b/modules/common/realtime/examples/schedule_example.cpp index 5b85902e..1cf86b42 100644 --- a/modules/common/realtime/examples/schedule_example.cpp +++ b/modules/common/realtime/examples/schedule_example.cpp @@ -11,7 +11,7 @@ //================================================================================================= auto main() -> int { try { - static constexpr auto CPUS = { 1u, 2u, 3u }; + static constexpr auto CPUS = { 1U, 2U, 3U }; // Set CPU affinity const auto is_cpu_set = grape::realtime::setCpuAffinity(CPUS); diff --git a/modules/common/realtime/examples/thread_example.cpp b/modules/common/realtime/examples/thread_example.cpp index 117f817a..69983113 100644 --- a/modules/common/realtime/examples/thread_example.cpp +++ b/modules/common/realtime/examples/thread_example.cpp @@ -70,8 +70,8 @@ auto main() -> int { // Define CPU cores to allocate to non-rt and rt threads. Ideally these should be // non-intersecting sets. - static constexpr auto CPUS_RT = { 0u }; - static constexpr auto CPUS_NON_RT = { 1u, 2u, 3u }; + static constexpr auto CPUS_RT = { 0U }; + static constexpr auto CPUS_NON_RT = { 1U, 2U, 3U }; // Set main thread CPU affinity here. Will assign rt thread CPU affinity in task setup(). const auto is_main_cpu_set = grape::realtime::setCpuAffinity(CPUS_NON_RT); diff --git a/modules/common/realtime/include/grape/realtime/mpsc_queue.h b/modules/common/realtime/include/grape/realtime/mpsc_queue.h index a55374b4..6a830165 100644 --- a/modules/common/realtime/include/grape/realtime/mpsc_queue.h +++ b/modules/common/realtime/include/grape/realtime/mpsc_queue.h @@ -49,7 +49,7 @@ class MPSCQueue { //------------------------------------------------------------------------------------------------- template -MPSCQueue::MPSCQueue(std::size_t capacity) : items_((capacity > 0 ? capacity : 1u)) { +MPSCQueue::MPSCQueue(std::size_t capacity) : items_((capacity > 0 ? capacity : 1U)) { } //------------------------------------------------------------------------------------------------- diff --git a/modules/common/realtime/tests/mpscq_tests.cpp b/modules/common/realtime/tests/mpscq_tests.cpp index c980932c..17737d22 100644 --- a/modules/common/realtime/tests/mpscq_tests.cpp +++ b/modules/common/realtime/tests/mpscq_tests.cpp @@ -18,7 +18,7 @@ TEST_CASE("Basline single producer and single consumer case", "[mpsc_queue]") { REQUIRE(queue.tryPush(2)); REQUIRE(queue.tryPush(3)); - REQUIRE(queue.count() == 3u); + REQUIRE(queue.count() == 3U); // NOLINTBEGIN(bugprone-unchecked-optional-access) REQUIRE(queue.tryPop().value() == 1); @@ -26,7 +26,7 @@ TEST_CASE("Basline single producer and single consumer case", "[mpsc_queue]") { REQUIRE(queue.tryPop().value() == 3); // NOLINTEND(bugprone-unchecked-optional-access) - REQUIRE(queue.count() == 0u); + REQUIRE(queue.count() == 0U); } //------------------------------------------------------------------------------------------------- diff --git a/modules/common/serdes/examples/advanced_example.cpp b/modules/common/serdes/examples/advanced_example.cpp index 5d8f3696..1b22944c 100644 --- a/modules/common/serdes/examples/advanced_example.cpp +++ b/modules/common/serdes/examples/advanced_example.cpp @@ -33,7 +33,7 @@ auto main(int argc, const char* argv[]) -> int { (void)argc; (void)argv; - constexpr auto BUF_SIZE = 1024u; + constexpr auto BUF_SIZE = 1024U; using OutStream = grape::serdes::OutStream; using InStream = grape::serdes::InStream; using Serialiser = grape::serdes::Serialiser; diff --git a/modules/common/serdes/examples/bench.cpp b/modules/common/serdes/examples/bench.cpp index 6a8db2f0..164f6734 100644 --- a/modules/common/serdes/examples/bench.cpp +++ b/modules/common/serdes/examples/bench.cpp @@ -11,7 +11,7 @@ namespace { -constexpr auto BUFFER_INIT_SIZE = 1024u; +constexpr auto BUFFER_INIT_SIZE = 1024U; //------------------------------------------------------------------------------------------------- void bmSerialize(benchmark::State& state) { diff --git a/modules/common/serdes/examples/example.cpp b/modules/common/serdes/examples/example.cpp index c00c10ed..fe09a49a 100644 --- a/modules/common/serdes/examples/example.cpp +++ b/modules/common/serdes/examples/example.cpp @@ -55,7 +55,7 @@ auto readFromFile(const std::string& filename) -> std::optional; using InStream = grape::serdes::InStream; using Serialiser = grape::serdes::Serialiser; diff --git a/modules/common/serdes/include/grape/serdes/serdes.h b/modules/common/serdes/include/grape/serdes/serdes.h index 23179750..384ab99d 100644 --- a/modules/common/serdes/include/grape/serdes/serdes.h +++ b/modules/common/serdes/include/grape/serdes/serdes.h @@ -43,7 +43,7 @@ class Serialiser { template [[nodiscard]] auto pack(const T& value) -> bool { - return pack(std::span{ &value, 1u }); + return pack(std::span{ &value, 1U }); } template @@ -103,7 +103,7 @@ class Deserialiser { template [[nodiscard]] auto unpack(T& value) -> bool { - return unpack(std::span{ &value, 1u }); + return unpack(std::span{ &value, 1U }); } template diff --git a/modules/common/serdes/include/grape/serdes/stream.h b/modules/common/serdes/include/grape/serdes/stream.h index 679baceb..9fa70a04 100644 --- a/modules/common/serdes/include/grape/serdes/stream.h +++ b/modules/common/serdes/include/grape/serdes/stream.h @@ -50,12 +50,12 @@ class OutStream { /// Set next writing position to 'n' bytes behind the current positon void rewind(std::size_t n) { - offset_ = (n < offset_) ? (offset_ - n) : 0u; + offset_ = (n < offset_) ? (offset_ - n) : 0U; } /// Reset next writing position to the beginning of the stream buffer void reset() { - offset_ = 0u; + offset_ = 0U; } private: @@ -93,12 +93,12 @@ class InStream { /// Set next reading position to 'n' bytes behind the current positon void rewind(std::size_t n) { - offset_ = (n < offset_) ? (offset_ - n) : 0u; + offset_ = (n < offset_) ? (offset_ - n) : 0U; } /// Reset next reading position to the beginning of the stream buffer void reset() { - offset_ = 0u; + offset_ = 0U; } private: diff --git a/modules/common/serdes/tests/serdes_tests.cpp b/modules/common/serdes/tests/serdes_tests.cpp index 93e64c5d..6ea6f076 100644 --- a/modules/common/serdes/tests/serdes_tests.cpp +++ b/modules/common/serdes/tests/serdes_tests.cpp @@ -11,7 +11,7 @@ namespace { // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers) -constexpr auto BUF_SIZE = 1024u; +constexpr auto BUF_SIZE = 1024U; //------------------------------------------------------------------------------------------------- TEST_CASE("Serialize arithmetic types", "[serdes]") { @@ -22,7 +22,7 @@ TEST_CASE("Serialize arithmetic types", "[serdes]") { REQUIRE(ser.pack(std::uint16_t{ 1000 })); REQUIRE(ser.pack(std::int32_t{ -123456 })); REQUIRE(ser.pack(std::uint64_t{ 9876543210 })); - REQUIRE(ser.pack(float{ 3.14f })); + REQUIRE(ser.pack(float{ 3.14F })); REQUIRE(ser.pack(double{ 2.71828 })); REQUIRE(ostream.size() == sizeof(std::int8_t) + sizeof(std::uint16_t) + sizeof(std::int32_t) + sizeof(std::uint64_t) + sizeof(float) + sizeof(double)); diff --git a/modules/common/utils/include/grape/utils/ip.h b/modules/common/utils/include/grape/utils/ip.h index 0adcca37..912b6866 100644 --- a/modules/common/utils/include/grape/utils/ip.h +++ b/modules/common/utils/include/grape/utils/ip.h @@ -14,7 +14,7 @@ namespace grape::utils { /// Holds an IP Address and associated methods struct [[nodiscard]] IPAddress { enum class Version { IPv4, IPv6 }; - static constexpr auto MAX_SEGMENTS = 16u; + static constexpr auto MAX_SEGMENTS = 16U; Version version{ Version::IPv4 }; std::array bytes{}; diff --git a/modules/common/utils/src/stacktrace.cpp b/modules/common/utils/src/stacktrace.cpp index 73325f1c..e6e0d171 100644 --- a/modules/common/utils/src/stacktrace.cpp +++ b/modules/common/utils/src/stacktrace.cpp @@ -20,7 +20,7 @@ auto StackTrace::current() -> StackTrace { const auto symbols = std::unique_ptr( backtrace_symbols(stack_frames.data(), frame_count), std::free); trace.symbol_list_.resize(static_cast(frame_count)); - for (auto i = 1u; i < static_cast(frame_count); ++i) { + for (auto i = 1U; i < static_cast(frame_count); ++i) { trace.symbol_list_.at(i - 1) = symbols.get()[i]; } diff --git a/modules/probe/monitor/src/monitor.cpp b/modules/probe/monitor/src/monitor.cpp index 6bb4e805..88b31ca5 100644 --- a/modules/probe/monitor/src/monitor.cpp +++ b/modules/probe/monitor/src/monitor.cpp @@ -87,7 +87,7 @@ ScrollingBuffer::ScrollingBuffer(std::size_t length, : length_(length), signals_info_(signals_info) { const auto num_signals = signals_info_.size(); signal_offsets_in_frame_.resize(num_signals); - for (auto signal_number = 0u; signal_number < num_signals; ++signal_number) { + for (auto signal_number = 0U; signal_number < num_signals; ++signal_number) { const auto& signal_info = signals_info_.at(signal_number); if (signal_info.role == grape::probe::Signal::Role::Timestamp) { timestamp_offset_in_frame_ = frame_size_; @@ -214,8 +214,8 @@ auto signalDataGetter(int idx, void* buf) -> ImPlotPoint { return {}; } - // TODO: pass frame_data, trace, signal_info from outside to optimise number of times they are - // calculated + // TODO(vilas): pass frame_data, trace, signal_info from outside to optimise number of times they + // are calculated // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) const auto* frame_data = buffer->frameData(static_cast(idx)); @@ -374,7 +374,7 @@ void Monitor::setSender(Sender&& sender) { //------------------------------------------------------------------------------------------------- void Monitor::run() { - static constexpr auto BK_COLOR = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); + static constexpr auto BK_COLOR = ImVec4(0.45F, 0.55F, 0.60F, 1.00F); while (glfwWindowShouldClose(impl_->window) == 0) { glfwPollEvents(); @@ -403,7 +403,7 @@ void Monitor::recv(const std::vector& signals, std::span frame) { const std::unique_lock signals_lock(impl_->signals_lock); if (impl_->signals_buffer == nullptr) { - static constexpr auto BUFFER_MAX_SIZE = 2000u; + static constexpr auto BUFFER_MAX_SIZE = 2000U; impl_->signals_buffer = std::make_unique(BUFFER_MAX_SIZE, signals); const std::unique_lock ctrl_lock(impl_->controllables_lock); impl_->controllables = std::make_unique(signals, frame); @@ -416,9 +416,9 @@ void Monitor::drawPlots() { static constexpr auto PLOT_SIZE = ImVec2(-1, 150); static constexpr auto AXIS_FLAGS_X = ImPlotAxisFlags_None; static constexpr auto AXIS_FLAGS_Y = ImPlotAxisFlags_None | ImPlotAxisFlags_AutoFit; - static constexpr auto PLOT_FILL_ALPHA = 0.5f; - static constexpr auto MAX_HISTORY_SECONDS = 30.f; - static constexpr auto MIN_HISTORY_SECONDS = 1.f; + static constexpr auto PLOT_FILL_ALPHA = 0.5F; + static constexpr auto MAX_HISTORY_SECONDS = 30.F; + static constexpr auto MIN_HISTORY_SECONDS = 1.F; const ImGuiIO& io = ImGui::GetIO(); @@ -435,7 +435,7 @@ void Monitor::drawPlots() { ImGui::SliderFloat("History", &history, 1, MAX_HISTORY_SECONDS, "%.1f s"); const auto& signals_info = impl_->signals_buffer->signalsInfo(); - for (auto signal_number = 0u; signal_number < signals_info.size(); ++signal_number) { + for (auto signal_number = 0U; signal_number < signals_info.size(); ++signal_number) { const auto signal = signals_info.at(signal_number); const auto* signal_name = signal.name.cStr(); if (signal.role == Signal::Role::Timestamp) { @@ -446,9 +446,9 @@ void Monitor::drawPlots() { ImPlot::SetupAxes(nullptr, nullptr, AXIS_FLAGS_X, AXIS_FLAGS_Y); ImPlot::SetNextFillStyle(IMPLOT_AUTO_COL, PLOT_FILL_ALPHA); ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 1); - // TODO: X axis limits must come from time in data history rather than t + // TODO(vilas): X axis limits must come from time in data history rather than t ImPlot::SetupAxisLimits(ImAxis_X1, t - static_cast(history), t, ImGuiCond_Always); - for (auto trace_number = 0u; trace_number < signal.num_elements; ++trace_number) { + for (auto trace_number = 0U; trace_number < signal.num_elements; ++trace_number) { auto trace_name = std::string(signal_name); if (signal.num_elements > 1) { trace_name += "[" + std::to_string(trace_number) + "]"; @@ -457,7 +457,7 @@ void Monitor::drawPlots() { ImPlot::PlotLineG(trace_name.c_str(), signalDataGetter, impl_->signals_buffer.get(), static_cast(impl_->signals_buffer->length()), /*ImPlotLineFlags*/ 0); - // TODO: use PlotLineEx directly when reading off separate timestamp and signal buffers + // TODO(vilas): use PlotLineEx directly when reading off separate timestamp and signals } ImPlot::EndPlot(); } @@ -475,8 +475,7 @@ void Monitor::drawControls() { return; } - // TODO: - // - show current values with ImGuiInputTextFlags_ReadOnly + // TODO(vilas): show current values with ImGuiInputTextFlags_ReadOnly ImGui::Begin("Controls"); diff --git a/modules/probe/monitor/third_party/implot/examples/implot_example.cpp b/modules/probe/monitor/third_party/implot/examples/implot_example.cpp index eb56fa0a..012fc408 100644 --- a/modules/probe/monitor/third_party/implot/examples/implot_example.cpp +++ b/modules/probe/monitor/third_party/implot/examples/implot_example.cpp @@ -129,7 +129,7 @@ ImplotExample::~ImplotExample() { //------------------------------------------------------------------------------------------------- void ImplotExample::run() { - static constexpr auto BK_COLOR = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); + static constexpr auto BK_COLOR = ImVec4(0.45F, 0.55F, 0.60F, 1.00F); while (glfwWindowShouldClose(window_) == 0) { glfwPollEvents(); @@ -202,12 +202,12 @@ void ImplotExample::demoRealtimePlot() { static ScrollingBuffer mybf(2000); const ImVec2 mouse = ImGui::GetMousePos(); const ImGuiIO& io = ImGui::GetIO(); - static auto t = 0.f; + static auto t = 0.F; t += io.DeltaTime; - mxbf.addPoint(t, mouse.x * 0.0005f); - mybf.addPoint(t, mouse.y * 0.0005f); + mxbf.addPoint(t, mouse.x * 0.0005F); + mybf.addPoint(t, mouse.y * 0.0005F); - static float history = 10.0f; + static float history = 10.0F; ImGui::SliderFloat("History", &history, 1, 30, "%.1f s"); const ImPlotAxisFlags flags = ImPlotAxisFlags_NoTickLabels; @@ -217,7 +217,7 @@ void ImplotExample::demoRealtimePlot() { ImPlot::SetupAxisLimits(ImAxis_X1, static_cast(t - history), static_cast(t), ImGuiCond_Always); ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 1); - ImPlot::SetNextFillStyle(IMPLOT_AUTO_COL, 0.5f); + ImPlot::SetNextFillStyle(IMPLOT_AUTO_COL, 0.5F); const auto& mx = mxbf.data(); const auto& my = mybf.data(); ImPlot::PlotLine("Mouse X", &mx[0].x, &mx[0].y, mx.size(), 0, mxbf.offset(), 2 * sizeof(float));