Skip to content

Commit

Permalink
chore: Eliminates many linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cvilas committed Dec 4, 2024
1 parent feb2cee commit 7bc69d5
Show file tree
Hide file tree
Showing 24 changed files with 108 additions and 165 deletions.
10 changes: 0 additions & 10 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
158 changes: 56 additions & 102 deletions docs/02_roadmap.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,80 @@
# 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
- Differentiator
- 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<uintptr_t>` 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)
Expand All @@ -106,63 +92,32 @@
- 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<uintptr_t>` 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
- Add configuration presets to CMakePresets.json
- 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

Expand All @@ -172,4 +127,3 @@ auto main() -> int {
- Practical [C++26 Reflection](https://youtu.be/cqQ7v6xdZRw)
- Interfaces with C++20 concept: <https://concepts.godbolt.org/z/PjGb466cr>
- Clean code: <https://youtu.be/9ch7tZN4jeI>
- IoC containers for dependency injection, especially for mocking in tests: <https://github.com/ybainier/Hypodermic>. For why we should use it, see `clean code` video above
2 changes: 1 addition & 1 deletion modules/common/base/src/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void Exception::print() noexcept {
loc.function_name(), //
static_cast<int>(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());
}
Expand Down
2 changes: 1 addition & 1 deletion modules/common/ipc/examples/liveliness_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ auto main(int argc, const char* argv[]) -> int {

const auto key = args.getOptionOrThrow<std::string>("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<zenoh::Reply>(res);
Expand Down
6 changes: 3 additions & 3 deletions modules/common/ipc/examples/pub_shm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 })));

Expand Down
2 changes: 1 addition & 1 deletion modules/common/ipc/examples/sub_shm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/common/ipc/include/grape/ipc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct [[nodiscard]] Locator {
//=================================================================================================
/// Unique identifier
struct [[nodiscard]] UUID {
static constexpr auto LENGTH = 16u;
static constexpr auto LENGTH = 16U;
std::array<std::uint8_t, LENGTH> bytes;
};

Expand Down
4 changes: 2 additions & 2 deletions modules/common/ipc/src/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<const std::byte*>(data.data()), data.size() });
Expand Down
2 changes: 1 addition & 1 deletion modules/common/log/include/grape/log/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(const Record& r)>;

Expand Down
8 changes: 4 additions & 4 deletions modules/common/log/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<int, float>(logger, grape::log::Severity::Info, "{} {}", 5, 3.14f,
grape::log::Log<int, float>(logger, grape::log::Severity::Info, "{} {}", 5, 3.14F,
std::source_location::current());

/// Use the deduction guide for arguments with defaulted source location
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion modules/common/realtime/examples/schedule_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions modules/common/realtime/examples/thread_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MPSCQueue {

//-------------------------------------------------------------------------------------------------
template <typename T>
MPSCQueue<T>::MPSCQueue(std::size_t capacity) : items_((capacity > 0 ? capacity : 1u)) {
MPSCQueue<T>::MPSCQueue(std::size_t capacity) : items_((capacity > 0 ? capacity : 1U)) {
}

//-------------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 7bc69d5

Please sign in to comment.