Skip to content

Commit

Permalink
new clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Mar 26, 2024
1 parent 2bf04cc commit 6435fb7
Show file tree
Hide file tree
Showing 37 changed files with 573 additions and 456 deletions.
45 changes: 22 additions & 23 deletions data_tamer_cpp/.clang-format → .clang-format
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
---
BasedOnStyle: Google
BasedOnStyle: Google
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
BreakConstructorInitializers: BeforeComma
BinPackParameters: true
ColumnLimit: 90
ColumnLimit: 90
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerBinding: false
PointerBindsToType: true
Expand All @@ -30,19 +29,20 @@ PenaltyBreakString: 1
PenaltyBreakFirstLessLess: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 90
SpacesBeforeTrailingComments: 3
Cpp11BracedListStyle: true
Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: false
Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
IndentFunctionDeclarationAfterType: false
SpacesInParentheses: false
SpacesInAngles: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
ContinuationIndentWidth: 4
SortIncludes: false
SpaceAfterCStyleCast: false
Expand All @@ -53,17 +53,16 @@ BreakBeforeBraces: Custom

# Control of individual brace wrapping cases
BraceWrapping: {
AfterClass: 'true'
AfterControlStatement: 'true'
AfterEnum : 'true'
AfterFunction : 'true'
AfterNamespace : 'true'
AfterStruct : 'true'
AfterUnion : 'true'
BeforeCatch : 'true'
BeforeElse : 'true'
IndentBraces : 'false'
AfterClass: 'true',
AfterControlStatement: 'true',
AfterEnum : 'true',
AfterFunction : 'true',
AfterNamespace : 'true',
AfterStruct : 'true',
AfterUnion : 'true',
BeforeCatch : 'true',
BeforeElse : 'true',
IndentBraces : 'false',
SplitEmptyFunction: 'false'
}
...

11 changes: 5 additions & 6 deletions .github/workflows/cmake_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:

steps:
- uses: actions/checkout@v2

- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 2.0.13

- name: Create default profile
run: conan profile detect

Expand All @@ -48,17 +48,16 @@ jobs:
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake --build . --config Debug

- name: run test (Linux)
working-directory: ${{github.workspace}}/build
run: ctest -T test -T Coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
with:
directory: ${{github.workspace}}/build
gcov_ignore: ${{github.workspace}}/3rdparty
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

44 changes: 44 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

exclude: ^data_tamer_cpp/3rdparty/
repos:

# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude_types: [svg]
- id: mixed-line-ending
- id: trailing-whitespace
exclude_types: [svg]
- id: fix-byte-order-marker

