Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions gaia_slam/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
BasedOnStyle: LLVM
UseCRLF: false
UseTab: Never
IndentWidth: 4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in readme.md, should document that these are our styles, etc.

Copy link
Contributor

@dr-soong dr-soong Feb 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the example repo, perhaps we can leave out our styles altoghether? If other people use this the styles are unlikely to align with theirs and it just adds complexity and extra build dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removd.

ColumnLimit: 0
# The following configuration encodes the BreakBeforeBraces Allman style
# but for BeforeLambdaBody to allow one-liner lambdas.
# See discussion here about customizing BreakBeforeBraces: https://reviews.llvm.org/D94906#2505095.
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left

# Align public/final/protected on the left.
AccessModifierOffset: -4

# From clang-format-11 there are more fine grained options for this setting.
AlignOperands: DontAlign
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true

AllowAllConstructorInitializersOnNextLine: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
BreakConstructorInitializers: BeforeComma
ConstructorInitializerIndentWidth: 4

AllowShortFunctionsOnASingleLine: None
# Merge lambda into a single line if argument of a function.
AllowShortLambdasOnASingleLine: Inline
# (clang-format-13) Align lambda body relative to the indentation level of the outer scope the lambda signature resides in.
# LambdaBodyIndentation: OuterScope

# If false, all arguments will either be all on the same line or will have one line each.
BinPackArguments: true
BinPackParameters: true
AlignAfterOpenBracket: DontAlign
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true

# Merge multiple #include blocks together and sort as one. Then split into groups based on category priority:
# 1. Associated file header (XYZ.hpp)
# 2. C system headers. (Priority: 1-2)
# 3. C++ standard library headers (Priority: 5)
# 4. third party library headers (Priority: 10)
# 5. your other project headers (Priority: 20-22 + 30)
# Note this could break the code, read: https://stackoverflow.com/questions/37927553/can-clang-format-break-my-code
IncludeBlocks: Regroup
IncludeCategories:
# Public Gaia headers.
- Regex: 'gaia\/'
Priority: 20
# Internal Gaia headers.
- Regex: 'gaia_internal\/'
Priority: 21
# Internal Gaia headers.
- Regex: 'gaia_spdlog\/'
Priority: 22
# Internal Gaia headers.
- Regex: 'gaia_spdlog_setup\/'
Priority: 22
# Third-party headers.
- Regex: '[flatbuffers|gtest|libexplain|llvm|pybind11|rocksdb|spdlog|tabulate]\/'
Priority: 10
SortPriority: 10
- Regex: 'backward'
Priority: 10
SortPriority: 11
- Regex: 'cpptoml'
Priority: 10
SortPriority: 12
- Regex: 'liburing'
Priority: 10
SortPriority: 13
- Regex: 'json\.hpp'
Priority: 10
SortPriority: 14
# C system headers.
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<c.*'
Priority: 2
# C++ library headers.
- Regex: '^<.*'
Priority: 5
# Component-only headers.
- Regex: '.*'
Priority: 30

KeepEmptyLinesAtTheStartOfBlocks: true
SpaceAfterCStyleCast: false
ContinuationIndentWidth: 4
AlignTrailingComments: false
77 changes: 77 additions & 0 deletions gaia_slam/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Complete list of checks: https://clang.llvm.org/extra/clang-tidy/checks/list.html
Checks: '-*,
clang-analyzer-*,
performance-*,
modernize-*,
readability-identifier-naming,
cppcoreguidelines-macro-usage,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-no-malloc,
cppcoreguidelines-pro-type-cstyle-cast,
cppcoreguidelines-pro-type-const-cast,
google-readability-namespace-comments,
google-default-arguments,
google-explicit-constructor,
google-runtime-operator,
google-readability-casting,
-performance-unnecessary-value-param,
-modernize-use-trailing-return-type,
-modernize-avoid-c-arrays,
-modernize-concat-nested-namespaces,
-modernize-use-using,
-modernize-use-nodiscard
'

