Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf2_ros is not built for Python #99

Merged
merged 79 commits into from Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d29c620
made tf2_py compile with ROS2
BrannonKing Jun 21, 2017
ec0a7cf
fixed package ordering, time message conversion
BrannonKing Jun 25, 2017
09ad997
fixed dll deployment
BrannonKing Jun 26, 2017
12addd4
fix the installation path of tf2_py
vinnamkim Mar 16, 2019
851dc26
Port tf2_ros
vinnamkim Mar 16, 2019
a61f8c7
Port tf2_ros/buffer_client.py
vinnamkim Mar 16, 2019
9caefc4
Fix build errors because of ament_lint_auto dependency
vinnamkim Mar 16, 2019
9759d04
Fix tf2_py
vinnamkim Mar 22, 2019
c02ddb1
made tf2_py compile with ROS2
BrannonKing Jun 21, 2017
38ca50f
Fix some codes
vinnamkim Mar 16, 2019
dc1dac6
Rebase to the latest ros2
vinnamkim Aug 9, 2019
27129fd
Revert removing geometry2 and geometry_experimental
vinnamkim Aug 12, 2019
821a7a7
Fix build script of tf2_py with respect to the review
vinnamkim Aug 12, 2019
f034a4e
Remove unnecessary whitespace changes
vinnamkim Aug 12, 2019
9d421a2
Trim trailing whitespace
vinnamkim Aug 12, 2019
60bde6c
Fix Py_DECREF order
vinnamkim Aug 12, 2019
cb9542b
Remove the unused variable
vinnamkim Aug 12, 2019
e44dbb7
Prevent floating number conversion from getLatestCommonTime
vinnamkim Aug 12, 2019
170e4e3
Remove unused imports
vinnamkim Aug 12, 2019
10232f5
Fix colcon test error on pytest
vinnamkim Aug 12, 2019
7cc4d83
Add geometry_msgs dependency to tf2_py
vinnamkim Aug 12, 2019
94a82ca
Cleanup.
clalancette Aug 13, 2019
8f68f22
Fixes for Windows.
clalancette Aug 16, 2019
afe4411
Fix some initializer warnings.
clalancette Aug 16, 2019
a0b23f0
Prevent transform_listener.py from finding an attribute not existed i…
vinnamkim Aug 19, 2019
907f915
Add unit test for broadcaster and listner
vinnamkim Aug 19, 2019
48f37f8
Add static broadcaster unit test
vinnamkim Aug 19, 2019
c82596f
Make tf2_ros Python consistent with transform_listener, transform_bro…
vinnamkim Aug 21, 2019
3cacf52
Document python_compat functions
sloretz Aug 27, 2019
3610851
transform_convert error handling fixes
sloretz Aug 27, 2019
a9221c4
Eliminate constants
sloretz Aug 28, 2019
65e5714
Static QoS uses TransientLocal
sloretz Aug 29, 2019
29cd0f7
TransformListener uses its own callback group
sloretz Aug 29, 2019
1d65f3d
Remove debug print
sloretz Aug 29, 2019
dc9249f
Ask node to destroy subscription
sloretz Aug 29, 2019
c343dc4
Add lookup_transform_async()
sloretz Aug 30, 2019
d71c138
Simplify async function
sloretz Aug 30, 2019
a8ea8f3
Full async transform methods
sloretz Aug 30, 2019
77b434e
Add shortcut to avoid suspending if result is already available
sloretz Aug 30, 2019
f175752
Add test for async transform lookup
sloretz Aug 30, 2019
1d66d12
Remove redundant code
sloretz Sep 3, 2019
a8a8a88
Remove unused __is_done()
sloretz Sep 3, 2019
17d9b23
TODO why not service
sloretz Sep 3, 2019
3bc5bc5
Remove unnecessary list check
sloretz Sep 3, 2019
e88b319
Better checks for lists of transforms
sloretz Sep 3, 2019
9bdc25c
Default spin_thread to False
sloretz Sep 4, 2019
5f6f673
Error checking in rostime_converter
sloretz Sep 4, 2019
87ad785
rostime_converter error handling fixes
sloretz Sep 4, 2019
f346d9d
Simpler error handling
sloretz Sep 4, 2019
42d94f0
time -> duration
sloretz Sep 4, 2019
c5b3588
Simple error checking
sloretz Sep 4, 2019
f5d834e
error handling in getLatestCommonTime()
sloretz Sep 4, 2019
020b78b
spell test_tf2_py out for searchability
sloretz Sep 4, 2019
d8952e6
Static Broadcaster QoS depth 1
sloretz Sep 5, 2019
5af17bd
Unintent docstring
sloretz Sep 5, 2019
46eea00
Restore whitespace
sloretz Sep 5, 2019
7e1c7a0
Return future so callers can add done callbacks
sloretz Sep 5, 2019
5afe830
wait_for_transform_async returns Future
sloretz Sep 5, 2019
c074025
Whitespace and bug fix
sloretz Sep 5, 2019
c3b48e4
Test asyncronous lookup_transform methods
sloretz Sep 5, 2019
cef9781
Fix source/target mixup
sloretz Sep 5, 2019
a16cf15
Single quotes
sloretz Sep 5, 2019
f3b726e
Remove commented code
sloretz Sep 5, 2019
3e4532f
Remove commented code
sloretz Sep 5, 2019
47730a1
More specific node name
sloretz Sep 5, 2019
0c77383
Remove debug and unindent __init__
sloretz Sep 5, 2019
5b3f6ea
Update licenses
vinnamkim Sep 11, 2019
ca506ea
Only add __init__.py to build space when testing
sloretz Sep 13, 2019
474acfc
Remove example comments from package.xml
sloretz Sep 13, 2019
a07175f
Remove shebag from __init__.py
sloretz Sep 13, 2019
5afe619
Remove test_depend that are exec_depend
sloretz Sep 13, 2019
75d9e2e
Space between if and ( in new code
sloretz Sep 13, 2019
c95f0d9
Update TfListener __init__ docstr
sloretz Sep 13, 2019
c0a7156
Remove unnecessary str()
sloretz Sep 13, 2019
cfaa623
Add -Wpedantic
sloretz Sep 13, 2019
e737d33
Big cleanup block with goto
sloretz Sep 13, 2019
b40f5ee
Cleanup cleanup in getLatestCommonTime()
sloretz Sep 13, 2019
d380c38
Check for null before using pointers
sloretz Sep 13, 2019
c7a9c20
Minor style fixup in new code.
clalancette Sep 16, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file removed tf2_py/AMENT_IGNORE
Empty file.
211 changes: 65 additions & 146 deletions tf2_py/CMakeLists.txt
@@ -1,157 +1,76 @@
cmake_minimum_required(VERSION 3.5)
project(tf2_py)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS rospy tf2)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


