Skip to content

Commit

Permalink
Merge pull request #22 from yangmingustb/1227
Browse files Browse the repository at this point in the history
tool: add tf2
  • Loading branch information
yangmingustb authored Dec 28, 2023
2 parents 204ac55 + 4977982 commit abbf4e1
Show file tree
Hide file tree
Showing 41 changed files with 10,133 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ third_party/p*
third_party/R*
third_party/P*
third_party/l*
third_party/tf2/*
third_party/tf2/build/*
third_party/civetweb/*
third_party/install/*
third_party/tf2/*
third_party/civetweb/*
third_party/civetwe*
third_party/matplotlib-cpp*
Expand Down
20 changes: 18 additions & 2 deletions install_scripts/install_tf2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@

# ## How to build

set -e

CURRENT_PATH=$(cd $(dirname $0) && pwd)

cd ${CURRENT_PATH}
cd ..
cd third_party

cd tf2
rm -rf build
mkdir build && cd build
cmake .. -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/tf2
make -j$(nproc)


cmake .. -DCMAKE_INSTALL_PREFIX=../../install/tf2 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DBUILD_TESTS=OFF

make -j6

sudo make install



## gtest support for tf2-apollo

Expand Down
21 changes: 21 additions & 0 deletions third_party/tf2/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "tf2",
srcs = [
"src/buffer_core.cpp",
"src/cache.cpp",
"src/static_cache.cpp",
"src/time.cpp",
],
hdrs = glob([
"include/geometry_msgs/**",
"include/tf2_msgs/**",
"include/tf2/**",
]),
strip_include_prefix = "include",
visibility = ["//visibility:public"],
deps = [
"@boost",
],
)
384 changes: 384 additions & 0 deletions third_party/tf2/CHANGELOG.rst

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions third_party/tf2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.5)
project(tf2 CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "-fPIC -DNDEBUG -O3 -pipe -Wall")

# set (CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/build/install CACHE STRING "" FORCE)
# set (UNIT_TEST_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/tests CACHE STRING "" FORCE)
# set(CMAKE_CXX_FLAGS "-std=c++11 -pthread -fPIE -fPIC -Wno-deprecated -pipe -W -Werror -Wall -g -O2" CACHE STRING "" FORCE)

find_package(Boost REQUIRED COMPONENTS system thread)
include_directories(
include
${Boost_INCLUDE_DIR} # for signals2 is header only
)

option(BUILD_TESTS "Build the tests" ON)

# export user definitions
#CPP Libraries
add_library(tf2 SHARED
src/cache.cpp
src/buffer_core.cpp
src/static_cache.cpp
src/time.cpp
)

target_link_libraries(tf2
${Boost_LIBRARIES}
)

# ${catkin_LIBRARIES} ${console_bridge_LIBRARIES})

install(TARGETS ${PROJECT_NAME} DESTINATION
${CMAKE_INSTALL_PREFIX}/lib
)

install(DIRECTORY include DESTINATION
${CMAKE_INSTALL_PREFIX}
)

install(FILES README.md DESTINATION
${CMAKE_INSTALL_PREFIX}
)

if (BUILD_TESTS)
include(cmake/GTest.cmake)
fetch_googletest(
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_BINARY_DIR}/googletest
)
enable_testing()
add_subdirectory(test)
endif()
25 changes: 25 additions & 0 deletions third_party/tf2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# tf2-apollo

## Intro

tf2-apollo was Apollo's clone of ROS tf2 for coordinate transforms.
It seems that it was based on `ros/geometry2` tagged `0.5.16`

## How to build

```
mkdir build && cd build
cmake .. -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/tf2
make -j$(nproc)
sudo make install
```

## gtest support for tf2-apollo

In order not to build gtest into our docker image, gtest support for tf2 was
implemented according to https://crascit.com/2015/07/25/cmake-gtest

## Reference
- https://github.com/ros/geometry2
- http://wiki.ros.org/geometry2

33 changes: 33 additions & 0 deletions third_party/tf2/cmake/GTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# the following code to fetch googletest
# is inspired by and adapted after https://crascit.com/2015/07/25/cmake-gtest/
# download and unpack googletest at configure time

macro(fetch_googletest _download_module_path _download_root)
set(GOOGLETEST_DOWNLOAD_ROOT ${_download_root})
configure_file(
${_download_module_path}/GTestDownload.cmake
${_download_root}/CMakeLists.txt
@ONLY
)
unset(GOOGLETEST_DOWNLOAD_ROOT)

execute_process(
COMMAND
"${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY
${_download_root}
)
execute_process(
COMMAND
"${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY
${_download_root}
)

# adds the targers: gtest, gtest_main, gmock, gmock_main
add_subdirectory(
${_download_root}/googletest-src
${_download_root}/googletest-build
)
endmacro()

15 changes: 15 additions & 0 deletions third_party/tf2/cmake/GTestDownload.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# code copied from https://crascit.com/2015/07/25/cmake-gtest/
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(GoogleTestDownload NONE)

include(ExternalProject)
ExternalProject_Add(googletest
SOURCE_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-src"
BINARY_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-build"
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
Loading

0 comments on commit abbf4e1

Please sign in to comment.