Skip to content

Commit

Permalink
Added export(PACKAGE ...) to CMakeLists.txt so that we can run find_p…
Browse files Browse the repository at this point in the history
…ackage(inekf) in the ROS wrapper
  • Loading branch information
RossHartley committed Sep 13, 2018
1 parent a922f23 commit c891229
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 8 deletions.
62 changes: 59 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DEIGEN_NO_DEBUG -march=native -Wl,-
project(inekf)

# Set the output folder where your program will be created
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
#set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
#set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
#set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)

############################################
# The following folders will be included #
Expand All @@ -26,10 +28,12 @@ find_package (Threads)
# Boost
find_package(Boost 1.58 REQUIRED COMPONENTS system)
include_directories(${Boost_INCLUDE_DIR})
message("Boost_INCLUDE_DIR: " ${Boost_INCLUDE_DIR})

# Eigen
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
message("EIGEN3_INCLUDE_DIR: " ${EIGEN3_INCLUDE_DIR})

# Adding all classes
file(GLOB src_files
Expand All @@ -48,6 +52,58 @@ add_executable(correction_speed ${PROJECT_SOURCE_DIR}/src/tests/correction_speed
target_link_libraries(landmarks ${Boost_LIBRARIES})
target_link_libraries(correction_speed ${Boost_LIBRARIES})

# Create Library
add_library(inekf SHARED
"${PROJECT_SOURCE_DIR}/src/InEKF.cpp"
"${PROJECT_SOURCE_DIR}/src/RobotState.cpp"
"${PROJECT_SOURCE_DIR}/src/LieGroup.cpp"
)
set_target_properties(inekf PROPERTIES LIBRARY_OUTPUT_NAME inekf)



#=============================================
# to allow find_package() on kindr
#=============================================
#
# the following case be used in an external project requiring kindr:
# ...
# find_package(kindr)
# include_directories(${kindr_INCLUDE_DIRS})
# ...

# NOTE: the following will support find_package for 1) local build (make) and 2) for installed files (make install)

# 1- local build #

# Register the local build in case one doesn't use "make install"
export(PACKAGE inekf)

# Create variable for the local build tree
#set_target_properties(inekf PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
get_property(inekf_include_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
get_property(inekf_library_dirs TARGET inekf PROPERTY LIBRARY_OUTPUT_DIRECTORY)
get_property(inekf_libraries TARGET inekf PROPERTY LIBRARY_OUTPUT_NAME)

message("inekf_include_dirs: " ${inekf_include_dirs})
message("inekf_library_dirs: " ${inekf_library_dirs})
message("inekf_libraries: " ${inekf_libraries})

# Configure config file for local build tree
configure_file(inekfConfig.cmake.in
"${PROJECT_BINARY_DIR}/inekfConfig.cmake" @ONLY)

message("PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR})

# # 2- installation build #

# # Change the include location for the case of an install location
# set(inekf_include_dirs ${CMAKE_INSTALL_PREFIX}/include ${EIGEN_INCLUDE_DIR})

# # We put the generated file for installation in a different repository (i.e., ./CMakeFiles/)
# configure_file(inekfConfig.cmake.in
# "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/inekfConfig.cmake" @ONLY)

# install(FILES
# "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/inekfConfig.cmake"
# DESTINATION share/inekf/cmake COMPONENT dev)
5 changes: 3 additions & 2 deletions include/InEKF.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "RobotState.h"
#include "LieGroup.h"

namespace inekf {

typedef std::map<int,Eigen::Vector3d,std::less<int>,Eigen::aligned_allocator<std::pair<const int,Eigen::Vector3d>>> mapIntVector3d;
typedef std::vector<std::pair<int,Eigen::Vector3d>> vectorPairIntVector3d;

Expand Down Expand Up @@ -93,6 +95,5 @@ class InEKF {
std::map<int,int> estimated_landmarks_;
};



} // end inekf namespace
#endif
3 changes: 3 additions & 0 deletions include/LieGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
#include <Eigen/Dense>
#include <iostream>

namespace inekf {

#define TOLERANCE 1e-10

Eigen::Matrix3d skew(const Eigen::Vector3d& v);
Eigen::Matrix3d Exp_SO3(const Eigen::Vector3d& w);
Eigen::MatrixXd Exp_SEK3(const Eigen::VectorXd& v);
Eigen::MatrixXd Adjoint_SEK3(const Eigen::MatrixXd& X);

} // end inekf namespace
#endif
3 changes: 3 additions & 0 deletions include/RobotState.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <Eigen/Dense>
#include <iostream>

namespace inekf {

class RobotState {

public:
Expand Down Expand Up @@ -44,4 +46,5 @@ class RobotState {

};

} // end inekf namespace
#endif
13 changes: 13 additions & 0 deletions inekfConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# - Config file for the inekf package
# It defines the following variables
# inekf_INCLUDE_DIRS - include directories for inekf
# inekf_LIBRARY_DIRS - directories for inekf library

# Compute paths
get_filename_component(inekf_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(inekf_INCLUDE_DIRS "@inekf_include_dirs@")
set(inekf_LIBRARY_DIRS "@inekf_library_dirs@")
set(inekf_LIBRARIES "@inekf_libraries@")

# This causes catkin_simple to link against these libraries
set(inekf_FOUND_CATKIN_PROJECT true)
8 changes: 6 additions & 2 deletions src/InEKF.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "InEKF.h"
using namespace std;

namespace inekf {

using namespace std;

// ------------ NoiseParams -------------
// Default Constructor
Expand Down Expand Up @@ -333,4 +335,6 @@ void InEKF::CorrectLandmarks(const vectorPairIntVector3d& measured_landmarks) {
}

return;
}
}

} // end inekf namespace
5 changes: 5 additions & 0 deletions src/LieGroup.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "LieGroup.h"

namespace inekf {

using namespace std;

Eigen::Matrix3d skew(const Eigen::Vector3d& v) {
Expand Down Expand Up @@ -62,3 +65,5 @@ Eigen::MatrixXd Adjoint_SEK3(const Eigen::MatrixXd& X) {
}
return Adj;
}

} // end inekf namespace
7 changes: 6 additions & 1 deletion src/RobotState.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "RobotState.h"
#include "LieGroup.h"

namespace inekf {

using namespace std;

// Default constructor
Expand Down Expand Up @@ -62,4 +65,6 @@ ostream& operator<<(ostream& os, const RobotState& s) {
os << "P:\n" << s.P_ << endl;
os << "-----------------------------------";
return os;
}
}

} // end inekf namespace
1 change: 1 addition & 0 deletions src/examples/landmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define DT_MAX 1

using namespace std;
using namespace inekf;

int main()
{
Expand Down
1 change: 1 addition & 0 deletions src/tests/correction_speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT

using namespace std;
using namespace inekf;

typedef vector<pair<double,Eigen::Matrix<double,6,1>>> vectorPairIntVector6d;

Expand Down
1 change: 1 addition & 0 deletions src/tests/propagation_speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define DT_MAX 1

using namespace std;
using namespace inekf;

typedef vector<pair<double,Eigen::Matrix<double,6,1>>> vectorPairIntVector6d;

Expand Down

0 comments on commit c891229

Please sign in to comment.