Skip to content

Commit

Permalink
Feature/reorg (#170)
Browse files Browse the repository at this point in the history
* (wip) start moving core hydra files

* (wip) rename package in code

* finish moving core package files around

* rename frontend class

* rename backend class

* rename lcd class

* misc other renaming for configs

* (wip) start moving hydra topology into hydra

* fully drop hydra_topology package

* rework reconstruction vs places namespace a little

* move non-ros hydra utils to hydra package

* get hydra ros code building again

* move last of hydra_utils file into hydra_ros

* move topology configs

* drop config specializations for each enum

* make hydra unit tests compile again

* drop last ros package call

* get hydra ros tests to compile

* fix ros unit tests

* (wip) fix config test resource filepaths

* (wip) update lcd paths

* (wip) fix loop closure tests with new convention

* rework packages in launch files

* update clang format file

* reformat

* update licenses and add dev scripts

* fix cmake format

* (wip) drop hydra msg defs from non-ros code

* (wip) update cmake a little

* adapt to frontend changes

* (wip) fix ros compilation issues

* address comments from Yun

* minor cleanup to ros interface

Co-authored-by: Nathan Hughes <[email protected]>
  • Loading branch information
nathanhhughes and nathanhhughes committed Jun 26, 2023
1 parent a2eeac1 commit 6a80928
Show file tree
Hide file tree
Showing 419 changed files with 2,934 additions and 3,995 deletions.
98 changes: 7 additions & 91 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,94 +1,10 @@
---
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BasedOnStyle: Google
---
Language: Cpp
DerivePointerAlignment: false
PointerAlignment: Left
ColumnLimit: 88
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 88
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
...

---
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,9 @@ Finally, build your workspace:
catkin build
```

### Components
### Config Library

See the following for more information:
- [hydra_dsg_builder](hydra_dsg_builder/README.md)
- [hydra_topology](hydra_topology/README.md)
- [hydra_utils](hydra_utils/README.md)
Hydra has a wrapper around config parsing that is documented [here](doc/config_parsing.md).

### Filing Issues

Expand Down
8 changes: 8 additions & 0 deletions dev/check-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
pushd $(dirname $SCRIPT_DIR)

find ./python -iname '*.py' | xargs python3 -m flake8

popd
10 changes: 10 additions & 0 deletions dev/check-licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

pushd $(dirname $SCRIPT_DIR)

find . -iname *.h -o -iname *.cpp | xargs python3 $SCRIPT_DIR/check_license.py
find . -iname '*.py' | xargs python3 $SCRIPT_DIR/check_license.py

popd
73 changes: 73 additions & 0 deletions dev/check_license.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env python3
"""Script to check source file for license info."""
import difflib
import pathlib
import click


def get_filetype(extension):
"""Get filetype based on extension."""
if extension in [".cpp", ".h"]:
return "cpp"
elif extension == ".py":
return "python"
else:
return None


@click.command()
@click.argument("input_files", type=click.File("r"), nargs=-1)
@click.option("--verbose", "-v", is_flag=True, help="show files checked")
def main(input_files, verbose):
"""Check if header of file matches license."""
parent_dir = pathlib.Path(__file__).absolute().parent
headers = {}
with (parent_dir / "cpp-header.txt").open("r") as fin:
headers["cpp"] = fin.read()

with (parent_dir / "python-header.txt").open("r") as fin:
headers["python"] = fin.read()

for input_file in input_files:
ext = pathlib.Path(input_file.name).suffix
filetype = get_filetype(ext)
if not filetype:
click.secho(f"unknown extension for {input_file.name}: {ext}", fg="yellow")
continue

target = headers[filetype]
num_lines = len(target.split("\n")) - 1

try:
lines = [next(input_file) for _ in range(num_lines)]
except StopIteration:
click.secho(f"{input_file.name}: missing", fg="red")
continue

if filetype == "python":
if lines and "#!" in lines[0]:
lines = lines[1:]
try:
lines.append(next(input_file))
except StopIteration:
click.secho(f"{input_file.name}: missing", fg="red")
continue

header = "".join(lines)
if header != target:
click.secho(f"{input_file.name}: bad", fg="red")
if verbose:
diff = difflib.context_diff(
header.splitlines(keepends=True),
target.splitlines(keepends=True),
fromfile=input_file.name,
tofile="license",
)
diff_str = "".join(diff)
click.secho(f"{diff_str}", fg="red")
elif verbose:
click.secho(f"{input_file.name}: good", fg="green")


if __name__ == "__main__":
main()
34 changes: 34 additions & 0 deletions dev/cpp-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------------
* Copyright 2022 Massachusetts Institute of Technology.
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Research was sponsored by the United States Air Force Research Laboratory and
* the United States Air Force Artificial Intelligence Accelerator and was
* accomplished under Cooperative Agreement Number FA8750-19-2-1000. The views
* and conclusions contained in this document are those of the authors and should
* not be interpreted as representing the official policies, either expressed or
* implied, of the United States Air Force or the U.S. Government. The U.S.
* Government is authorized to reproduce and distribute reprints for Government
* purposes notwithstanding any copyright notation herein.
* -------------------------------------------------------------------------- */
32 changes: 32 additions & 0 deletions dev/python-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2022, Massachusetts Institute of Technology.
# All Rights Reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Research was sponsored by the United States Air Force Research Laboratory and
# the United States Air Force Artificial Intelligence Accelerator and was
# accomplished under Cooperative Agreement Number FA8750-19-2-1000. The views
# and conclusions contained in this document are those of the authors and should
# not be interpreted as representing the official policies, either expressed or
# implied, of the United States Air Force or the U.S. Government. The U.S.
# Government is authorized to reproduce and distribute reprints for Government
# purposes notwithstanding any copyright notation herein.
11 changes: 11 additions & 0 deletions dev/reformat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

pushd $(dirname $SCRIPT_DIR)

find . -iname *.h -o -iname *.cpp | xargs clang-format -i
python3 -m black .
find . -iname *CMakeLists.txt* | xargs python3 -m cmakelang.format -i

popd
File renamed without changes.
File renamed without changes.
100 changes: 100 additions & 0 deletions hydra/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
cmake_minimum_required(VERSION 3.1)
project(hydra)

add_compile_options(-Wall -Wextra)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(HYDRA_USE_COVERAGE "Build core library with GCC --coverage option" OFF)
option(HYDRA_GNN "build GNN interface" ON)
if(HYDRA_GNN)
set(HYDRA_USE_GNN_CXX_VALUE 1)
else()
set(HYDRA_USE_GNN_CXX_VALUE 0)
endif()
configure_file(hydra_build_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/hydra_build_config.h)

find_package(Boost REQUIRED COMPONENTS timer)
find_package(spark_dsg REQUIRED)
find_package(teaserpp REQUIRED)
find_package(GTSAM REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(
catkin REQUIRED
COMPONENTS kimera_pgmo
kimera_semantics
tf2_eigen
voxblox
)

set(PCL_FIND_QUIETLY TRUE)
find_package(PCL REQUIRED COMPONENTS common)

configure_file(cmake/nanoflann.CMakeLists.txt.in nanoflann-download/CMakeLists.txt)
execute_process(
COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/nanoflann-download"
OUTPUT_QUIET
)
execute_process(
COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/nanoflann-download"
OUTPUT_QUIET
)

set(NANOFLANN_BUILD_EXAMPLES
OFF
CACHE INTERNAL ""
)
set(NANOFLANN_BUILD_TESTS
OFF
CACHE INTERNAL ""
)
add_subdirectory(${CMAKE_BINARY_DIR}/nanoflann-src ${CMAKE_BINARY_DIR}/nanoflann-build)

catkin_package(
CATKIN_DEPENDS
kimera_pgmo
kimera_semantics
tf2_eigen
voxblox
DEPENDS spark_dsg YAML_CPP
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME} gtsam
)

add_library(${PROJECT_NAME})
target_include_directories(
${PROJECT_NAME}
PUBLIC include ${catkin_INCLUDE_DIRS}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${PCL_INCLUDE_DIRS}
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC ${catkin_LIBRARIES}
teaserpp::teaser_registration
spark_dsg::spark_dsg
yaml-cpp
gtsam
PRIVATE nanoflann::nanoflann ${PCL_LIBRARIES}
)
add_subdirectory(src)

if(HYDRA_GNN)
add_subdirectory(src/gnn)
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_NAME}_gnn)
endif(HYDRA_GNN)

if(HYDRA_USE_COVERAGE)
target_compile_options(${PROJECT_NAME} PRIVATE --coverage)
# TODO(nathan) once we have newer cmake, target link options
target_link_libraries(${PROJECT_NAME} PRIVATE --coverage)
endif(HYDRA_USE_COVERAGE)

if(CATKIN_ENABLE_TESTING)
add_subdirectory(tests)
endif(CATKIN_ENABLE_TESTING)

# TODO(nathan) handle install
File renamed without changes.
Loading

0 comments on commit 6a80928

Please sign in to comment.