Skip to content

Commit

Permalink
Moved the Variable class into the public fuse repo
Browse files Browse the repository at this point in the history
  • Loading branch information
svwilliams committed Jul 3, 2018
1 parent 17d9121 commit 6362b64
Show file tree
Hide file tree
Showing 14 changed files with 790 additions and 1 deletion.
31 changes: 31 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Software License Agreement (BSD License)

Copyright (c) 2018, Locus Robotics
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

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.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# fuse
The fuse stack provides a general architecture for performing sensor fusion live on a robot. Some possible applications include state estimation, localization, mapping, and calibration.
The fuse stack provides a general architecture for performing sensor fusion live on a robot. Some possible applications
include state estimation, localization, mapping, and calibration.
4 changes: 4 additions & 0 deletions fuse/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 2.8.3)
project(fuse)
find_package(catkin REQUIRED)
catkin_metapackage()
31 changes: 31 additions & 0 deletions fuse/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Software License Agreement (BSD License)

Copyright (c) 2018, Locus Robotics
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

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.
2 changes: 2 additions & 0 deletions fuse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# fuse
This is the metapackage for the entire fuse stack.
19 changes: 19 additions & 0 deletions fuse/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<package format="2">
<name>fuse</name>
<version>0.0.0</version>
<description>
The fuse metapackage
</description>

<maintainer email="[email protected]">Stephen Williams</maintainer>
<author email="[email protected]">Stephen Williams</author>
<license>BSD</license>

<buildtool_depend>catkin</buildtool_depend>
<exec_depend>fuse_core</exec_depend>

<export>
<metapackage />
</export>
</package>
74 changes: 74 additions & 0 deletions fuse_core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
cmake_minimum_required(VERSION 2.8.3)
project(fuse_core)

find_package(catkin REQUIRED COMPONENTS
roscpp
)
find_package(Boost REQUIRED)
find_package(Ceres REQUIRED)

catkin_package(
INCLUDE_DIRS
include
${CERES_INCLUDE_DIRS}
LIBRARIES
${PROJECT_NAME}
${CERES_LIBRARIES}
CATKIN_DEPENDS
roscpp
DEPENDS
Boost
)

###########
## Build ##
###########

set_directory_properties(PROPERTIES COMPILE_OPTIONS "-std=c++14;-Wall;-Werror")

include_directories(
include
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${CERES_INCLUDE_DIRS}
)

## fuse_core library
add_library(${PROJECT_NAME}
src/variable.cpp
)
add_dependencies(${PROJECT_NAME}
${catkin_EXPORTED_TARGETS}
)
target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
${CERES_LIBRARIES}
)

#############
## Install ##
#############

