Skip to content

Commit 5e78816

Browse files
committed
Initial commit
0 parents  commit 5e78816

File tree

78 files changed

+23456
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+23456
-0
lines changed

.github/workflows/main.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
on: [push, pull_request]
2+
3+
defaults:
4+
run:
5+
shell: bash
6+
7+
jobs:
8+
jammy_ccws_static:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
repository: asherikov/ccws
14+
- uses: actions/checkout@v4
15+
with:
16+
path: src/pjmsg_mcap_wrapper
17+
- run: make bp_install_build BUILD_PROFILE=scan_build
18+
- run: make bp_install_build BUILD_PROFILE=static_checks
19+
- run: mkdir -p src/.ccws
20+
- run: echo "pjmsg_mcap_wrapper/src/3rdparty/" >> src/.ccws/static_checks.exceptions.paths
21+
- run: make BUILD_PROFILE=static_checks
22+
- run: make dep_install PKG=pjmsg_mcap_wrapper
23+
- run: make pjmsg_mcap_wrapper BUILD_PROFILE=scan_build
24+
25+
jammy_ccws_plain_22:
26+
runs-on: ubuntu-22.04
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
repository: asherikov/ccws
31+
- uses: actions/checkout@v4
32+
with:
33+
path: src/pjmsg_mcap_wrapper
34+
- run: make bp_install_build BUILD_PROFILE=reldebug
35+
- run: make dep_install PKG=pjmsg_mcap_wrapper
36+
- run: make pjmsg_mcap_wrapper
37+
- run: make test PKG=pjmsg_mcap_wrapper
38+
39+
jammy_ccws_plain_24:
40+
runs-on: ubuntu-24.04
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
repository: asherikov/ccws
45+
- uses: actions/checkout@v4
46+
with:
47+
path: src/pjmsg_mcap_wrapper
48+
- run: make bp_install_build BUILD_PROFILE=reldebug
49+
- run: make dep_install PKG=pjmsg_mcap_wrapper
50+
- run: make pjmsg_mcap_wrapper
51+
- run: make test PKG=pjmsg_mcap_wrapper
52+
53+
jammy_ccws_threadsan:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
with:
58+
repository: asherikov/ccws
59+
- uses: actions/checkout@v4
60+
with:
61+
path: src/pjmsg_mcap_wrapper
62+
- run: make bp_install_build BUILD_PROFILE=thread_sanitizer
63+
- run: make dep_install PKG=pjmsg_mcap_wrapper
64+
- run: make pjmsg_mcap_wrapper BUILD_PROFILE=thread_sanitizer
65+
- run: make test PKG=pjmsg_mcap_wrapper BUILD_PROFILE=thread_sanitizer
66+
67+
jammy_ccws_asan:
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
with:
72+
repository: asherikov/ccws
73+
- uses: actions/checkout@v4
74+
with:
75+
path: src/pjmsg_mcap_wrapper
76+
- run: make bp_install_build BUILD_PROFILE=addr_undef_sanitizers
77+
- run: make dep_install PKG=pjmsg_mcap_wrapper
78+
- run: make pjmsg_mcap_wrapper BUILD_PROFILE=addr_undef_sanitizers
79+
- run: make test PKG=pjmsg_mcap_wrapper BUILD_PROFILE=addr_undef_sanitizers

CMakeLists.txt

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(pjmsg_mcap_wrapper VERSION 0.1.0 LANGUAGES CXX)
3+
4+
if(CCWS_CXX_FLAGS)
5+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CCWS_CXX_FLAGS}")
6+
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CCWS_LINKER_FLAGS}")
7+
else()
8+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
9+
set(CMAKE_VERBOSE_MAKEFILE ON)
10+
11+
if(NOT CMAKE_CXX_STANDARD)
12+
set(CMAKE_CXX_STANDARD 17)
13+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
14+
endif()
15+
16+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
17+
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
18+
endif()
19+
endif()
20+
21+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
22+
set(CMAKE_VISIBILITY_INLINES_HIDDEN hidden)
23+
24+
25+
add_subdirectory(src/3rdparty/)
26+
27+
if(CCWS_CLANG_TIDY)
28+
set(CMAKE_CXX_CLANG_TIDY "${CCWS_CLANG_TIDY}" CACHE STRING "" FORCE)
29+
endif()
30+
31+
32+
add_library(${PROJECT_NAME} SHARED
33+
src/writer.cpp
34+
)
35+
target_link_libraries(${PROJECT_NAME}
36+
PRIVATE fastcdr
37+
)
38+
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
39+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
40+
$<INSTALL_INTERFACE:include>
41+
)
42+
target_include_directories(${PROJECT_NAME}
43+
SYSTEM
44+
PRIVATE include/${PROJECT_NAME}/generated/
45+
PRIVATE src/3rdparty/mcap/cpp/mcap/include/
46+
PRIVATE src/3rdparty/generated/
47+
)
48+
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERFACE_${PROJECT_NAME}_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
49+
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${PROJECT_VERSION_MAJOR})
50+
51+
install(
52+
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
53+
INCLUDES DESTINATION include
54+
)
55+
56+
install(TARGETS ${PROJECT_NAME}
57+
ARCHIVE DESTINATION lib
58+
LIBRARY DESTINATION lib
59+
RUNTIME DESTINATION bin
60+
)
61+
62+
install(DIRECTORY include/${PROJECT_NAME}
63+
DESTINATION include
64+
FILES_MATCHING PATTERN "*.h"
65+
)
66+
67+
68+
# ---
69+
# cmake package stuff
70+
export(EXPORT ${PROJECT_NAME}
71+
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
72+
NAMESPACE ${PROJECT_NAME}::
73+
)
74+
75+
install(EXPORT ${PROJECT_NAME}
76+
FILE ${PROJECT_NAME}Targets.cmake
77+
NAMESPACE ${PROJECT_NAME}::
78+
DESTINATION share/${PROJECT_NAME}/
79+
)
80+
81+
82+
include(CMakePackageConfigHelpers)
83+
84+
write_basic_package_version_file(
85+
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
86+
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
87+
COMPATIBILITY SameMajorVersion
88+
)
89+
file(
90+
WRITE
91+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
92+
"include(\"\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake\")\n"
93+
)
94+
95+
install(
96+
FILES
97+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
98+
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
99+
DESTINATION share/${PROJECT_NAME}/
100+
)
101+
# ---

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
`pjmsg_mcap_writer`
2+
===================
3+
4+
Logging library that writes `plotjuggler_msgs` to `MCAP` files without `ROS`
5+
dependencies. Library incorporates `FastCDR` serializer, `MCAP` library, and
6+
pregenerated `plotjuggler_msgs` data structures: none of these dependencies are
7+
exposed through the API to avoid possible conflicts.