# TODO: headers are disabled for now, they produce too many warnings.
#HeaderFilterRegex: "GaiaPlatform/production/.*inc/.*(hpp|inc|h)$"

CheckOptions:
# - { key: readability-identifier-naming.ClassSuffix, value: _t } can't do this because of exceptions
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ }
- { key: readability-identifier-naming.StructSuffix, value: _t }
- { key: readability-identifier-naming.GlobalVariablePrefix, value: g_ }
- { key: readability-identifier-naming.GlobalConstantPrefix, value: c_ }
- { key: readability-identifier-naming.ConstantPrefix, value: c_ }
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: c_ }
- { key: readability-identifier-naming.TypeTemplateParameterPrefix, value: T_ }
- { key: readability-identifier-naming.AbstractClassCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: lower_case }
- { key: readability-identifier-naming.ClassConstantCase, value: lower_case }
- { key: readability-identifier-naming.ClassMemberCase, value: lower_case }
- { key: readability-identifier-naming.ClassMethodCase, value: lower_case }
- { key: readability-identifier-naming.ConstantCase, value: lower_case }
- { key: readability-identifier-naming.ConstexprFunctionCase, value: lower_case }
- { key: readability-identifier-naming.ConstexprMethodCase, value: lower_case }
- { key: readability-identifier-naming.ConstexprVariableCase, value: lower_case }
- { key: readability-identifier-naming.EnumCase, value: lower_case }
- { key: readability-identifier-naming.EnumConstantCase, value: lower_case }
- { key: readability-identifier-naming.FunctionCase, value: lower_case }
- { key: readability-identifier-naming.GlobalConstantCase, value: lower_case }
- { key: readability-identifier-naming.GlobalFunctionCase, value: lower_case }
- { key: readability-identifier-naming.GlobalVariableCase, value: lower_case }
- { key: readability-identifier-naming.InlineNamespaceCase, value: lower_case }
- { key: readability-identifier-naming.LocalConstantCase, value: lower_case }
- { key: readability-identifier-naming.LocalVariableCase, value: lower_case }
- { key: readability-identifier-naming.MemberCase, value: lower_case }
- { key: readability-identifier-naming.ConstantMemberCase, value: lower_case }
- { key: readability-identifier-naming.PublicMemberCase, value: lower_case }
- { key: readability-identifier-naming.MethodCase, value: lower_case }
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ParameterCase, value: lower_case }
- { key: readability-identifier-naming.ConstantParameterCase, value: lower_case }
- { key: readability-identifier-naming.ParameterPackCase, value: lower_case }
- { key: readability-identifier-naming.PureFunctionCase, value: lower_case }
- { key: readability-identifier-naming.PureMethodCase, value: lower_case }
- { key: readability-identifier-naming.StaticConstantCase, value: lower_case }
- { key: readability-identifier-naming.StaticVariableCase, value: lower_case }
- { key: readability-identifier-naming.StructCase, value: lower_case }
- { key: readability-identifier-naming.TemplateParameterCase, value: lower_case }
- { key: readability-identifier-naming.TemplateTemplateParameterCase, value: lower_case }
- { key: readability-identifier-naming.TemplateUsingCase, value: lower_case }
- { key: readability-identifier-naming.TypeTemplateParameterCase, value: lower_case }
- { key: readability-identifier-naming.TypedefCase, value: lower_case }
- { key: readability-identifier-naming.UnionCase, value: lower_case }
- { key: readability-identifier-naming.UsingCase, value: lower_case }
- { key: readability-identifier-naming.ValueTemplateParameterCase, value: lower_case }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.VirtualMethodCase, value: lower_case }
4 changes: 4 additions & 0 deletions gaia_slam/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
logs/
.gaia_slam_db
cmake-*
.idea
75 changes: 75 additions & 0 deletions gaia_slam/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
###################################################
# Copyright (c) Gaia Platform LLC
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE.txt file
# or at https://opensource.org/licenses/MIT.
###################################################

cmake_minimum_required(VERSION 3.16)

project(gaia_slam)
project(gaia_slam)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


