Skip to content

Commit 3b9e06c

Browse files
committed
add formatting consistent with plotjuggler App
1 parent 1295aac commit 3b9e06c

23 files changed

Lines changed: 495 additions & 322 deletions

.clang-format

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
BasedOnStyle: Google
3+
AccessModifierOffset: -2
4+
ConstructorInitializerIndentWidth: 2
5+
AlignEscapedNewlinesLeft: false
6+
AlignTrailingComments: true
7+
AllowAllParametersOfDeclarationOnNextLine: false
8+
AllowShortIfStatementsOnASingleLine: false
9+
AllowShortLoopsOnASingleLine: false
10+
AllowShortFunctionsOnASingleLine: None
11+
AlwaysBreakTemplateDeclarations: true
12+
AlwaysBreakBeforeMultilineStrings: false
13+
BreakBeforeBinaryOperators: false
14+
BreakBeforeTernaryOperators: false
15+
BreakConstructorInitializers: BeforeComma
16+
BinPackParameters: true
17+
ColumnLimit: 100
18+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
19+
DerivePointerBinding: false
20+
PointerBindsToType: true
21+
ExperimentalAutoDetectBinPacking: false
22+
IndentCaseLabels: true
23+
MaxEmptyLinesToKeep: 1
24+
NamespaceIndentation: None
25+
ObjCSpaceBeforeProtocolList: true
26+
PenaltyBreakBeforeFirstCallParameter: 19
27+
PenaltyBreakComment: 60
28+
PenaltyBreakString: 1
29+
PenaltyBreakFirstLessLess: 1000
30+
PenaltyExcessCharacter: 1000
31+
PenaltyReturnTypeOnItsOwnLine: 90
32+
SpacesBeforeTrailingComments: 2
33+
Cpp11BracedListStyle: false
34+
Standard: Auto
35+
IndentWidth: 2
36+
TabWidth: 2
37+
UseTab: Never
38+
IndentFunctionDeclarationAfterType: false
39+
SpacesInParentheses: false
40+
SpacesInAngles: false
41+
SpaceInEmptyParentheses: false
42+
SpacesInCStyleCastParentheses: false
43+
SpaceAfterControlStatementKeyword: true
44+
SpaceBeforeAssignmentOperators: true
45+
ContinuationIndentWidth: 4
46+
SortIncludes: false
47+
SpaceAfterCStyleCast: false
48+
BreakStringLiterals: false
49+
50+
# Configure each individual brace in BraceWrapping
51+
BreakBeforeBraces: Custom
52+
53+
# Control of individual brace wrapping cases
54+
BraceWrapping: {
55+
AfterClass: 'true',
56+
AfterControlStatement: 'true',
57+
AfterEnum : 'true',
58+
AfterFunction : 'true',
59+
AfterNamespace : 'true',
60+
AfterStruct : 'true',
61+
AfterUnion : 'true',
62+
BeforeCatch : 'true',
63+
BeforeElse : 'true',
64+
IndentBraces : 'false'
65+
}
66+
...

.pre-commit-config.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
# To use:
3+
#
4+
# pre-commit run -a
5+
#
6+
# Or:
7+
#
8+
# pre-commit install # (runs every time you commit in git)
9+
#
10+
# To update this file:
11+
#
12+
# pre-commit autoupdate
13+
#
14+
# See https://github.com/pre-commit/pre-commit
15+
16+
exclude: cmake/CPM.cmake|^3rdparty/|3rdparty
17+
repos:
18+
19+
# Standard hooks
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v4.5.0
22+
hooks:
23+
- id: check-added-large-files
24+
- id: check-ast
25+
- id: check-case-conflict
26+
- id: check-docstring-first
27+
- id: check-merge-conflict
28+
- id: check-symlinks
29+
- id: check-xml
30+
- id: check-yaml
31+
- id: debug-statements
32+
- id: end-of-file-fixer
33+
exclude_types: [svg]
34+
- id: mixed-line-ending
35+
- id: trailing-whitespace
36+
exclude_types: [svg]
37+
- id: fix-byte-order-marker
38+
39+
# CPP hooks
40+
- repo: https://github.com/pre-commit/mirrors-clang-format
41+
rev: v17.0.6
42+
hooks:
43+
- id: clang-format
44+
args: ['-fallback-style=none', '-i']
45+
46+
# Spell check
47+
# - repo: https://github.com/codespell-project/codespell
48+
# rev: v2.4.1
49+
# hooks:
50+
# - id: codespell
51+
# additional_dependencies:
52+
# - tomli
53+
# args:
54+
# [--toml=./tools/pyproject.toml]
55+
# exclude_types: [svg]

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ros.distro": "humble"
3+
}

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
7373

7474
install(DIRECTORY launch
7575
DESTINATION share/${PROJECT_NAME})
76-
76+
7777
add_subdirectory( src )
7878

7979
ament_package()
80-
81-

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Create a catkin workspace and clone the repositories:
3333
git clone https://github.com/PlotJuggler/plotjuggler_msgs.git
3434
git clone https://github.com/facontidavide/PlotJuggler.git
3535
git clone https://github.com/PlotJuggler/plotjuggler-ros-plugins.git
36-
36+
3737
Now, it is time to compile:
3838

3939
cd ~/ws_plotjuggler
@@ -43,6 +43,3 @@ Now, it is time to compile:
4343
# For ROS (1) users
4444

4545
From version 2.3+, this library will support only ROS2 (Hubmle or older)
46-
47-
48-