install(
TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

install(
DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)

#############
## Testing ##
#############

if(CATKIN_ENABLE_TESTING)
# Lint tests
find_package(roslint REQUIRED)
set(ROSLINT_CPP_OPTS "--filter=-build/c++11,-runtime/references")
roslint_cpp()
roslint_add_test()
endif()
31 changes: 31 additions & 0 deletions fuse_core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Software License Agreement (BSD License)

Copyright (c) 2018, Locus Robotics
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

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.
25 changes: 25 additions & 0 deletions fuse_core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# fuse_core
This package provides the base class interfaces for the various fuse components. Concrete implementations of these
interfaces are provided in other packages.

## Variable
Within the fuse system, a "variable" is a convenient group of one or more related scalar values. These scalars are
treated as a block within the optimizer. If the variable is modeling a time-varying quatity, the an instance of the
variable represents value of the state at one specific point in time. The fuse system maintains a history of variable
instances, allowing measurements to involve previous states as well as the current state.

When defining a new variable type, there is a balance that must be struct between reusability and convenience. If you
define a complex composite state, it is unlikely that any other available components will use that same state
definition. If you make the state too granular, then more book-keeping and value lookups will be required to piece
together a useful concept from many smallar scalar components.

As an example, let's consider a 3D pose consisting of a 3D position (x, y, z) and a quaternion orientation
(qx, qy, qx, qw). We could define a single state for the 3D pose consisting of all 7 scalar components. Alternatively,
we could define two variables types, a 3 dimension position vector and a 4 dimension quaternion. Or we could even
define seven variable types, one for each dimension.

Within the `fuse_core` package, no concrete variables are actually created. We only define the common interface to which
all types must adhere. A set of common variable types are provided in the [`fuse_variables`](../fuse_variables)
package. And new variable types can be created outside the fuse stack completely. However, similar to how using common
ROS messages across nodes allow for code reuse, using common variable types will allow sensor models and motion models
to be shared across the community.
135 changes: 135 additions & 0 deletions fuse_core/include/fuse_core/macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Copyright 2014 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/***************************************************************************
* This file has been modified from its original published source.
* https://raw.githubusercontent.com/ros2/rclcpp/master/rclcpp/include/rclcpp/macros.hpp
* Modifications are provided under the BSD license.
***************************************************************************/

/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2018, Locus Robotics
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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.
*/

#ifndef FUSE_CORE_MACROS_H
#define FUSE_CORE_MACROS_H

#include <memory>

/**
* Defines aliases and static functions for using the Class with smart pointers.
*
* Use in the public section of the class.
*/
#define SMART_PTR_DEFINITIONS(...) \
SHARED_PTR_DEFINITIONS(__VA_ARGS__) \
WEAK_PTR_DEFINITIONS(__VA_ARGS__) \
UNIQUE_PTR_DEFINITIONS(__VA_ARGS__)

/**
* Defines aliases only for using the Class with smart pointers.
*
* Same as SMART_PTR_DEFINITIONS except it excludes the static
* method definitions which do not work on pure virtual classes and classes
* which are not CopyConstructable.
*
* Use in the public section of the class.
*/
#define SMART_PTR_ALIASES_ONLY(...) \
__SHARED_PTR_ALIAS(__VA_ARGS__) \
__WEAK_PTR_ALIAS(__VA_ARGS__) \
__UNIQUE_PTR_ALIAS(__VA_ARGS__)

/// Defines aliases and static functions for using the Class with shared_ptrs.
#define SHARED_PTR_DEFINITIONS(...) \
__SHARED_PTR_ALIAS(__VA_ARGS__) \
__MAKE_SHARED_DEFINITION(__VA_ARGS__)

#define __SHARED_PTR_ALIAS(...) \
using SharedPtr = std::shared_ptr<__VA_ARGS__>; \
using ConstSharedPtr = std::shared_ptr<const __VA_ARGS__>;

#define __MAKE_SHARED_DEFINITION(...) \
template<typename ... Args> \
static std::shared_ptr<__VA_ARGS__> \
make_shared(Args && ... args) \
{ \
return std::make_shared<__VA_ARGS__>(std::forward<Args>(args) ...); \
}

/// Defines aliases and static functions for using the Class with weak_ptrs.
#define WEAK_PTR_DEFINITIONS(...) \
__WEAK_PTR_ALIAS(__VA_ARGS__)

#define __WEAK_PTR_ALIAS(...) \
using WeakPtr = std::weak_ptr<__VA_ARGS__>; \
using ConstWeakPtr = std::weak_ptr<const __VA_ARGS__>;

/// Defines aliases and static functions for using the Class with unique_ptrs.
#define UNIQUE_PTR_DEFINITIONS(...) \
__UNIQUE_PTR_ALIAS(__VA_ARGS__) \
__MAKE_UNIQUE_DEFINITION(__VA_ARGS__)

#define __UNIQUE_PTR_ALIAS(...) \
using UniquePtr = std::unique_ptr<__VA_ARGS__>;

#if __cplusplus >= 201402L
#define __MAKE_UNIQUE_DEFINITION(...) \
template<typename ... Args> \
static std::unique_ptr<__VA_ARGS__> \
make_unique(Args && ... args) \
{ \
return std::make_unique<__VA_ARGS__>(std::forward<Args>(args) ...); \
}
#else
#define __MAKE_UNIQUE_DEFINITION(...) \
template<typename ... Args> \
static std::unique_ptr<__VA_ARGS__> \
make_unique(Args && ... args) \
{ \
return std::unique_ptr<__VA_ARGS__>(new __VA_ARGS__(std::forward<Args>(args) ...)); \
}
#endif

#endif // FUSE_CORE_MACROS_H
Loading

0 comments on commit 6362b64

Please sign in to comment.