set(CMAKE_CXX_STANDARD 17)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why C++17? Do we use C++17 features in this app?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but I don't see a reason not to use it. (Well actually i do since our DAC headers use C++17 features, it's a known problem, better to proactively avoid warnings).


# We need pthreads support.
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)

include("/opt/gaia/cmake/gaia.cmake")

# --- Generate Direct Access classes from DDL---
process_schema(
DDL_FILE ${PROJECT_SOURCE_DIR}/gaia/gaia_slam.ddl
DATABASE_NAME gaia_slam
)

# -- Translate ruleset into CPP --
translate_ruleset(
RULESET_FILE ${PROJECT_SOURCE_DIR}/gaia/gaia_slam.ruleset
DATABASE_NAME gaia_slam
CLANG_PARAMS
-I ${PROJECT_SOURCE_DIR}/include
)

#
# Direct Access Example
#
add_executable(gaia_slam_direct_access
src/main_direct_access.cpp
src/graph.cpp
)

target_add_gaia_generated_sources(gaia_slam_direct_access)

target_include_directories(gaia_slam_direct_access PRIVATE
${GAIA_INC}
${PROJECT_SOURCE_DIR}/include
)

target_link_libraries(gaia_slam_direct_access PRIVATE
${GAIA_LIB}
Threads::Threads
)

#
# Rules Example
#
add_executable(gaia_slam_rules
src/main_rules.cpp
src/graph.cpp
)

target_add_gaia_generated_sources(gaia_slam_rules)

target_include_directories(gaia_slam_rules PRIVATE
${GAIA_INC}
${PROJECT_SOURCE_DIR}/include
)

target_link_libraries(gaia_slam_rules PRIVATE
${GAIA_LIB}
Threads::Threads
)
66 changes: 66 additions & 0 deletions gaia_slam/gaia/gaia_slam.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
----------------------------------------------------
-- Copyright (c) Gaia Platform LLC
--
-- Use of this source code is governed by the MIT
-- license that can be found in the LICENSE.txt file
-- or at https://opensource.org/licenses/MIT.
----------------------------------------------------

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tables need an explainer - how do these get used?
I saw that there are comments in the ruleset that talks about hooking rules up to table events,
but "what is this table representing" should be described here as clearly as possible.
Especially the incoming_data_event which won't make sense reading here and is tough to follow from the ruleset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a little explanation but not too detail since I'm no SLAM expert.

database gaia_slam

table graph

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to what bill said. plus a good part in the readme.md detailing why, what, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added readme with pretty much same code content as the description of this PR.

(
uuid string unique,
vertices references vertex[],
edges references edge[]
)

table vertex
(
id uint64 unique,
type uint8,
data uint8[],
pose_x double,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an obvious candidate for a nested struct when we support complex types...

pose_y double,

-- Relationships
graph_uuid string,
Copy link

@senderista senderista Feb 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered creating a special UUID type? This should be straightforward to implement as a flatbuffers struct with 2 64-bit ints, and it should be much faster than strings for comparisons. I'm worried about the potential perf penalty of using strings here (and in other usage of UUIDs). If enough apps need UUIDs then I think we should add a first-class UUID type, even if we don't generally support nested structs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove uuid for now. This is a leftover from the source example.

But yes, we should have first class uuid support.

graph references graph
using vertices
where vertex.graph_uuid = graph.uuid,

in_edges references edge[],
out_edges references edge[]
)

table edge
(
id uint64 unique,

-- Relationships
graph_uuid string,
graph references graph
where edge.graph_uuid = graph.uuid,

dest_id uint64,
dest references vertex
using in_edges
where edge.dest_id = vertex.id,

src_id uint64,
src references vertex
using out_edges
where edge.src_id = vertex.id
)

------------------------------------------------------------------------
-- Example table. For this example, assume that an entry is made into
-- the 'incoming_data_event' table when a new packet of data arrives.
table incoming_data_event
(
id uint64 unique,
type uint8,
data uint8[],
pose_x double,
pose_y double
)
Loading