Skip to content

Commit

Permalink
Merge pull request #59 from utiasASRL/C++11
Browse files Browse the repository at this point in the history
Get rid of boost dependency (in particular, switch to use standard library implementation of shared_ptr's)
  • Loading branch information
cheneyuwu authored Oct 28, 2021
2 parents 39369b7 + 29a1c3a commit 0905736
Show file tree
Hide file tree
Showing 76 changed files with 432 additions and 281 deletions.
48 changes: 8 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ if (NOT USE_AMENT)
set(PROJECT_VERSION 1.1.0)

# Find dependencies
find_package(Boost 1.71.0 REQUIRED system)
find_package(OpenMP REQUIRED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
Expand All @@ -31,9 +30,7 @@ find_package(lgmath 1.1.0 REQUIRED)
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME}
PUBLIC
${Boost_LIBRARIES}
lgmath
PUBLIC lgmath
)
target_include_directories(${PROJECT_NAME}
PUBLIC
Expand Down Expand Up @@ -95,7 +92,6 @@ else()

# Find dependencies
find_package(ament_cmake REQUIRED)
find_package(Boost REQUIRED system)
find_package(OpenMP REQUIRED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
Expand All @@ -106,31 +102,23 @@ find_package(lgmath REQUIRED)
# Libraries
file(GLOB_RECURSE SOURCE src/*.cpp)
add_library(${PROJECT_NAME} ${SOURCE})
ament_target_dependencies(${PROJECT_NAME} Boost Eigen3 OpenMP lgmath)
ament_target_dependencies(${PROJECT_NAME} Eigen3 OpenMP lgmath)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)


ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
# May need the following
ament_export_dependencies(
Boost
Eigen3
OpenMP
lgmath
)
ament_export_dependencies(eigen3_cmake_module)
ament_export_dependencies(OpenMP Eigen3 lgmath)

install(
DIRECTORY include/
DESTINATION include
)

install(
TARGETS
# Libraries
${PROJECT_NAME}
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
Expand All @@ -141,41 +129,20 @@ install(
endif()

# Executables
link_libraries(${PROJECT_NAME})
add_executable(SimpleBAandTrajPrior samples/SimpleBAandTrajPrior.cpp)
target_link_libraries(SimpleBAandTrajPrior ${PROJECT_NAME})

add_executable(SimpleBAandCATrajPrior samples/SimpleBAandCATrajPrior.cpp)
target_link_libraries(SimpleBAandCATrajPrior ${PROJECT_NAME})

add_executable(SimpleBundleAdjustment samples/SimpleBundleAdjustment.cpp)
target_link_libraries(SimpleBundleAdjustment ${PROJECT_NAME})

add_executable(SimpleBundleAdjustmentFullRel samples/SimpleBundleAdjustmentFullRel.cpp)
target_link_libraries(SimpleBundleAdjustmentFullRel ${PROJECT_NAME})

add_executable(SimpleBundleAdjustmentRelLand samples/SimpleBundleAdjustmentRelLand.cpp)
target_link_libraries(SimpleBundleAdjustmentRelLand ${PROJECT_NAME})

add_executable(SimpleBundleAdjustmentRelLandX samples/SimpleBundleAdjustmentRelLandX.cpp)
target_link_libraries(SimpleBundleAdjustmentRelLandX ${PROJECT_NAME})

add_executable(SimplePoseGraphRelax samples/SimplePoseGraphRelax.cpp)
target_link_libraries(SimplePoseGraphRelax ${PROJECT_NAME})

add_executable(SimpleTrajectoryPrior samples/SimpleTrajectoryPrior.cpp)
target_link_libraries(SimpleTrajectoryPrior ${PROJECT_NAME})

add_executable(SpherePoseGraphRelax samples/SpherePoseGraphRelax.cpp)
target_link_libraries(SpherePoseGraphRelax ${PROJECT_NAME})

add_executable(TrustRegionExample samples/TrustRegionExample.cpp)
target_link_libraries(TrustRegionExample ${PROJECT_NAME})

add_executable(MotionDistortedP2PandCATrajPrior samples/MotionDistortedP2PandCATrajPrior.cpp)
target_link_libraries(MotionDistortedP2PandCATrajPrior ${PROJECT_NAME})

add_executable(SimpleP2PandCATrajPrior samples/SimpleP2PandCATrajPrior.cpp)
target_link_libraries(SimpleP2PandCATrajPrior ${PROJECT_NAME})
add_executable(SimplePointCloudAlignment samples/SimplePointCloudAlignment.cpp)

if (USE_AMENT)

Expand All @@ -194,6 +161,7 @@ install(
TrustRegionExample
MotionDistortedP2PandCATrajPrior
SimpleP2PandCATrajPrior
SimplePointCloudAlignment
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ CMD ["/bin/bash"]
ARG DEBIAN_FRONTEND=noninteractive

RUN apt update

RUN apt install -q -y curl gnupg2 lsb-release build-essential cmake
RUN apt install -q -y libboost-all-dev libomp-dev
RUN apt install -q -y libeigen3-dev
RUN apt install -q -y libeigen3-dev libomp-dev
8 changes: 4 additions & 4 deletions Dockerfile.ROS2
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ros:foxy
FROM ros:galactic

CMD ["/bin/bash"]

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt install -q -y curl gnupg2 lsb-release build-essential
RUN apt install -q -y libboost-all-dev libomp-dev
RUN apt install -q -y python3-colcon-core python3-colcon-common-extensions
RUN apt install -q -y curl gnupg2 lsb-release build-essential cmake
RUN apt install -q -y python3-colcon-core python3-colcon-common-extensions
RUN apt install -q -y libeigen3-dev libomp-dev
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pipeline {
dir('lgmath') {
git branch: 'master', url: 'https://github.com/utiasASRL/lgmath.git'
sh '''
source /opt/ros/foxy/setup.bash
source /opt/ros/galactic/setup.bash
colcon build --symlink-install --cmake-args "-DUSE_AMENT=ON"
touch COLGON_IGNORE
'''
Expand Down
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ STEAM (Simultaneous Trajectory Estimation and Mapping) Engine is an optimization

- Compiler with C++17 support and OpenMP
- CMake (>=3.16)
- Boost (>=1.71.0)
- Eigen (>=3.3.7)
- [lgmath (>=1.1.0)](https://github.com/utiasASRL/lgmath.git)
- (Optional) ROS2 Foxy or later (colcon+ament_cmake)
Expand All @@ -21,22 +20,6 @@ STEAM (Simultaneous Trajectory Estimation and Mapping) Engine is an optimization
sudo apt -q -y install build-essential cmake libomp-dev
```

### Install Boost

```bash
# using APT
sudo apt -q -y install libboost-all-dev

# OR from source
WORKSPACE=~/workspace # choose your own workspace directory
mkdir -p ${WORKSPACE}/boost && cd $_
wget --no-verbose https://boostorg.jfrog.io/artifactory/main/release/1.71.0/source/boost_1_71_0.tar.gz
tar xzf boost_1_71_0.tar.gz && cd boost_1_71_0
./bootstrap.sh --with-python=$(which python3)
./b2 cxxflags="-std=gnu++17" install
ldconfig
```

### Install Eigen (>=3.3.7)

```bash
Expand Down
1 change: 1 addition & 0 deletions include/steam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <steam/evaluator/samples/LinearFuncErrorEval.hpp>
#include <steam/evaluator/samples/ImuErrorEval.hpp>
#include <steam/evaluator/samples/PointToPointErrorEval.hpp>
#include <steam/evaluator/samples/PointToPointErrorEval2.hpp>

// evaluator - block auto diff
#include <steam/evaluator/blockauto/EvalTreeNode.hpp>
Expand Down
13 changes: 6 additions & 7 deletions include/steam/common/Time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define STEAM_TIME_HPP

#include <iostream>
#include <boost/cstdint.hpp>

namespace steam {

Expand All @@ -20,11 +19,11 @@ namespace steam {
class Time {
public:
Time() : nsecs_(0) {}
Time(boost::int64_t nsecs) : nsecs_(nsecs) {}
Time(int64_t nsecs) : nsecs_(nsecs) {}
Time(double secs) : nsecs_(secs*1e9) {}
Time(boost::int32_t secs, boost::int32_t nsec) {
boost::int64_t t1 = (boost::int64_t) secs;
boost::int64_t t2 = (boost::int64_t) nsec;
Time(int32_t secs, int32_t nsec) {
int64_t t1 = (int64_t) secs;
int64_t t2 = (int64_t) nsec;
this->nsecs_ = t1*1000000000 + t2;
}

Expand All @@ -44,7 +43,7 @@ class Time {
/// Usually it makes sense to use this method after *this* has been reduced to a
/// duration between two times.
//////////////////////////////////////////////////////////////////////////////////////////////
const boost::int64_t& nanosecs() const {
const int64_t& nanosecs() const {
return nsecs_;
}

Expand Down Expand Up @@ -108,7 +107,7 @@ class Time {
/// seconds since epoch and 1e9 nsecs. Furthermore, a single base type, rather than
/// two combined unsigned int32s to allow nsecs to be used as a key in a std::map.
//////////////////////////////////////////////////////////////////////////////////////////////
boost::int64_t nsecs_;
int64_t nsecs_;

};

Expand Down
1 change: 0 additions & 1 deletion include/steam/common/Timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// system timer
#include <sys/time.h>
#include <iostream>
#include <boost/cstdint.hpp>

namespace steam {

Expand Down
4 changes: 2 additions & 2 deletions include/steam/evaluator/ErrorEvaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ template<int MEAS_DIM, // Dimension of the measurement error. Note the mea
int MAX_STATE_SIZE> // The maximum dimension of a single state variable perturbation
struct ErrorEvaluator{
typedef EvaluatorBase<Eigen::Matrix<double, MEAS_DIM, 1>,MEAS_DIM,MEAS_DIM,MAX_STATE_SIZE> type;
typedef boost::shared_ptr<type> Ptr;
typedef boost::shared_ptr<const type> ConstPtr;
typedef std::shared_ptr<type> Ptr;
typedef std::shared_ptr<const type> ConstPtr;
};

//////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions include/steam/evaluator/EvaluatorBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class EvaluatorBase
public:

/// Convenience typedefs
typedef boost::shared_ptr<EvaluatorBase<TYPE,LHS_DIM,INNER_DIM,MAX_STATE_DIM> > Ptr;
typedef boost::shared_ptr<const EvaluatorBase<TYPE,LHS_DIM,INNER_DIM,MAX_STATE_DIM> > ConstPtr;
typedef std::shared_ptr<EvaluatorBase<TYPE,LHS_DIM,INNER_DIM,MAX_STATE_DIM> > Ptr;
typedef std::shared_ptr<const EvaluatorBase<TYPE,LHS_DIM,INNER_DIM,MAX_STATE_DIM> > ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Default constructor
Expand Down
4 changes: 2 additions & 2 deletions include/steam/evaluator/blockauto/BlockAutomaticEvaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class BlockAutomaticEvaluator : public EvaluatorBase<TYPE>
public:

/// Convenience typedefs
typedef boost::shared_ptr<BlockAutomaticEvaluator<TYPE,INNER_DIM,MAX_STATE_SIZE> > Ptr;
typedef boost::shared_ptr<const BlockAutomaticEvaluator<TYPE,INNER_DIM,MAX_STATE_SIZE> > ConstPtr;
typedef std::shared_ptr<BlockAutomaticEvaluator<TYPE,INNER_DIM,MAX_STATE_SIZE> > Ptr;
typedef std::shared_ptr<const BlockAutomaticEvaluator<TYPE,INNER_DIM,MAX_STATE_SIZE> > ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Default constructor
Expand Down
1 change: 0 additions & 1 deletion include/steam/evaluator/blockauto/EvalTreeNode-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////

#include <steam/evaluator/blockauto/EvalTreeNode.hpp>
#include <boost/make_shared.hpp>

namespace steam {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class ComposeInverseTransformEvaluator : public TransformEvaluator
public:

/// Convenience typedefs
typedef boost::shared_ptr<ComposeInverseTransformEvaluator> Ptr;
typedef boost::shared_ptr<const ComposeInverseTransformEvaluator> ConstPtr;
typedef std::shared_ptr<ComposeInverseTransformEvaluator> Ptr;
typedef std::shared_ptr<const ComposeInverseTransformEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor -- T_ba = T_bx * inv(T_ax)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class ComposeLandmarkEvaluator : public BlockAutomaticEvaluator<Eigen::Vector4d,
public:

/// Convenience typedefs
typedef boost::shared_ptr<ComposeLandmarkEvaluator> Ptr;
typedef boost::shared_ptr<const ComposeLandmarkEvaluator> ConstPtr;
typedef std::shared_ptr<ComposeLandmarkEvaluator> Ptr;
typedef std::shared_ptr<const ComposeLandmarkEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class ComposeTransformEvaluator : public TransformEvaluator
public:

/// Convenience typedefs
typedef boost::shared_ptr<ComposeTransformEvaluator> Ptr;
typedef boost::shared_ptr<const ComposeTransformEvaluator> ConstPtr;
typedef std::shared_ptr<ComposeTransformEvaluator> Ptr;
typedef std::shared_ptr<const ComposeTransformEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class ConstAccTransformEvaluator : public TransformEvaluator
public:

/// Convenience typedefs
typedef boost::shared_ptr<ConstAccTransformEvaluator> Ptr;
typedef boost::shared_ptr<const ConstAccTransformEvaluator> ConstPtr;
typedef std::shared_ptr<ConstAccTransformEvaluator> Ptr;
typedef std::shared_ptr<const ConstAccTransformEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class ConstVelTransformEvaluator : public TransformEvaluator
public:

/// Convenience typedefs
typedef boost::shared_ptr<ConstVelTransformEvaluator> Ptr;
typedef boost::shared_ptr<const ConstVelTransformEvaluator> ConstPtr;
typedef std::shared_ptr<ConstVelTransformEvaluator> Ptr;
typedef std::shared_ptr<const ConstVelTransformEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class FixedTransformEvaluator : public TransformEvaluator
public:

/// Convenience typedefs
typedef boost::shared_ptr<FixedTransformEvaluator> Ptr;
typedef boost::shared_ptr<const FixedTransformEvaluator> ConstPtr;
typedef std::shared_ptr<FixedTransformEvaluator> Ptr;
typedef std::shared_ptr<const FixedTransformEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class InverseTransformEvaluator : public TransformEvaluator
public:

/// Convenience typedefs
typedef boost::shared_ptr<InverseTransformEvaluator> Ptr;
typedef boost::shared_ptr<const InverseTransformEvaluator> ConstPtr;
typedef std::shared_ptr<InverseTransformEvaluator> Ptr;
typedef std::shared_ptr<const InverseTransformEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class LogMapEvaluator : public BlockAutomaticEvaluator<Eigen::Matrix<double,6,1>
public:

/// Convenience typedefs
typedef boost::shared_ptr<LogMapEvaluator> Ptr;
typedef boost::shared_ptr<const LogMapEvaluator> ConstPtr;
typedef std::shared_ptr<LogMapEvaluator> Ptr;
typedef std::shared_ptr<const LogMapEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class PositionEvaluator : public BlockAutomaticEvaluator<Eigen::Matrix<double, 3
public:

/// Convenience typedefs
typedef boost::shared_ptr<PositionEvaluator> Ptr;
typedef boost::shared_ptr<const PositionEvaluator> ConstPtr;
typedef std::shared_ptr<PositionEvaluator> Ptr;
typedef std::shared_ptr<const PositionEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class TransformStateEvaluator : public TransformEvaluator
public:

/// Convenience typedefs
typedef boost::shared_ptr<TransformStateEvaluator> Ptr;
typedef boost::shared_ptr<const TransformStateEvaluator> ConstPtr;
typedef std::shared_ptr<TransformStateEvaluator> Ptr;
typedef std::shared_ptr<const TransformStateEvaluator> ConstPtr;

//////////////////////////////////////////////////////////////////////////////////////////////
/// \brief Constructor
Expand Down
Loading

0 comments on commit 0905736

Please sign in to comment.