find_package(PythonLibs 2 REQUIRED)
include_directories(${PYTHON_INCLUDE_PATH} ${catkin_INCLUDE_DIRS})

## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
catkin_python_setup()

#######################################
## Declare ROS messages and services ##
#######################################

## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )

## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )

## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs # Or other packages containing msgs
# )

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES tf2_py
CATKIN_DEPENDS rospy tf2
# DEPENDS system_lib
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2 REQUIRED)

find_package(python_cmake_module REQUIRED)
find_package(PythonExtra REQUIRED)

set(_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")

if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}")
endif()

ament_python_install_package(${PROJECT_NAME})

function(set_properties _targetname _build_type)
set_target_properties(${_targetname} PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY${_build_type} "${CMAKE_CURRENT_BINARY_DIR}/test_tf2_py"
RUNTIME_OUTPUT_DIRECTORY${_build_type} "${CMAKE_CURRENT_BINARY_DIR}/test_tf2_py"
OUTPUT_NAME "_${_targetname}${PythonExtra_EXTENSION_SUFFIX}"
SUFFIX "${PythonExtra_EXTENSION_EXTENSION}")
endfunction()

add_library(${PROJECT_NAME} SHARED src/tf2_py.cpp)

set_properties(${PROJECT_NAME} "")
if(WIN32)
set_properties(${PROJECT_NAME} "_DEBUG")
set_properties(${PROJECT_NAME} "_MINSIZEREL")
set_properties(${PROJECT_NAME} "_RELEASE")
set_properties(${PROJECT_NAME} "_RELWITHDEBINFO")
endif()

ament_target_dependencies(${PROJECT_NAME}
"geometry_msgs"
"tf2"
"PythonExtra"
)

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

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})

## Declare a cpp library
# add_library(tf2_py
# src/${PROJECT_NAME}/tf2_py.cpp
# )

## Declare a cpp executable
# add_executable(tf2_py_node src/tf2_py_node.cpp)

## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
# add_dependencies(tf2_py_node tf2_py_generate_messages_cpp)

## Specify libraries to link a library or executable target against
# target_link_libraries(tf2_py_node
# ${catkin_LIBRARIES}
# )


# Check for SSE
#!!! rosbuild_check_for_sse()

# Dynamic linking with tf worked OK, except for exception propagation, which failed in the unit test.
# so build with the objects directly instead.
install(TARGETS
${PROJECT_NAME}
DESTINATION ${PYTHON_INSTALL_DIR}/${PROJECT_NAME}
)

link_libraries(${PYTHON_LIBRARIES})
add_library(tf2_py src/tf2_py.cpp)
target_link_libraries(tf2_py ${catkin_LIBRARIES})
add_dependencies(tf2_py tf2_msgs_gencpp)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