# CPP hooks
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.2
hooks:
- id: clang-format
args: ['-fallback-style=none', '-i']
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
[![cmake Ubuntu](https://github.com/facontidavide/data_tamer/actions/workflows/cmake_ubuntu.yml/badge.svg)](https://github.com/facontidavide/data_tamer/actions/workflows/cmake_ubuntu.yml)
[![ros2](https://github.com/PickNikRobotics/data_tamer/actions/workflows/ros2.yml/badge.svg)](https://github.com/PickNikRobotics/data_tamer/actions/workflows/ros2.yml)
[![codecov](https://codecov.io/gh/facontidavide/data_tamer/graph/badge.svg?token=D0wtsntWds)](https://codecov.io/gh/facontidavide/data_tamer)

**DataTamer** is a library to log/trace numerical variables over time and
takes periodic "snapshots" of their values, to later visualize them as **timeseries**.

It works great with [PlotJuggler](https://github.com/facontidavide/PlotJuggler),
the timeseries visualization tool (note: you will need PlotJuggler **3.8.2** or later).

**DataTamer** is "fearless data logger" because you can record hundreds or **thousands of variables**:
**DataTamer** is "fearless data logger" because you can record hundreds or **thousands of variables**:
even 1 million points per second should have a fairly small CPU overhead.

Since all the values are aggregated in a single "snapshot", it is usually meant to
Since all the values are aggregated in a single "snapshot", it is usually meant to
record data in a periodic loop (a very frequent use case, in robotics applications).

Kudos to [pal_statistics](https://github.com/pal-robotics/pal_statistics), for inspiring this project.
Expand All @@ -27,20 +27,20 @@ DataTamer can be used to monitor multiple variables in your applications.
**Channels** are used to take "snapshots" of a subset of variables at a given time.
If you want to record at different frequencies, you can use different channels.

DataTamer will forward the collected data to 1 or multiple **sinks**;
DataTamer will forward the collected data to 1 or multiple **sinks**;
a sink may save the information immediately in a file (currently, we support [MCAP](https://mcap.dev/))
or publish it using an inter-process communication, for instance, a ROS2 publisher.

You can easily create your own, specialized sinks.

Use [PlotJuggler](https://github.com/facontidavide/PlotJuggler) to
visualize your logs offline or in real-time.
visualize your logs offline or in real-time.

## Features

- **Serialization schema is created at run-time**: no need to do code generation.
- **Suitable for real-time applications**: very low latency (on the side of the callee).
- **Multi-sink architecture**: recorded data can be forwarded to multiple "backends".
- **Multi-sink architecture**: recorded data can be forwarded to multiple "backends".
- **Very low serialization overhead**, in the order of 1 bit per traced value.
- The user can enable/disable traced variables at run-time.

Expand Down Expand Up @@ -176,11 +176,7 @@ cmake --build build/Debug --parallel
# How to deserialize data recorded with DataTamer

I will write more extensively about the serialization format used by DataTamer, but for the time being I
created a single header file without external dependencies that you can just copy into your project:
created a single header file without external dependencies that you can just copy into your project:
[data_tamer_parser.hpp](data_tamer/include/data_tamer_parser)

You can see how it is used in this example: [mcap_reader](data_tamer/examples/mcap_reader.cpp)




5 changes: 2 additions & 3 deletions data_tamer_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
find_package(ament_cmake QUIET)

if (ament_cmake_FOUND)
set(ROS2_SINK
set(ROS2_SINK
src/sinks/ros2_publisher_sink.cpp)
endif()

Expand Down Expand Up @@ -139,7 +139,7 @@ endif()

if(DATA_TAMER_BUILD_TESTS)
include(CTest)
enable_testing()
enable_testing()
add_subdirectory(tests)
endif()

Expand All @@ -153,4 +153,3 @@ if(benchmark_FOUND)
else()
message("Google Benchmark library not found")
endif()

1 change: 0 additions & 1 deletion data_tamer_cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ add_executable(dt_benchmark data_tamer_benchmark.cpp)
target_include_directories(dt_benchmark
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_link_libraries(dt_benchmark data_tamer benchmark)

17 changes: 12 additions & 5 deletions data_tamer_cpp/benchmarks/data_tamer_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ using namespace DataTamer;
class NullSink : public DataSinkBase
{
public:
~NullSink() override { stopThread(); }
void addChannel(std::string const&, Schema const&) override {}
bool storeSnapshot(const Snapshot&) override { return true; }
~NullSink() override
{
stopThread();
}
void addChannel(std::string const&, Schema const&) override
{}
bool storeSnapshot(const Snapshot&) override
{
return true;
}
};

static void DT_Doubles(benchmark::State& state)
Expand All @@ -23,7 +30,7 @@ static void DT_Doubles(benchmark::State& state)

channel->registerValue("values", &values);

for (auto _ : state)
for(auto _ : state)
{
channel->takeSnapshot();
}
Expand All @@ -39,7 +46,7 @@ static void DT_PoseType(benchmark::State& state)

channel->registerValue("values", &poses);

for (auto _ : state)
for(auto _ : state)
{
channel->takeSnapshot();
}
Expand Down
1 change: 0 additions & 1 deletion data_tamer_cpp/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ else()
$<BUILD_INTERFACE:${PROJECT_DIR}/3rdparty>
)
endif()

9 changes: 5 additions & 4 deletions data_tamer_cpp/examples/custom_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ int main()

// Note has the size of the message is almost the same as the raw data.
// The only overhead is the size of points_vect
size_t expected_size = sizeof(double) * 3 + // point
sizeof(double) * 7 + // pose
sizeof(uint32_t) + 5 * (sizeof(double) * 3) + // points_vect and its size
sizeof(int32_t) * 3; // value_array
size_t expected_size = sizeof(double) * 3 + // point
sizeof(double) * 7 + // pose
sizeof(uint32_t) +
5 * (sizeof(double) * 3) + // points_vect and its size
sizeof(int32_t) * 3; // value_array

channel->takeSnapshot();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
Expand Down
45 changes: 35 additions & 10 deletions data_tamer_cpp/examples/geometry_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,26 @@ class Vector2d

public:
Vector2d() = default;
Vector2d(double x, double y) : _x(x), _y(y) {}
Vector2d(double x, double y) : _x(x), _y(y)
{}

const double& x() const { return _x; }
const double& y() const { return _y; }
const double& x() const
{
return _x;
}
const double& y() const
{
return _y;
}

double& x() { return _x; }
double& y() { return _y; }
double& x()
{
return _x;
}
double& y()
{
return _y;
}
};

namespace DataTamer
Expand All @@ -47,7 +60,10 @@ namespace DataTamer
template <>
struct TypeDefinition<Point3D>
{
std::string typeName() const { return "Point3D"; }
std::string typeName() const
{
return "Point3D";
}

template <class Function>
void typeDef(Function& addField)
Expand All @@ -61,7 +77,10 @@ struct TypeDefinition<Point3D>
template <>
struct TypeDefinition<Quaternion>
{
std::string typeName() const { return "Quaternion"; }
std::string typeName() const
{
return "Quaternion";
}

template <class Function>
void typeDef(Function& addField)
Expand All @@ -76,7 +95,10 @@ struct TypeDefinition<Quaternion>
template <>
struct TypeDefinition<Pose>
{
std::string typeName() const { return "Pose"; }
std::string typeName() const
{
return "Pose";
}

template <class Function>
void typeDef(Function& addField)
Expand All @@ -89,7 +111,10 @@ struct TypeDefinition<Pose>
template <>
struct TypeDefinition<Vector2d>
{
std::string typeName() const { return "Vector2d"; }
std::string typeName() const
{
return "Vector2d";
}

// typeDef must use a different overload and x() and y() must return const reference to
// a class attribute
Expand All @@ -101,4 +126,4 @@ struct TypeDefinition<Vector2d>
}
};

} // namespace DataTamer
} // namespace DataTamer
Loading

0 comments on commit 6435fb7

Please sign in to comment.