include/pjmsg_mcap_wrapper/all.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
@file
3+
@author Alexander Sherikov
4+
@copyright 2024 Alexander Sherikov. Licensed under the Apache License,
5+
Version 2.0. (see LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
6+
7+
@brief Sink class.
8+
*/
9+
10+
#pragma once
11+
12+
#include <filesystem>
13+
#include <vector>
14+
15+
#define PJMSG_MCAP_WRAPPER_PUBLIC __attribute__((visibility("default")))
16+
17+
18+
namespace pjmsg_mcap_wrapper
19+
{
20+
class PJMSG_MCAP_WRAPPER_PUBLIC Message
21+
{
22+
public:
23+
class Implementation;
24+
25+
public:
26+
const std::unique_ptr<Implementation> pimpl_;
27+
28+
public:
29+
Message();
30+
~Message();
31+
32+
std::vector<std::string> &names();
33+
std::vector<double> &values();
34+
35+
void bumpVersion();
36+
void setStamp(const uint64_t timestamp);
37+
void reserve(const std::size_t size);
38+
void resize(const std::size_t size);
39+
std::string &name(const std::size_t index);
40+
double &value(const std::size_t index);
41+
[[nodiscard]] std::size_t size() const;
42+
void setVersion(const uint32_t version);
43+
};
44+
45+
46+
class PJMSG_MCAP_WRAPPER_PUBLIC Writer
47+
{
48+
protected:
49+
class Implementation;
50+
51+
protected:
52+
const std::unique_ptr<Implementation> pimpl_;
53+
54+
public:
55+
Writer();
56+
~Writer();
57+
void initialize(const std::filesystem::path &filename, const std::string &topic_prefix);
58+
void flush();
59+
void write(const Message &message);
60+
};
61+
} // namespace pjmsg_mcap

messages/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
OUTPUT_DIR=../src/3rdparty/generated
2+
3+
generate: clean
4+
mkdir -p ${OUTPUT_DIR}
5+
~/Fast-DDS-Gen/scripts/fastddsgen \
6+
-default_extensibility final \
7+
-flat-output-dir \
8+
-fusion \
9+
-language c++ \
10+
-typeros2 \
11+
-no-typeobjectsupport \
12+
-I ./idl/ \
13+
-d ${OUTPUT_DIR}/ \
14+
idl/*.idl
15+
rm -rf ${OUTPUT_DIR}/*PubSubTypes*
16+
17+
clean:
18+
rm -rf ${OUTPUT_DIR}

messages/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
```
2+
from mcap.reader import make_reader
3+
4+
with open('filename', "rb") as f:
5+
reader = make_reader(f)
6+
for schema, channel, message in reader.iter_messages(topics=["sample_topic"]):
7+
print(f"{channel.topic} ({schema.name}): {message.data}")
8+
```

messages/idl/Header.idl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "Time.idl"
2+
3+
module std_msgs {
4+
module msg {
5+
struct Header {
6+
builtin_interfaces::msg::Time stamp;
7+
string frame_id;
8+
};
9+
};
10+
};

messages/idl/StatisticsNames.idl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "Header.idl"
2+
3+
module plotjuggler_msgs {
4+
module msg {
5+
struct StatisticsNames {
6+
std_msgs::msg::Header header;
7+
8+
sequence<string> names;
9+
10+
uint32 names_version;
11+
};
12+
};
13+
};

messages/idl/StatisticsValues.idl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "Header.idl"
2+
3+
module plotjuggler_msgs {
4+
module msg {
5+
struct StatisticsValues {
6+
std_msgs::msg::Header header;
7+
8+
sequence<double> values;
9+
10+
uint32 names_version;
11+
};
12+
};
13+
};

messages/idl/Time.idl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module builtin_interfaces {
2+
module msg {
3+
struct Time {
4+
int32 sec;
5+
6+
uint32 nanosec;
7+
};
8+
};
9+
};

0 commit comments

Comments
 (0)