set_target_properties(tf2_py PROPERTIES OUTPUT_NAME tf2 PREFIX "_" SUFFIX ".so")
set_target_properties(tf2_py PROPERTIES COMPILE_FLAGS "-g -Wno-missing-field-initializers")
set_target_properties(tf2_py PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}
LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}
)
#!! rosbuild_add_compile_flags(tf2_py ${SSE_FLAGS}) #conditionally adds sse flags if available


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

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables and/or libraries for installation
# install(TARGETS tf2_py tf2_py_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

install(FILES ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}/_tf2.so
DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}
)
find_package(ament_cmake_pytest REQUIRED)

ament_add_pytest_test(tf2_py_test test
PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}"
APPEND_ENV PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}
)

#############
## Testing ##
#############
# Create importable location in build directory
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_tf2_py/__init__.py" "")
endif()

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_tf2_py.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
set(PYTHON_EXECUTABLE "${_PYTHON_EXECUTABLE}")

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
ament_package()
48 changes: 12 additions & 36 deletions tf2_py/package.xml
@@ -1,55 +1,31 @@
<?xml version="1.0"?>
<package>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>tf2_py</name>
<version>0.9.1</version>
<description>The tf2_py package</description>

<!-- One maintainer tag required, multiple allowed, one person per tag -->
<maintainer email="tfoote@osrfoundation.org">Tully Foote</maintainer>


<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>BSD</license>


<!-- Url tags are optional, but mutiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<url type="website">http://ros.org/wiki/tf2_py</url>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>python_cmake_module</buildtool_depend>

<!-- Author tags are optional, mutiple are allowed, one per tag -->
<!-- Authors do not have to be maintianers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<build_depend>geometry_msgs</build_depend>

<depend>tf2</depend>

<!-- The *_depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use run_depend for packages you need at runtime: -->
<!-- <run_depend>message_runtime</run_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>tf2</build_depend>
<build_depend>rospy</build_depend>
<run_depend>tf2</run_depend>
<run_depend>rospy</run_depend>
<exec_depend>builtin_interfaces</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>rclpy</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_cmake_pytest</test_depend>

<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- You can specify that this package is a metapackage here: -->
<!-- <metapackage/> -->

<!-- Other tools can request additional information be placed here -->

<build_type>ament_cmake</build_type>
</export>
</package>
12 changes: 0 additions & 12 deletions tf2_py/setup.py

This file was deleted.

33 changes: 29 additions & 4 deletions tf2_py/src/python_compat.h
Expand Up @@ -5,6 +5,10 @@

#include <string>

/// \brief Converts a C++ string into a Python string.
/// \note The caller is responsible for decref'ing the returned object.
/// \note If the return value is NULL then an exception is set.
/// \return a new PyObject reference, or NULL
inline PyObject *stringToPython(const std::string &input)
{
#if PY_MAJOR_VERSION >= 3
Expand All @@ -14,6 +18,10 @@ inline PyObject *stringToPython(const std::string &input)
#endif
}

/// \brief Converts a C string into a Python string.
/// \note The caller is responsible for decref'ing the returned object.
/// \note If the return value is NULL then an exception is set.
/// \return a new PyObject reference, or NULL
inline PyObject *stringToPython(const char *input)
{
#if PY_MAJOR_VERSION >= 3
Expand All @@ -23,10 +31,16 @@ inline PyObject *stringToPython(const char *input)
#endif
}

/// \brief Converts a Python string into a C++ string.
/// \note The input PyObject is borrowed, and will not be decref'd.
/// \note It's possible for this function to set an exception.
/// If the returned string is empty, callers should check if an exception was
/// set using PyErr_Ocurred().
/// \return a new std::string instance
inline std::string stringFromPython(PyObject * input)
{
Py_ssize_t size;
char * data;
const char * data;
#if PY_MAJOR_VERSION >= 3
data = PyUnicode_AsUTF8AndSize(input, &size);
#else
Expand All @@ -35,19 +49,30 @@ inline std::string stringFromPython(PyObject * input)
return std::string(data, size);
}

/// \brief Imports a python module by name.
/// \note The caller is responsible for decref'ing the returned object.
/// \note If the return value is NULL then an exception is set.
/// \return a reference to the imported module.
inline PyObject *pythonImport(const std::string & name)
{
PyObject *py_name = stringToPython(name);
if (!py_name) {
return nullptr;
}
PyObject *module = PyImport_Import(py_name);
Py_XDECREF(py_name);
return module;
}

/// \brief Borrow an attribute on an object.
/// \note The caller must not decref the returned object.
/// \note If the return value is NULL then an exception is set.
/// \return a reference to the attribute on the object.
inline PyObject *pythonBorrowAttrString(PyObject* o, const char *name)
{
PyObject *r = PyObject_GetAttrString(o, name);
Py_XDECREF(r);
return r;
PyObject *r = PyObject_GetAttrString(o, name);
Py_XDECREF(r);
return r;
}

#endif