launch/plotjuggler.launch

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<launch>
22
<node name = "PlotJuggler" pkg = "plotjuggler" type = "plotjuggler" output = "screen" />
33
</launch>
4-

src/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ QT5_WRAP_UI ( COMMON_UI_SRC
99
publisher_select_dialog.ui )
1010

1111

12-
add_library( commonROS STATIC
12+
add_library( commonROS STATIC
1313
dialog_select_ros_topics.h
1414
dialog_select_ros_topics.cpp
1515
dialog_with_itemlist.h
@@ -60,6 +60,5 @@ install(TARGETS
6060
DataLoadROS2
6161
DataStreamROS2
6262
TopicPublisherROS2
63-
DESTINATION lib/${PROJECT_NAME}
63+
DESTINATION lib/${PROJECT_NAME}
6464
)
65-

src/DataLoadROS2/dataload_ros2.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ const std::vector<const char*>& DataLoadROS2::compatibleFileExtensions() const
4040
return _extensions;
4141
}
4242

43-
bool DataLoadROS2::readDataFromFile(PJ::FileLoadInfo* info,
44-
PJ::PlotDataMapRef& plot_map)
43+
bool DataLoadROS2::readDataFromFile(PJ::FileLoadInfo* info, PJ::PlotDataMapRef& plot_map)
4544
{
4645
auto metadata_io = std::make_unique<rosbag2_storage::MetadataIo>();
4746

@@ -71,14 +70,17 @@ bool DataLoadROS2::readDataFromFile(PJ::FileLoadInfo* info,
7170
}
7271
catch (std::runtime_error& ex)
7372
{
74-
QMessageBox::warning(nullptr, tr("Error"), QString("rosbag::open thrown an exception:\n") + QString(ex.what()));
73+
QMessageBox::warning(nullptr, tr("Error"),
74+
QString("rosbag::open thrown an exception:\n") + QString(ex.what()));
7575
return false;
7676
}
7777

7878
QDir::setCurrent(oldPath);
7979

80-
// Temporarily change the current directory as a workaround for rosbag2 relative directories not working properly
81-
std::vector<rosbag2_storage::TopicMetadata> topic_metadata = temp_bag_reader->get_all_topics_and_types();
80+
// Temporarily change the current directory as a workaround for rosbag2 relative directories not
81+
// working properly
82+
std::vector<rosbag2_storage::TopicMetadata> topic_metadata =
83+
temp_bag_reader->get_all_topics_and_types();
8284

8385
std::unordered_map<std::string, std::string> topicTypesByName;
8486

@@ -91,25 +93,27 @@ bool DataLoadROS2::readDataFromFile(PJ::FileLoadInfo* info,
9193

9294
for (const rosbag2_storage::TopicMetadata& topic : topic_metadata)
9395
{
94-
all_topics_qt.push_back( {QString::fromStdString(topic.name),
95-
QString::fromStdString(topic.type)} );
96+
all_topics_qt.push_back(
97+
{ QString::fromStdString(topic.name), QString::fromStdString(topic.type) });
9698
topicTypesByName.emplace(topic.name, topic.type);
9799

98100
const auto& typesupport_identifier = rosidl_typesupport_cpp::typesupport_identifier;
99101
try
100102
{
101-
topics_info.emplace_back( CreateTopicInfo(topic.name, topic.type) );
102-
103-
} catch (...) {
103+
topics_info.emplace_back(CreateTopicInfo(topic.name, topic.type));
104+
}
105+
catch (...)
106+
{
104107
failed_topic_type.insert(topic.type);
105108
blacklist_topic_name.insert(topic.type);
106109
}
107110
}
108111

109-
if(!failed_topic_type.empty())
112+
if (!failed_topic_type.empty())
110113
{
111-
QString msg("Can not recognize the following message types and those topics will be ignored:\n\n");
112-
for(const auto& type: failed_topic_type)
114+
QString msg(
115+
"Can not recognize the following message types and those topics will be ignored:\n\n");
116+
for (const auto& type : failed_topic_type)
113117
{
114118
msg += " " + QString::fromStdString(type) + "\n";
115119
}
@@ -159,10 +163,8 @@ bool DataLoadROS2::readDataFromFile(PJ::FileLoadInfo* info,
159163
std::string topic_type = topicTypesByName.at(topic_name);
160164
topic_selected.insert(topic_name);
161165

162-
auto ros2_parser = CreateParserROS2( *parserFactories(),
163-
topic_name, topic_type, plot_map);
166+
auto ros2_parser = CreateParserROS2(*parserFactories(), topic_name, topic_type, plot_map);
164167
parser.addParser(topic_name, ros2_parser);
165-
166168
}
167169

168170
parser.setConfig(_config);
@@ -181,15 +183,15 @@ bool DataLoadROS2::readDataFromFile(PJ::FileLoadInfo* info,
181183
plot_map.addUserDefined("plotjuggler::rosbag2_cpp::topics_metadata")->second;
182184

183185
// dirty trick. Store it in a one point timeseries
184-
metadata_storage.pushBack( {0, std::any(topics_info) } );
186+
metadata_storage.pushBack({ 0, std::any(topics_info) });
185187

186188
auto time_prev = std::chrono::high_resolution_clock::now();
187189

188190
while (_bag_reader->has_next())
189191
{
190192
auto msg = _bag_reader->read_next();
191193
const std::string& topic_name = msg->topic_name;
192-
if(blacklist_topic_name.count(topic_name))
194+
if (blacklist_topic_name.count(topic_name))
193195
{
194196
continue;
195197
}

0 commit comments

Comments
 (0)