repo_id stringlengths 19 138 | file_path stringlengths 32 200 | content stringlengths 1 12.9M | __index_level_0__ int64 0 0 |
|---|---|---|---|
apollo_public_repos/apollo-platform/ros/geometry2/tf2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2/src/cache.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Tully Foote */
#include "tf2/time_cache.h"
#include "tf2/exceptions.h"
#include <tf2/LinearMath/Vector3.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2/LinearMath/Transform.h>
#include <geometry_msgs/TransformStamped.h>
#include <assert.h>
using namespace tf2;
TransformStorage::TransformStorage()
{
}
TransformStorage::TransformStorage(const geometry_msgs::TransformStamped& data, CompactFrameID frame_id,
CompactFrameID child_frame_id)
: stamp_(data.header.stamp)
, frame_id_(frame_id)
, child_frame_id_(child_frame_id)
{
const geometry_msgs::Quaternion& o = data.transform.rotation;
rotation_ = tf2::Quaternion(o.x, o.y, o.z, o.w);
const geometry_msgs::Vector3& v = data.transform.translation;
translation_ = tf2::Vector3(v.x, v.y, v.z);
}
TimeCache::TimeCache(ros::Duration max_storage_time)
: max_storage_time_(max_storage_time)
{}
// hoisting these into separate functions causes an ~8% speedup. Removing calling them altogether adds another ~10%
void createExtrapolationException1(ros::Time t0, ros::Time t1, std::string* error_str)
{
if (error_str)
{
std::stringstream ss;
ss << "Lookup would require extrapolation at time " << t0 << ", but only time " << t1 << " is in the buffer";
*error_str = ss.str();
}
}
void createExtrapolationException2(ros::Time t0, ros::Time t1, std::string* error_str)
{
if (error_str)
{
std::stringstream ss;
ss << "Lookup would require extrapolation into the future. Requested time " << t0 << " but the latest data is at time " << t1;
*error_str = ss.str();
}
}
void createExtrapolationException3(ros::Time t0, ros::Time t1, std::string* error_str)
{
if (error_str)
{
std::stringstream ss;
ss << "Lookup would require extrapolation into the past. Requested time " << t0 << " but the earliest data is at time " << t1;
*error_str = ss.str();
}
}
uint8_t TimeCache::findClosest(TransformStorage*& one, TransformStorage*& two, ros::Time target_time, std::string* error_str)
{
//No values stored
if (storage_.empty())
{
return 0;
}
//If time == 0 return the latest
if (target_time.isZero())
{
one = &storage_.front();
return 1;
}
// One value stored
if (++storage_.begin() == storage_.end())
{
TransformStorage& ts = *storage_.begin();
if (ts.stamp_ == target_time)
{
one = &ts;
return 1;
}
else
{
createExtrapolationException1(target_time, ts.stamp_, error_str);
return 0;
}
}
ros::Time latest_time = (*storage_.begin()).stamp_;
ros::Time earliest_time = (*(storage_.rbegin())).stamp_;
if (target_time == latest_time)
{
one = &(*storage_.begin());
return 1;
}
else if (target_time == earliest_time)
{
one = &(*storage_.rbegin());
return 1;
}
// Catch cases that would require extrapolation
else if (target_time > latest_time)
{
createExtrapolationException2(target_time, latest_time, error_str);
return 0;
}
else if (target_time < earliest_time)
{
createExtrapolationException3(target_time, earliest_time, error_str);
return 0;
}
//At least 2 values stored
//Find the first value less than the target value
L_TransformStorage::iterator storage_it = storage_.begin();
while(storage_it != storage_.end())
{
if (storage_it->stamp_ <= target_time)
break;
storage_it++;
}
//Finally the case were somewhere in the middle Guarenteed no extrapolation :-)
one = &*(storage_it); //Older
two = &*(--storage_it); //Newer
return 2;
}
void TimeCache::interpolate(const TransformStorage& one, const TransformStorage& two, ros::Time time, TransformStorage& output)
{
// Check for zero distance case
if( two.stamp_ == one.stamp_ )
{
output = two;
return;
}
//Calculate the ratio
tf2Scalar ratio = (time.toSec() - one.stamp_.toSec()) / (two.stamp_.toSec() - one.stamp_.toSec());
//Interpolate translation
output.translation_.setInterpolate3(one.translation_, two.translation_, ratio);
//Interpolate rotation
output.rotation_ = slerp( one.rotation_, two.rotation_, ratio);
output.stamp_ = one.stamp_;
output.frame_id_ = one.frame_id_;
output.child_frame_id_ = one.child_frame_id_;
}
bool TimeCache::getData(ros::Time time, TransformStorage & data_out, std::string* error_str) //returns false if data not available
{
TransformStorage* p_temp_1;
TransformStorage* p_temp_2;
int num_nodes = findClosest(p_temp_1, p_temp_2, time, error_str);
if (num_nodes == 0)
{
return false;
}
else if (num_nodes == 1)
{
data_out = *p_temp_1;
}
else if (num_nodes == 2)
{
if( p_temp_1->frame_id_ == p_temp_2->frame_id_)
{
interpolate(*p_temp_1, *p_temp_2, time, data_out);
}
else
{
data_out = *p_temp_1;
}
}
else
{
assert(0);
}
return true;
}
CompactFrameID TimeCache::getParent(ros::Time time, std::string* error_str)
{
TransformStorage* p_temp_1;
TransformStorage* p_temp_2;
int num_nodes = findClosest(p_temp_1, p_temp_2, time, error_str);
if (num_nodes == 0)
{
return 0;
}
return p_temp_1->frame_id_;
}
bool TimeCache::insertData(const TransformStorage& new_data)
{
L_TransformStorage::iterator storage_it = storage_.begin();
if(storage_it != storage_.end())
{
if (storage_it->stamp_ > new_data.stamp_ + max_storage_time_)
{
return false;
}
}
while(storage_it != storage_.end())
{
if (storage_it->stamp_ <= new_data.stamp_)
break;
storage_it++;
}
storage_.insert(storage_it, new_data);
pruneList();
return true;
}
void TimeCache::clearList()
{
storage_.clear();
}
unsigned int TimeCache::getListLength()
{
return storage_.size();
}
P_TimeAndFrameID TimeCache::getLatestTimeAndParent()
{
if (storage_.empty())
{
return std::make_pair(ros::Time(), 0);
}
const TransformStorage& ts = storage_.front();
return std::make_pair(ts.stamp_, ts.frame_id_);
}
ros::Time TimeCache::getLatestTimestamp()
{
if (storage_.empty()) return ros::Time(); //empty list case
return storage_.front().stamp_;
}
ros::Time TimeCache::getOldestTimestamp()
{
if (storage_.empty()) return ros::Time(); //empty list case
return storage_.back().stamp_;
}
void TimeCache::pruneList()
{
ros::Time latest_time = storage_.begin()->stamp_;
while(!storage_.empty() && storage_.back().stamp_ + max_storage_time_ < latest_time)
{
storage_.pop_back();
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
project(tf2_kdl)
find_package(orocos_kdl)
find_package(catkin REQUIRED COMPONENTS cmake_modules tf2 tf2_ros tf2_msgs)
find_package(Eigen REQUIRED)
catkin_package(
INCLUDE_DIRS include ${Eigen_INCLUDE_DIRS}
DEPENDS Eigen orocos_kdl
)
catkin_python_setup()
link_directories(${orocos_kdl_LIBRARY_DIRS})
include_directories(include ${catkin_INCLUDE_DIRS} ${Eigen_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
install(PROGRAMS scripts/test.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
if(CATKIN_ENABLE_TESTING)
find_package(catkin REQUIRED COMPONENTS rostest tf2 tf2_ros tf2_msgs)
add_executable(test_kdl EXCLUDE_FROM_ALL test/test_tf2_kdl.cpp)
find_package (Threads)
target_link_libraries(test_kdl ${catkin_LIBRARIES} ${GTEST_LIBRARIES} ${orocos_kdl_LIBRARIES} ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
add_rostest(${CMAKE_CURRENT_SOURCE_DIR}/test/test.launch)
add_rostest(${CMAKE_CURRENT_SOURCE_DIR}/test/test_python.launch)
if(TARGET tests)
add_dependencies(tests test_kdl)
endif()
endif()
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/package.xml | <package>
<name>tf2_kdl</name>
<version>0.5.13</version>
<description>
KDL binding for tf2
</description>
<maintainer email="tfoote@osrfoundation.org">Tully Foote</maintainer>
<author>Wim Meeussen</author>
<license>BSD</license>
<url type="website">http://ros.org/wiki/tf2</url>
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>cmake_modules</build_depend> <!-- needed for eigen -->
<build_depend>eigen</build_depend> <!-- needed by kdl interally -->
<build_depend>orocos_kdl</build_depend>
<build_depend>tf2</build_depend>
<build_depend>tf2_ros</build_depend>
<run_depend>cmake_modules</run_depend> <!-- needed for eigen -->
<run_depend>eigen</run_depend>
<run_depend>orocos_kdl</run_depend>
<run_depend>tf2</run_depend>
<run_depend>tf2_ros</run_depend>
<test_depend>rostest</test_depend>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/mainpage.dox | /**
\mainpage
\htmlinclude manifest.html
\b tf2_kdl is ...
<!--
Provide an overview of your package.
-->
\section codeapi Code API
<!--
Provide links to specific auto-generated API documentation within your
package that is of particular interest to a reader. Doxygen will
document pretty much every part of your code, so do your best here to
point the reader to the actual API.
If your codebase is fairly large or has different sets of APIs, you
should use the doxygen 'group' tag to keep these APIs together. For
example, the roscpp documentation has 'libros' group.
-->
*/
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/setup.py | #!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
## don't do this unless you want a globally visible script
# scripts=['script/test.py'],
packages=['tf2_kdl'],
package_dir={'': 'src'}
)
setup(**d)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/.tar | {!!python/unicode 'url': 'https://github.com/ros-gbp/geometry2-release/archive/release/indigo/tf2_kdl/0.5.13-0.tar.gz',
!!python/unicode 'version': geometry2-release-release-indigo-tf2_kdl-0.5.13-0}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/CHANGELOG.rst | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package tf2_kdl
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.5.13 (2016-03-04)
-------------------
* converting python test script into unit test
* Don't export catkin includes
* Contributors: Jochen Sprickerhof, Tully Foote
0.5.12 (2015-08-05)
-------------------
* Add kdl::Frame to TransformStamped conversion
* Contributors: Paul Bovbel
0.5.11 (2015-04-22)
-------------------
0.5.10 (2015-04-21)
-------------------
0.5.9 (2015-03-25)
------------------
0.5.8 (2015-03-17)
------------------
* remove useless Makefile files
* fix ODR violations
* Contributors: Vincent Rabaud
0.5.7 (2014-12-23)
------------------
* fixing install rules and adding backwards compatible include with #warning
* Contributors: Tully Foote
0.5.6 (2014-09-18)
------------------
0.5.5 (2014-06-23)
------------------
0.5.4 (2014-05-07)
------------------
0.5.3 (2014-02-21)
------------------
* finding eigen from cmake_modules instead of from catkin
* Contributors: Tully Foote
0.5.2 (2014-02-20)
------------------
* add cmake_modules dependency for eigen find_package rules
* Contributors: Tully Foote
0.5.1 (2014-02-14)
------------------
0.5.0 (2014-02-14)
------------------
0.4.10 (2013-12-26)
-------------------
0.4.9 (2013-11-06)
------------------
0.4.8 (2013-11-06)
------------------
0.4.7 (2013-08-28)
------------------
0.4.6 (2013-08-28)
------------------
0.4.5 (2013-07-11)
------------------
0.4.4 (2013-07-09)
------------------
* making repo use CATKIN_ENABLE_TESTING correctly and switching rostest to be a test_depend with that change.
0.4.3 (2013-07-05)
------------------
0.4.2 (2013-07-05)
------------------
0.4.1 (2013-07-05)
------------------
0.4.0 (2013-06-27)
------------------
* moving convert methods back into tf2 because it does not have any ros dependencies beyond ros::Time which is already a dependency of tf2
* Cleaning up unnecessary dependency on roscpp
* converting contents of tf2_ros to be properly namespaced in the tf2_ros namespace
* Cleaning up packaging of tf2 including:
removing unused nodehandle
cleaning up a few dependencies and linking
removing old backup of package.xml
making diff minimally different from tf version of library
* Restoring test packages and bullet packages.
reverting 3570e8c42f9b394ecbfd9db076b920b41300ad55 to get back more of the packages previously implemented
reverting 04cf29d1b58c660fdc999ab83563a5d4b76ab331 to fix `#7 <https://github.com/ros/geometry_experimental/issues/7>`_
* passing unit tests
0.3.6 (2013-03-03)
------------------
* fix compilation under Oneiric
0.3.5 (2013-02-15 14:46)
------------------------
* 0.3.4 -> 0.3.5
0.3.4 (2013-02-15 13:14)
------------------------
* 0.3.3 -> 0.3.4
0.3.3 (2013-02-15 11:30)
------------------------
* 0.3.2 -> 0.3.3
0.3.2 (2013-02-15 00:42)
------------------------
* 0.3.1 -> 0.3.2
* fixed missing include export & tf2_ros dependecy
0.3.1 (2013-02-14)
------------------
* fixing version number in tf2_kdl
* catkinized tf2_kdl
0.3.0 (2013-02-13)
------------------
* fixing groovy-devel
* removing bullet and kdl related packages
* catkinizing geometry-experimental
* catkinizing tf2_kdl
* fix for kdl rotaiton constrition
* add twist, wrench and pose conversion to kdl, fix message to message conversion by adding specific conversion functions
* merge tf2_cpp and tf2_py into tf2_ros
* Got transform with types working in python
* A working first version of transforming and converting between different types
* Moving from camelCase to undescores to be in line with python style guides
* kdl unittest passing
* whitespace test
* add support for PointStamped geometry_msgs
* Fixing script
* set transform for test
* add advanced api
* working to transform kdl objects with dummy buffer_core
* plugin for py kdl
* add regression tests for geometry_msgs point, vector and pose
* add frame unit tests to kdl and bullet
* add first regression tests for kdl and bullet tf
* add bullet transforms, and create tests for bullet and kdl
* transform for vector3stamped message
* move implementation into library
* add advanced api
* compiling again with new design
* renaming classes
* compiling now
* almost compiling version of template code
* add test to start compiling
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/test/test_python.launch | <launch>
<test test-name="test_tf_kdl_python" pkg="tf2_kdl" type="test.py" time-limit="120" />
</launch>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/test/test_tf2_kdl.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Wim Meeussen */
#include <tf2_kdl/tf2_kdl.h>
#include <kdl/frames_io.hpp>
#include <gtest/gtest.h>
#include "tf2_ros/buffer.h"
tf2_ros::Buffer* tf_buffer;
static const double EPS = 1e-3;
TEST(TfKDL, Frame)
{
tf2::Stamped<KDL::Frame> v1(KDL::Frame(KDL::Rotation::RPY(M_PI, 0, 0), KDL::Vector(1,2,3)), ros::Time(2.0), "A");
// simple api
KDL::Frame v_simple = tf_buffer->transform(v1, "B", ros::Duration(2.0));
EXPECT_NEAR(v_simple.p[0], -9, EPS);
EXPECT_NEAR(v_simple.p[1], 18, EPS);
EXPECT_NEAR(v_simple.p[2], 27, EPS);
double r, p, y;
v_simple.M.GetRPY(r, p, y);
EXPECT_NEAR(r, 0.0, EPS);
EXPECT_NEAR(p, 0.0, EPS);
EXPECT_NEAR(y, 0.0, EPS);
// advanced api
KDL::Frame v_advanced = tf_buffer->transform(v1, "B", ros::Time(2.0),
"A", ros::Duration(3.0));
EXPECT_NEAR(v_advanced.p[0], -9, EPS);
EXPECT_NEAR(v_advanced.p[1], 18, EPS);
EXPECT_NEAR(v_advanced.p[2], 27, EPS);
v_advanced.M.GetRPY(r, p, y);
EXPECT_NEAR(r, 0.0, EPS);
EXPECT_NEAR(p, 0.0, EPS);
EXPECT_NEAR(y, 0.0, EPS);
}
TEST(TfKDL, Vector)
{
tf2::Stamped<KDL::Vector> v1(KDL::Vector(1,2,3), ros::Time(2.0), "A");
// simple api
KDL::Vector v_simple = tf_buffer->transform(v1, "B", ros::Duration(2.0));
EXPECT_NEAR(v_simple[0], -9, EPS);
EXPECT_NEAR(v_simple[1], 18, EPS);
EXPECT_NEAR(v_simple[2], 27, EPS);
// advanced api
KDL::Vector v_advanced = tf_buffer->transform(v1, "B", ros::Time(2.0),
"A", ros::Duration(3.0));
EXPECT_NEAR(v_advanced[0], -9, EPS);
EXPECT_NEAR(v_advanced[1], 18, EPS);
EXPECT_NEAR(v_advanced[2], 27, EPS);
}
TEST(TfKDL, ConvertVector)
{
tf2::Stamped<KDL::Vector> v(KDL::Vector(1,2,3), ros::Time(), "my_frame");
tf2::Stamped<KDL::Vector> v1 = v;
tf2::convert(v1, v1);
EXPECT_EQ(v, v1);
tf2::Stamped<KDL::Vector> v2(KDL::Vector(3,4,5), ros::Time(), "my_frame2");
tf2::convert(v1, v2);
EXPECT_EQ(v, v2);
EXPECT_EQ(v1, v2);
}
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
ros::init(argc, argv, "test");
ros::NodeHandle n;
tf_buffer = new tf2_ros::Buffer();
// populate buffer
geometry_msgs::TransformStamped t;
t.transform.translation.x = 10;
t.transform.translation.y = 20;
t.transform.translation.z = 30;
t.transform.rotation.x = 1;
t.header.stamp = ros::Time(2.0);
t.header.frame_id = "A";
t.child_frame_id = "B";
tf_buffer->setTransform(t, "test");
bool retval = RUN_ALL_TESTS();
delete tf_buffer;
return retval;
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/test/test.launch | <launch>
<test test-name="test_tf_kdl" pkg="tf2_kdl" type="test_kdl" time-limit="120" />
</launch> | 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/include/tf2_kdl/tf2_kdl.h | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Wim Meeussen */
#ifndef TF2_KDL_H
#define TF2_KDL_H
#include <tf2/convert.h>
#include <kdl/frames.hpp>
#include <geometry_msgs/PointStamped.h>
#include <geometry_msgs/TwistStamped.h>
#include <geometry_msgs/WrenchStamped.h>
#include <geometry_msgs/PoseStamped.h>
namespace tf2
{
inline
KDL::Frame transformToKDL(const geometry_msgs::TransformStamped& t)
{
return KDL::Frame(KDL::Rotation::Quaternion(t.transform.rotation.x, t.transform.rotation.y,
t.transform.rotation.z, t.transform.rotation.w),
KDL::Vector(t.transform.translation.x, t.transform.translation.y, t.transform.translation.z));
}
inline
geometry_msgs::TransformStamped kdlToTransform(const KDL::Frame& k)
{
geometry_msgs::TransformStamped t;
t.transform.translation.x = k.p.x();
t.transform.translation.y = k.p.y();
t.transform.translation.z = k.p.z();
k.M.GetQuaternion(t.transform.rotation.x, t.transform.rotation.y, t.transform.rotation.z, t.transform.rotation.w);
return t;
}
// ---------------------
// Vector
// ---------------------
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const tf2::Stamped<KDL::Vector>& t_in, tf2::Stamped<KDL::Vector>& t_out, const geometry_msgs::TransformStamped& transform)
{
t_out = tf2::Stamped<KDL::Vector>(transformToKDL(transform) * t_in, transform.header.stamp, transform.header.frame_id);
}
//convert to vector message
inline
geometry_msgs::PointStamped toMsg(const tf2::Stamped<KDL::Vector>& in)
{
geometry_msgs::PointStamped msg;
msg.header.stamp = in.stamp_;
msg.header.frame_id = in.frame_id_;
msg.point.x = in[0];
msg.point.y = in[1];
msg.point.z = in[2];
return msg;
}
inline
void fromMsg(const geometry_msgs::PointStamped& msg, tf2::Stamped<KDL::Vector>& out)
{
out.stamp_ = msg.header.stamp;
out.frame_id_ = msg.header.frame_id;
out[0] = msg.point.x;
out[1] = msg.point.y;
out[2] = msg.point.z;
}
// ---------------------
// Twist
// ---------------------
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const tf2::Stamped<KDL::Twist>& t_in, tf2::Stamped<KDL::Twist>& t_out, const geometry_msgs::TransformStamped& transform)
{
t_out = tf2::Stamped<KDL::Twist>(transformToKDL(transform) * t_in, transform.header.stamp, transform.header.frame_id);
}
//convert to twist message
inline
geometry_msgs::TwistStamped toMsg(const tf2::Stamped<KDL::Twist>& in)
{
geometry_msgs::TwistStamped msg;
msg.header.stamp = in.stamp_;
msg.header.frame_id = in.frame_id_;
msg.twist.linear.x = in.vel[0];
msg.twist.linear.y = in.vel[1];
msg.twist.linear.z = in.vel[2];
msg.twist.angular.x = in.rot[0];
msg.twist.angular.y = in.rot[1];
msg.twist.angular.z = in.rot[2];
return msg;
}
inline
void fromMsg(const geometry_msgs::TwistStamped& msg, tf2::Stamped<KDL::Twist>& out)
{
out.stamp_ = msg.header.stamp;
out.frame_id_ = msg.header.frame_id;
out.vel[0] = msg.twist.linear.x;
out.vel[1] = msg.twist.linear.y;
out.vel[2] = msg.twist.linear.z;
out.rot[0] = msg.twist.angular.x;
out.rot[1] = msg.twist.angular.y;
out.rot[2] = msg.twist.angular.z;
}
// ---------------------
// Wrench
// ---------------------
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const tf2::Stamped<KDL::Wrench>& t_in, tf2::Stamped<KDL::Wrench>& t_out, const geometry_msgs::TransformStamped& transform)
{
t_out = tf2::Stamped<KDL::Wrench>(transformToKDL(transform) * t_in, transform.header.stamp, transform.header.frame_id);
}
//convert to wrench message
inline
geometry_msgs::WrenchStamped toMsg(const tf2::Stamped<KDL::Wrench>& in)
{
geometry_msgs::WrenchStamped msg;
msg.header.stamp = in.stamp_;
msg.header.frame_id = in.frame_id_;
msg.wrench.force.x = in.force[0];
msg.wrench.force.y = in.force[1];
msg.wrench.force.z = in.force[2];
msg.wrench.torque.x = in.torque[0];
msg.wrench.torque.y = in.torque[1];
msg.wrench.torque.z = in.torque[2];
return msg;
}
inline
void fromMsg(const geometry_msgs::WrenchStamped& msg, tf2::Stamped<KDL::Wrench>& out)
{
out.stamp_ = msg.header.stamp;
out.frame_id_ = msg.header.frame_id;
out.force[0] = msg.wrench.force.x;
out.force[1] = msg.wrench.force.y;
out.force[2] = msg.wrench.force.z;
out.torque[0] = msg.wrench.torque.x;
out.torque[1] = msg.wrench.torque.y;
out.torque[2] = msg.wrench.torque.z;
}
// ---------------------
// Frame
// ---------------------
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const tf2::Stamped<KDL::Frame>& t_in, tf2::Stamped<KDL::Frame>& t_out, const geometry_msgs::TransformStamped& transform)
{
t_out = tf2::Stamped<KDL::Frame>(transformToKDL(transform) * t_in, transform.header.stamp, transform.header.frame_id);
}
//convert to pose message
inline
geometry_msgs::PoseStamped toMsg(const tf2::Stamped<KDL::Frame>& in)
{
geometry_msgs::PoseStamped msg;
msg.header.stamp = in.stamp_;
msg.header.frame_id = in.frame_id_;
msg.pose.position.x = in.p[0];
msg.pose.position.y = in.p[1];
msg.pose.position.z = in.p[2];
in.M.GetQuaternion(msg.pose.orientation.x, msg.pose.orientation.y, msg.pose.orientation.z, msg.pose.orientation.w);
return msg;
}
inline
void fromMsg(const geometry_msgs::PoseStamped& msg, tf2::Stamped<KDL::Frame>& out)
{
out.stamp_ = msg.header.stamp;
out.frame_id_ = msg.header.frame_id;
out.p[0] = msg.pose.position.x;
out.p[1] = msg.pose.position.y;
out.p[2] = msg.pose.position.z;
out.M = KDL::Rotation::Quaternion(msg.pose.orientation.x, msg.pose.orientation.y, msg.pose.orientation.z, msg.pose.orientation.w);
}
} // namespace
#endif // TF2_KDL_H
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/include/tf2_kdl | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/include/tf2_kdl/tf2_kdl/tf2_kdl.h | #warning This header is at the wrong path you should include <tf2_kdl/tf2_kdl.h>
#include <tf2_kdl/tf2_kdl.h>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/scripts/test.py | #!/usr/bin/python
import unittest
import rospy
import PyKDL
import tf2_ros
import tf2_kdl
from geometry_msgs.msg import TransformStamped
from copy import deepcopy
class KDLConversions(unittest.TestCase):
def test_transform(self):
b = tf2_ros.Buffer()
t = TransformStamped()
t.transform.translation.x = 1
t.transform.rotation.x = 1
t.header.stamp = rospy.Time(2.0)
t.header.frame_id = 'a'
t.child_frame_id = 'b'
b.set_transform(t, 'eitan_rocks')
out = b.lookup_transform('a','b', rospy.Time(2.0), rospy.Duration(2.0))
self.assertEqual(out.transform.translation.x, 1)
self.assertEqual(out.transform.rotation.x, 1)
self.assertEqual(out.header.frame_id, 'a')
self.assertEqual(out.child_frame_id, 'b')
v = PyKDL.Vector(1,2,3)
out = b.transform(tf2_ros.Stamped(v, rospy.Time(2), 'a'), 'b')
self.assertEqual(out.x(), 0)
self.assertEqual(out.y(), -2)
self.assertEqual(out.z(), -3)
f = PyKDL.Frame(PyKDL.Rotation.RPY(1,2,3), PyKDL.Vector(1,2,3))
out = b.transform(tf2_ros.Stamped(f, rospy.Time(2), 'a'), 'b')
print out
self.assertEqual(out.p.x(), 0)
self.assertEqual(out.p.y(), -2)
self.assertEqual(out.p.z(), -3)
# TODO(tfoote) check values of rotation
t = PyKDL.Twist(PyKDL.Vector(1,2,3), PyKDL.Vector(4,5,6))
out = b.transform(tf2_ros.Stamped(t, rospy.Time(2), 'a'), 'b')
self.assertEqual(out.vel.x(), 1)
self.assertEqual(out.vel.y(), -8)
self.assertEqual(out.vel.z(), 2)
self.assertEqual(out.rot.x(), 4)
self.assertEqual(out.rot.y(), -5)
self.assertEqual(out.rot.z(), -6)
w = PyKDL.Wrench(PyKDL.Vector(1,2,3), PyKDL.Vector(4,5,6))
out = b.transform(tf2_ros.Stamped(w, rospy.Time(2), 'a'), 'b')
self.assertEqual(out.force.x(), 1)
self.assertEqual(out.force.y(), -2)
self.assertEqual(out.force.z(), -3)
self.assertEqual(out.torque.x(), 4)
self.assertEqual(out.torque.y(), -8)
self.assertEqual(out.torque.z(), -4)
def test_convert(self):
v = PyKDL.Vector(1,2,3)
vs = tf2_ros.Stamped(v, rospy.Time(2), 'a')
vs2 = tf2_ros.convert(vs, PyKDL.Vector)
self.assertEqual(vs.x(), 1)
self.assertEqual(vs.y(), 2)
self.assertEqual(vs.z(), 3)
self.assertEqual(vs2.x(), 1)
self.assertEqual(vs2.y(), 2)
self.assertEqual(vs2.z(), 3)
if __name__ == '__main__':
import rosunit
rospy.init_node('test_tf2_kdl_python')
rosunit.unitrun("test_tf2_kdl", "test_tf2_kdl_python", KDLConversions)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/src/tf2_kdl/__init__.py | from tf2_kdl import *
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_kdl/src/tf2_kdl/tf2_kdl.py | # Copyright (c) 2008, Willow Garage, Inc.
# 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 Willow Garage, Inc. 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 OWNER 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.
# author: Wim Meeussen
import roslib; roslib.load_manifest('tf2_kdl')
import PyKDL
import rospy
import tf2_ros
from geometry_msgs.msg import PointStamped
def transform_to_kdl(t):
return PyKDL.Frame(PyKDL.Rotation.Quaternion(t.transform.rotation.x, t.transform.rotation.y,
t.transform.rotation.z, t.transform.rotation.w),
PyKDL.Vector(t.transform.translation.x,
t.transform.translation.y,
t.transform.translation.z))
# Vector
def do_transform_vector(vector, transform):
res = transform_to_kdl(transform) * vector
res.header = transform.header
return res
tf2_ros.TransformRegistration().add(PyKDL.Vector, do_transform_vector)
def to_msg_vector(vector):
msg = PointStamped()
msg.header = vector.header
msg.point.x = vector[0]
msg.point.y = vector[1]
msg.point.z = vector[2]
return msg
tf2_ros.ConvertRegistration().add_to_msg(PyKDL.Vector, to_msg_vector)
def from_msg_vector(msg):
vector = PyKDL.Vector(msg.point.x, msg.point.y, msg.point.z)
return tf2_ros.Stamped(vector, msg.header.stamp, msg.header.frame_id)
tf2_ros.ConvertRegistration().add_from_msg(PyKDL.Vector, from_msg_vector)
def convert_vector(vector):
return tf2_ros.Stamped(PyKDL.Vector(vector), vector.header.stamp, vector.header.frame_id)
tf2_ros.ConvertRegistration().add_convert((PyKDL.Vector, PyKDL.Vector), convert_vector)
# Frame
def do_transform_frame(frame, transform):
res = transform_to_kdl(transform) * frame
res.header = transform.header
return res
tf2_ros.TransformRegistration().add(PyKDL.Frame, do_transform_frame)
# Twist
def do_transform_twist(twist, transform):
res = transform_to_kdl(transform) * twist
res.header = transform.header
return res
tf2_ros.TransformRegistration().add(PyKDL.Twist, do_transform_twist)
# Wrench
def do_transform_wrench(wrench, transform):
res = transform_to_kdl(transform) * wrench
res.header = transform.header
return res
tf2_ros.TransformRegistration().add(PyKDL.Wrench, do_transform_wrench)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
project(tf2_sensor_msgs)
find_package(catkin REQUIRED COMPONENTS cmake_modules sensor_msgs tf2_ros tf2)
find_package(Boost COMPONENTS thread REQUIRED)
find_package(Eigen)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS sensor_msgs tf2_ros tf2
DEPENDS Eigen
)
include_directories(include
${catkin_INCLUDE_DIRS}
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
catkin_python_setup()
if(CATKIN_ENABLE_TESTING)
catkin_add_nosetests(test/test_tf2_sensor_msgs.py)
find_package(catkin REQUIRED COMPONENTS sensor_msgs rostest tf2_ros tf2)
include_directories(${EIGEN_INCLUDE_DIRS})
add_executable(test_tf2_sensor_msgs_cpp EXCLUDE_FROM_ALL test/test_tf2_sensor_msgs.cpp)
target_link_libraries(test_tf2_sensor_msgs_cpp ${catkin_LIBRARIES} ${GTEST_LIBRARIES})
if(TARGET tests)
add_dependencies(tests test_tf2_sensor_msgs_cpp)
endif()
add_rostest(${CMAKE_CURRENT_SOURCE_DIR}/test/test.launch)
endif()
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/package.xml | <package>
<name>tf2_sensor_msgs</name>
<version>0.5.13</version>
<description>
Small lib to transform sensor_msgs with tf. Most notably, PointCloud2
</description>
<author>Vincent Rabaud</author>
<maintainer email="vincent.rabaud@gmail.com">Vincent Rabaud</maintainer>
<license>BSD</license>
<url type="website">http://www.ros.org/wiki/tf2_ros</url>
<buildtool_depend version_gte="0.5.6">catkin</buildtool_depend>
<build_depend>cmake_modules</build_depend>
<build_depend>eigen</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>tf2</build_depend>
<build_depend>tf2_ros</build_depend>
<run_depend>cmake_modules</run_depend>
<run_depend>eigen</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>tf2_ros</run_depend>
<run_depend>tf2</run_depend>
<run_depend>python_orocos_kdl</run_depend>
<test_depend>rostest</test_depend>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/setup.py | #!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=['tf2_sensor_msgs'],
package_dir={'': 'src'},
requires={'rospy','sensor_msgs','tf2_ros','orocos_kdl'}
)
setup(**d)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/.tar | {!!python/unicode 'url': 'https://github.com/ros-gbp/geometry2-release/archive/release/indigo/tf2_sensor_msgs/0.5.13-0.tar.gz',
!!python/unicode 'version': geometry2-release-release-indigo-tf2_sensor_msgs-0.5.13-0}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/CHANGELOG.rst | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package tf2_sensor_msgs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.5.13 (2016-03-04)
-------------------
* add missing Python runtime dependency
* fix wrong comment
* Adding tests to package
* Fixing do_transform_cloud for python
The previous code was not used at all (it was a mistake in the __init_\_.py so
the do_transform_cloud was not available to the python users).
The python code need some little correction (e.g there is no method named
read_cloud but it's read_points for instance, and as we are in python we can't
use the same trick as in c++ when we got an immutable)
* Contributors: Laurent GEORGE, Vincent Rabaud
0.5.12 (2015-08-05)
-------------------
0.5.11 (2015-04-22)
-------------------
0.5.10 (2015-04-21)
-------------------
0.5.9 (2015-03-25)
------------------
0.5.8 (2015-03-17)
------------------
* ODR violation fixes and more conversions
* Fix keeping original pointcloud header in transformed pointcloud
* Contributors: Paul Bovbel, Tully Foote, Vincent Rabaud
0.5.7 (2014-12-23)
------------------
* add support for transforming sensor_msgs::PointCloud2
* Contributors: Vincent Rabaud
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/test/test_tf2_sensor_msgs.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
#include <tf2_sensor_msgs/tf2_sensor_msgs.h>
#include <geometry_msgs/PoseStamped.h>
#include <tf2_ros/transform_listener.h>
#include <ros/ros.h>
#include <gtest/gtest.h>
#include <tf2_ros/buffer.h>
tf2_ros::Buffer* tf_buffer;
static const double EPS = 1e-3;
TEST(Tf2Sensor, PointCloud2)
{
sensor_msgs::PointCloud2 cloud;
sensor_msgs::PointCloud2Modifier modifier(cloud);
modifier.setPointCloud2FieldsByString(2, "xyz", "rgb");
modifier.resize(1);
sensor_msgs::PointCloud2Iterator<float> iter_x(cloud, "x");
sensor_msgs::PointCloud2Iterator<float> iter_y(cloud, "y");
sensor_msgs::PointCloud2Iterator<float> iter_z(cloud, "z");
*iter_x = 1;
*iter_y = 2;
*iter_z = 3;
cloud.header.stamp = ros::Time(2);
cloud.header.frame_id = "A";
// simple api
sensor_msgs::PointCloud2 cloud_simple = tf_buffer->transform(cloud, "B", ros::Duration(2.0));
sensor_msgs::PointCloud2Iterator<float> iter_x_after(cloud_simple, "x");
sensor_msgs::PointCloud2Iterator<float> iter_y_after(cloud_simple, "y");
sensor_msgs::PointCloud2Iterator<float> iter_z_after(cloud_simple, "z");
EXPECT_NEAR(*iter_x_after, -9, EPS);
EXPECT_NEAR(*iter_y_after, 18, EPS);
EXPECT_NEAR(*iter_z_after, 27, EPS);
// advanced api
sensor_msgs::PointCloud2 cloud_advanced = tf_buffer->transform(cloud, "B", ros::Time(2.0),
"A", ros::Duration(3.0));
sensor_msgs::PointCloud2Iterator<float> iter_x_advanced(cloud_advanced, "x");
sensor_msgs::PointCloud2Iterator<float> iter_y_advanced(cloud_advanced, "y");
sensor_msgs::PointCloud2Iterator<float> iter_z_advanced(cloud_advanced, "z");
EXPECT_NEAR(*iter_x_advanced, -9, EPS);
EXPECT_NEAR(*iter_y_advanced, 18, EPS);
EXPECT_NEAR(*iter_z_advanced, 27, EPS);
}
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
ros::init(argc, argv, "test");
ros::NodeHandle n;
tf_buffer = new tf2_ros::Buffer();
// populate buffer
geometry_msgs::TransformStamped t;
t.transform.translation.x = 10;
t.transform.translation.y = 20;
t.transform.translation.z = 30;
t.transform.rotation.x = 1;
t.transform.rotation.y = 0;
t.transform.rotation.z = 0;
t.transform.rotation.w = 0;
t.header.stamp = ros::Time(2.0);
t.header.frame_id = "A";
t.child_frame_id = "B";
tf_buffer->setTransform(t, "test");
bool ret = RUN_ALL_TESTS();
delete tf_buffer;
return ret;
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/test/test_tf2_sensor_msgs.py | #!/usr/bin/env python
import unittest
import struct
import tf2_sensor_msgs
from sensor_msgs import point_cloud2
from sensor_msgs.msg import PointField
from tf2_ros import TransformStamped
import copy
## A sample python unit test
class PointCloudConversions(unittest.TestCase):
def setUp(self):
self.point_cloud_in = point_cloud2.PointCloud2()
self.point_cloud_in.fields = [PointField('x', 0, PointField.FLOAT32, 1),
PointField('y', 4, PointField.FLOAT32, 1),
PointField('z', 8, PointField.FLOAT32, 1)]
self.point_cloud_in.point_step = 4 * 3
self.point_cloud_in.height = 1
# we add two points (with x, y, z to the cloud)
self.point_cloud_in.width = 2
self.point_cloud_in.row_step = self.point_cloud_in.point_step * self.point_cloud_in.width
points = [1, 2, 0, 10, 20, 30]
self.point_cloud_in.data = struct.pack('%sf' % len(points), *points)
self.transform_translate_xyz_300 = TransformStamped()
self.transform_translate_xyz_300.transform.translation.x = 300
self.transform_translate_xyz_300.transform.translation.y = 300
self.transform_translate_xyz_300.transform.translation.z = 300
self.transform_translate_xyz_300.transform.rotation.w = 1 # no rotation so we only set w
assert(list(point_cloud2.read_points(self.point_cloud_in)) == [(1.0, 2.0, 0.0), (10.0, 20.0, 30.0)])
def test_simple_transform(self):
old_data = copy.deepcopy(self.point_cloud_in.data) # deepcopy is not required here because we have a str for now
point_cloud_transformed = tf2_sensor_msgs.do_transform_cloud(self.point_cloud_in, self.transform_translate_xyz_300)
k = 300
expected_coordinates = [(1+k, 2+k, 0+k), (10+k, 20+k, 30+k)]
new_points = list(point_cloud2.read_points(point_cloud_transformed))
print("new_points are %s" % new_points)
assert(expected_coordinates == new_points)
assert(old_data == self.point_cloud_in.data) # checking no modification in input cloud
if __name__ == '__main__':
import rosunit
rosunit.unitrun("test_tf2_sensor_msgs", "test_point_cloud_conversion", PointCloudConversions)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/test/test.launch | <launch>
<test test-name="tf2_sensor_msgs" pkg="tf2_sensor_msgs" type="test_tf2_sensor_msgs_cpp" time-limit="120" />
</launch>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/include/tf2_sensor_msgs/tf2_sensor_msgs.h | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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 TF2_SENSOR_MSGS_H
#define TF2_SENSOR_MSGS_H
#include <tf2/convert.h>
#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/point_cloud2_iterator.h>
#include <Eigen/Eigen>
#include <Eigen/Geometry>
namespace tf2
{
/********************/
/** PointCloud2 **/
/********************/
// method to extract timestamp from object
template <>
inline
const ros::Time& getTimestamp(const sensor_msgs::PointCloud2& p) {return p.header.stamp;}
// method to extract frame id from object
template <>
inline
const std::string& getFrameId(const sensor_msgs::PointCloud2 &p) {return p.header.frame_id;}
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const sensor_msgs::PointCloud2 &p_in, sensor_msgs::PointCloud2 &p_out, const geometry_msgs::TransformStamped& t_in)
{
p_out = p_in;
p_out.header = t_in.header;
Eigen::Transform<float,3,Eigen::Affine> t = Eigen::Translation3f(t_in.transform.translation.x, t_in.transform.translation.y,
t_in.transform.translation.z) * Eigen::Quaternion<float>(
t_in.transform.rotation.w, t_in.transform.rotation.x,
t_in.transform.rotation.y, t_in.transform.rotation.z);
sensor_msgs::PointCloud2ConstIterator<float> x_in(p_in, "x");
sensor_msgs::PointCloud2ConstIterator<float> y_in(p_in, "y");
sensor_msgs::PointCloud2ConstIterator<float> z_in(p_in, "z");
sensor_msgs::PointCloud2Iterator<float> x_out(p_out, "x");
sensor_msgs::PointCloud2Iterator<float> y_out(p_out, "y");
sensor_msgs::PointCloud2Iterator<float> z_out(p_out, "z");
Eigen::Vector3f point;
for(; x_in != x_in.end(); ++x_in, ++y_in, ++z_in, ++x_out, ++y_out, ++z_out) {
point = t * Eigen::Vector3f(*x_in, *y_in, *z_in);
*x_out = point.x();
*y_out = point.y();
*z_out = point.z();
}
}
inline
sensor_msgs::PointCloud2 toMsg(const sensor_msgs::PointCloud2 &in)
{
return in;
}
inline
void fromMsg(const sensor_msgs::PointCloud2 &msg, sensor_msgs::PointCloud2 &out)
{
out = msg;
}
} // namespace
#endif // TF2_SENSOR_MSGS_H
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/src/tf2_sensor_msgs/tf2_sensor_msgs.py | # Copyright (c) 2008, Willow Garage, Inc.
# 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 Willow Garage, Inc. 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 OWNER 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.
from sensor_msgs.msg import PointCloud2
from sensor_msgs.point_cloud2 import read_points, create_cloud
import PyKDL
import rospy
import tf2_ros
def to_msg_msg(msg):
return msg
tf2_ros.ConvertRegistration().add_to_msg(PointCloud2, to_msg_msg)
def from_msg_msg(msg):
return msg
tf2_ros.ConvertRegistration().add_from_msg(PointCloud2, from_msg_msg)
def transform_to_kdl(t):
return PyKDL.Frame(PyKDL.Rotation.Quaternion(t.transform.rotation.x, t.transform.rotation.y,
t.transform.rotation.z, t.transform.rotation.w),
PyKDL.Vector(t.transform.translation.x,
t.transform.translation.y,
t.transform.translation.z))
# PointStamped
def do_transform_cloud(cloud, transform):
t_kdl = transform_to_kdl(transform)
points_out = []
for p_in in read_points(cloud):
p_out = t_kdl * PyKDL.Vector(p_in[0], p_in[1], p_in[2])
points_out.append(p_out)
res = create_cloud(transform.header, cloud.fields, points_out)
return res
tf2_ros.TransformRegistration().add(PointCloud2, do_transform_cloud)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_sensor_msgs/src/tf2_sensor_msgs/__init__.py | from tf2_sensor_msgs import *
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
project(tf2_msgs)
find_package(catkin REQUIRED COMPONENTS message_generation geometry_msgs actionlib_msgs)
find_package(Boost COMPONENTS thread REQUIRED)
add_message_files(DIRECTORY msg FILES TF2Error.msg TFMessage.msg)
add_service_files(DIRECTORY srv FILES FrameGraph.srv)
add_action_files(DIRECTORY action FILES LookupTransform.action)
generate_messages(
DEPENDENCIES actionlib_msgs std_msgs geometry_msgs
)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS message_generation geometry_msgs actionlib_msgs)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/package.xml | <package>
<name>tf2_msgs</name>
<version>0.5.13</version>
<description>
tf2_msgs
</description>
<author>Eitan Marder-Eppstein</author>
<maintainer email="tfoote@osrfoundation.org">Tully Foote</maintainer>
<license>BSD</license>
<url type="website">http://www.ros.org/wiki/tf2_msgs</url>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>actionlib_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>message_generation</build_depend>
<run_depend>actionlib_msgs</run_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>message_generation</run_depend>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/mainpage.dox | /**
\mainpage
\htmlinclude manifest.html
\b tf2_msgs is ...
<!--
Provide an overview of your package.
-->
\section codeapi Code API
<!--
Provide links to specific auto-generated API documentation within your
package that is of particular interest to a reader. Doxygen will
document pretty much every part of your code, so do your best here to
point the reader to the actual API.
If your codebase is fairly large or has different sets of APIs, you
should use the doxygen 'group' tag to keep these APIs together. For
example, the roscpp documentation has 'libros' group.
-->
*/
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/.tar | {!!python/unicode 'url': 'https://github.com/ros-gbp/geometry2-release/archive/release/indigo/tf2_msgs/0.5.13-0.tar.gz',
!!python/unicode 'version': geometry2-release-release-indigo-tf2_msgs-0.5.13-0}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/CHANGELOG.rst | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package tf2_msgs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.5.13 (2016-03-04)
-------------------
0.5.12 (2015-08-05)
-------------------
0.5.11 (2015-04-22)
-------------------
0.5.10 (2015-04-21)
-------------------
0.5.9 (2015-03-25)
------------------
0.5.8 (2015-03-17)
------------------
* remove useless Makefile files
* Contributors: Vincent Rabaud
0.5.7 (2014-12-23)
------------------
0.5.6 (2014-09-18)
------------------
0.5.5 (2014-06-23)
------------------
0.5.4 (2014-05-07)
------------------
0.5.3 (2014-02-21)
------------------
0.5.2 (2014-02-20)
------------------
0.5.1 (2014-02-14)
------------------
0.5.0 (2014-02-14)
------------------
0.4.10 (2013-12-26)
-------------------
0.4.9 (2013-11-06)
------------------
0.4.8 (2013-11-06)
------------------
0.4.7 (2013-08-28)
------------------
0.4.6 (2013-08-28)
------------------
0.4.5 (2013-07-11)
------------------
0.4.4 (2013-07-09)
------------------
0.4.3 (2013-07-05)
------------------
0.4.2 (2013-07-05)
------------------
0.4.1 (2013-07-05)
------------------
0.4.0 (2013-06-27)
------------------
* Restoring test packages and bullet packages.
reverting 3570e8c42f9b394ecbfd9db076b920b41300ad55 to get back more of the packages previously implemented
reverting 04cf29d1b58c660fdc999ab83563a5d4b76ab331 to fix `#7 <https://github.com/ros/geometry_experimental/issues/7>`_
0.3.6 (2013-03-03)
------------------
0.3.5 (2013-02-15 14:46)
------------------------
* 0.3.4 -> 0.3.5
0.3.4 (2013-02-15 13:14)
------------------------
* 0.3.3 -> 0.3.4
0.3.3 (2013-02-15 11:30)
------------------------
* 0.3.2 -> 0.3.3
0.3.2 (2013-02-15 00:42)
------------------------
* 0.3.1 -> 0.3.2
0.3.1 (2013-02-14)
------------------
* 0.3.0 -> 0.3.1
0.3.0 (2013-02-13)
------------------
* switching to version 0.3.0
* removing packages with missing deps
* adding include folder
* adding tf2_msgs/srv/FrameGraph.srv
* catkin fixes
* catkinizing geometry-experimental
* catkinizing tf2_msgs
* Adding ROS service interface to cpp Buffer
* fix tf messages dependency and name
* add python transform listener
* Compiling version of the buffer server
* Compiling version of the buffer client
* Adding a message that encapsulates errors that can be returned by tf
* A fully specified version of the LookupTransform.action
* Commiting so I can merge
* Adding action for LookupTransform
* Updating CMake to call genaction
* Moving tfMessage to TFMessage to adhere to naming conventions
* Copying tfMessage from tf to new tf2_msgs package
* Creating a package for new tf messages
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/msg/TF2Error.msg | uint8 NO_ERROR = 0
uint8 LOOKUP_ERROR = 1
uint8 CONNECTIVITY_ERROR = 2
uint8 EXTRAPOLATION_ERROR = 3
uint8 INVALID_ARGUMENT_ERROR = 4
uint8 TIMEOUT_ERROR = 5
uint8 TRANSFORM_ERROR = 6
uint8 error
string error_string
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/msg/TFMessage.msg | geometry_msgs/TransformStamped[] transforms
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/action/LookupTransform.action | #Simple API
string target_frame
string source_frame
time source_time
duration timeout
#Advanced API
time target_time
string fixed_frame
#Whether or not to use the advanced API
bool advanced
---
geometry_msgs/TransformStamped transform
tf2_msgs/TF2Error error
---
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_msgs/srv/FrameGraph.srv | ---
string frame_yaml
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
project(tf2_geometry_msgs)
find_package(orocos_kdl)
find_package(catkin REQUIRED COMPONENTS geometry_msgs tf2_ros tf2)
find_package(Boost COMPONENTS thread REQUIRED)
# Issue #53
find_library(KDL_LIBRARY REQUIRED NAMES orocos-kdl HINTS ${orocos_kdl_LIBRARY_DIRS})
catkin_package(
LIBRARIES ${KDL_LIBRARY}
INCLUDE_DIRS include
DEPENDS orocos_kdl
CATKIN_DEPENDS geometry_msgs tf2_ros tf2)
include_directories(include
${catkin_INCLUDE_DIRS}
)
link_directories(${orocos_kdl_LIBRARY_DIRS})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
catkin_python_setup()
if(CATKIN_ENABLE_TESTING)
find_package(catkin REQUIRED COMPONENTS geometry_msgs rostest tf2_ros tf2)
add_executable(test_geometry_msgs EXCLUDE_FROM_ALL test/test_tf2_geometry_msgs.cpp)
target_link_libraries(test_geometry_msgs ${catkin_LIBRARIES} ${GTEST_LIBRARIES} ${orocos_kdl_LIBRARIES})
add_rostest(${CMAKE_CURRENT_SOURCE_DIR}/test/test.launch)
add_rostest(${CMAKE_CURRENT_SOURCE_DIR}/test/test_python.launch)
if(TARGET tests)
add_dependencies(tests test_geometry_msgs)
endif()
endif()
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/package.xml | <package>
<name>tf2_geometry_msgs</name>
<version>0.5.13</version>
<description>
tf2_geometry_msgs
</description>
<author>Wim Meeussen</author>
<maintainer email="tfoote@osrfoundation.org">Tully Foote</maintainer>
<license>BSD</license>
<url type="website">http://www.ros.org/wiki/tf2_ros</url>
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>tf2_ros</build_depend>
<build_depend>tf2</build_depend>
<build_depend>orocos_kdl</build_depend>
<build_depend>python_orocos_kdl</build_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>tf2_ros</run_depend>
<run_depend>tf2</run_depend>
<run_depend>orocos_kdl</run_depend>
<run_depend>python_orocos_kdl</run_depend>
<test_depend>rostest</test_depend>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/mainpage.dox | /**
\mainpage
\htmlinclude manifest.html
\b tf2_geometry_msgs is ...
<!--
Provide an overview of your package.
-->
\section codeapi Code API
<!--
Provide links to specific auto-generated API documentation within your
package that is of particular interest to a reader. Doxygen will
document pretty much every part of your code, so do your best here to
point the reader to the actual API.
If your codebase is fairly large or has different sets of APIs, you
should use the doxygen 'group' tag to keep these APIs together. For
example, the roscpp documentation has 'libros' group.
-->
*/
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/setup.py | #!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=['tf2_geometry_msgs'],
package_dir={'': 'src'},
requires={'rospy','geometry_msgs','tf2_ros','orocos_kdl'}
)
setup(**d)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/.tar | {!!python/unicode 'url': 'https://github.com/ros-gbp/geometry2-release/archive/release/indigo/tf2_geometry_msgs/0.5.13-0.tar.gz',
!!python/unicode 'version': geometry2-release-release-indigo-tf2_geometry_msgs-0.5.13-0}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/CHANGELOG.rst | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package tf2_geometry_msgs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.5.13 (2016-03-04)
-------------------
* Add missing python_orocos_kdl dependency
* make example into unit test
* vector3 not affected by translation
* Contributors: Daniel Claes, chapulina
0.5.12 (2015-08-05)
-------------------
* Merge pull request `#112 <https://github.com/ros/geometry_experimental/issues/112>`_ from vrabaud/getYaw
Get yaw
* add toMsg and fromMsg for QuaternionStamped
* Contributors: Tully Foote, Vincent Rabaud
0.5.11 (2015-04-22)
-------------------
0.5.10 (2015-04-21)
-------------------
0.5.9 (2015-03-25)
------------------
0.5.8 (2015-03-17)
------------------
* remove useless Makefile files
* tf2 optimizations
* add conversions of type between tf2 and geometry_msgs
* fix ODR violations
* Contributors: Vincent Rabaud
0.5.7 (2014-12-23)
------------------
* fixing transitive dependency for kdl. Fixes `#53 <https://github.com/ros/geometry_experimental/issues/53>`_
* Contributors: Tully Foote
0.5.6 (2014-09-18)
------------------
0.5.5 (2014-06-23)
------------------
0.5.4 (2014-05-07)
------------------
0.5.3 (2014-02-21)
------------------
0.5.2 (2014-02-20)
------------------
0.5.1 (2014-02-14)
------------------
0.5.0 (2014-02-14)
------------------
0.4.10 (2013-12-26)
-------------------
0.4.9 (2013-11-06)
------------------
0.4.8 (2013-11-06)
------------------
0.4.7 (2013-08-28)
------------------
0.4.6 (2013-08-28)
------------------
0.4.5 (2013-07-11)
------------------
0.4.4 (2013-07-09)
------------------
* making repo use CATKIN_ENABLE_TESTING correctly and switching rostest to be a test_depend with that change.
0.4.3 (2013-07-05)
------------------
0.4.2 (2013-07-05)
------------------
0.4.1 (2013-07-05)
------------------
0.4.0 (2013-06-27)
------------------
* moving convert methods back into tf2 because it does not have any ros dependencies beyond ros::Time which is already a dependency of tf2
* Cleaning up unnecessary dependency on roscpp
* converting contents of tf2_ros to be properly namespaced in the tf2_ros namespace
* Cleaning up packaging of tf2 including:
removing unused nodehandle
cleaning up a few dependencies and linking
removing old backup of package.xml
making diff minimally different from tf version of library
* Restoring test packages and bullet packages.
reverting 3570e8c42f9b394ecbfd9db076b920b41300ad55 to get back more of the packages previously implemented
reverting 04cf29d1b58c660fdc999ab83563a5d4b76ab331 to fix `#7 <https://github.com/ros/geometry_experimental/issues/7>`_
0.3.6 (2013-03-03)
------------------
0.3.5 (2013-02-15 14:46)
------------------------
* 0.3.4 -> 0.3.5
0.3.4 (2013-02-15 13:14)
------------------------
* 0.3.3 -> 0.3.4
0.3.3 (2013-02-15 11:30)
------------------------
* 0.3.2 -> 0.3.3
0.3.2 (2013-02-15 00:42)
------------------------
* 0.3.1 -> 0.3.2
0.3.1 (2013-02-14)
------------------
* 0.3.0 -> 0.3.1
0.3.0 (2013-02-13)
------------------
* switching to version 0.3.0
* add setup.py
* added setup.py etc to tf2_geometry_msgs
* adding tf2 dependency to tf2_geometry_msgs
* adding tf2_geometry_msgs to groovy-devel (unit tests disabled)
* fixing groovy-devel
* removing bullet and kdl related packages
* disabling tf2_geometry_msgs due to missing kdl dependency
* catkinizing geometry-experimental
* catkinizing tf2_geometry_msgs
* add twist, wrench and pose conversion to kdl, fix message to message conversion by adding specific conversion functions
* merge tf2_cpp and tf2_py into tf2_ros
* Got transform with types working in python
* A working first version of transforming and converting between different types
* Moving from camelCase to undescores to be in line with python style guides
* Fixing tests now that Buffer creates a NodeHandle
* add posestamped
* import vector3stamped
* add support for Vector3Stamped and PoseStamped
* add support for PointStamped geometry_msgs
* add regression tests for geometry_msgs point, vector and pose
* Fixing missing export, compiling version of buffer_client test
* add bullet transforms, and create tests for bullet and kdl
* working transformations of messages
* add support for PoseStamped message
* test for pointstamped
* add PointStamped message transform methods
* transform for vector3stamped message
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/test/test_tf2_geometry_msgs.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Wim Meeussen */
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <tf2_ros/transform_listener.h>
#include <ros/ros.h>
#include <gtest/gtest.h>
#include <tf2_ros/buffer.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
tf2_ros::Buffer* tf_buffer;
static const double EPS = 1e-3;
TEST(TfGeometry, Frame)
{
geometry_msgs::PoseStamped v1;
v1.pose.position.x = 1;
v1.pose.position.y = 2;
v1.pose.position.z = 3;
v1.pose.orientation.x = 1;
v1.header.stamp = ros::Time(2);
v1.header.frame_id = "A";
// simple api
geometry_msgs::PoseStamped v_simple = tf_buffer->transform(v1, "B", ros::Duration(2.0));
EXPECT_NEAR(v_simple.pose.position.x, -9, EPS);
EXPECT_NEAR(v_simple.pose.position.y, 18, EPS);
EXPECT_NEAR(v_simple.pose.position.z, 27, EPS);
EXPECT_NEAR(v_simple.pose.orientation.x, 0.0, EPS);
EXPECT_NEAR(v_simple.pose.orientation.y, 0.0, EPS);
EXPECT_NEAR(v_simple.pose.orientation.z, 0.0, EPS);
EXPECT_NEAR(v_simple.pose.orientation.w, 1.0, EPS);
// advanced api
geometry_msgs::PoseStamped v_advanced = tf_buffer->transform(v1, "B", ros::Time(2.0),
"A", ros::Duration(3.0));
EXPECT_NEAR(v_advanced.pose.position.x, -9, EPS);
EXPECT_NEAR(v_advanced.pose.position.y, 18, EPS);
EXPECT_NEAR(v_advanced.pose.position.z, 27, EPS);
EXPECT_NEAR(v_advanced.pose.orientation.x, 0.0, EPS);
EXPECT_NEAR(v_advanced.pose.orientation.y, 0.0, EPS);
EXPECT_NEAR(v_advanced.pose.orientation.z, 0.0, EPS);
EXPECT_NEAR(v_advanced.pose.orientation.w, 1.0, EPS);
}
TEST(TfGeometry, Vector)
{
geometry_msgs::Vector3Stamped v1, res;
v1.vector.x = 1;
v1.vector.y = 2;
v1.vector.z = 3;
v1.header.stamp = ros::Time(2.0);
v1.header.frame_id = "A";
// simple api
geometry_msgs::Vector3Stamped v_simple = tf_buffer->transform(v1, "B", ros::Duration(2.0));
EXPECT_NEAR(v_simple.vector.x, 1, EPS);
EXPECT_NEAR(v_simple.vector.y, -2, EPS);
EXPECT_NEAR(v_simple.vector.z, -3, EPS);
// advanced api
geometry_msgs::Vector3Stamped v_advanced = tf_buffer->transform(v1, "B", ros::Time(2.0),
"A", ros::Duration(3.0));
EXPECT_NEAR(v_advanced.vector.x, 1, EPS);
EXPECT_NEAR(v_advanced.vector.y, -2, EPS);
EXPECT_NEAR(v_advanced.vector.z, -3, EPS);
}
TEST(TfGeometry, Point)
{
geometry_msgs::PointStamped v1, res;
v1.point.x = 1;
v1.point.y = 2;
v1.point.z = 3;
v1.header.stamp = ros::Time(2.0);
v1.header.frame_id = "A";
// simple api
geometry_msgs::PointStamped v_simple = tf_buffer->transform(v1, "B", ros::Duration(2.0));
EXPECT_NEAR(v_simple.point.x, -9, EPS);
EXPECT_NEAR(v_simple.point.y, 18, EPS);
EXPECT_NEAR(v_simple.point.z, 27, EPS);
// advanced api
geometry_msgs::PointStamped v_advanced = tf_buffer->transform(v1, "B", ros::Time(2.0),
"A", ros::Duration(3.0));
EXPECT_NEAR(v_advanced.point.x, -9, EPS);
EXPECT_NEAR(v_advanced.point.y, 18, EPS);
EXPECT_NEAR(v_advanced.point.z, 27, EPS);
}
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
ros::init(argc, argv, "test");
ros::NodeHandle n;
tf_buffer = new tf2_ros::Buffer();
// populate buffer
geometry_msgs::TransformStamped t;
t.transform.translation.x = 10;
t.transform.translation.y = 20;
t.transform.translation.z = 30;
t.transform.rotation.x = 1;
t.header.stamp = ros::Time(2.0);
t.header.frame_id = "A";
t.child_frame_id = "B";
tf_buffer->setTransform(t, "test");
bool ret = RUN_ALL_TESTS();
delete tf_buffer;
return ret;
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/test/test_python.launch | <launch>
<test test-name="test_tf_geometry_msgs_python" pkg="tf2_geometry_msgs" type="test.py" time-limit="120" />
</launch>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/test/test.launch | <launch>
<test test-name="test_tf_geometry_msgs" pkg="tf2_geometry_msgs" type="test_geometry_msgs" time-limit="120" />
</launch> | 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/include/tf2_geometry_msgs/tf2_geometry_msgs.h | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Wim Meeussen */
#ifndef TF2_GEOMETRY_MSGS_H
#define TF2_GEOMETRY_MSGS_H
#include <tf2/convert.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2/LinearMath/Transform.h>
#include <geometry_msgs/PointStamped.h>
#include <geometry_msgs/QuaternionStamped.h>
#include <geometry_msgs/TransformStamped.h>
#include <geometry_msgs/Vector3Stamped.h>
#include <geometry_msgs/Pose.h>
#include <geometry_msgs/PoseStamped.h>
#include <kdl/frames.hpp>
namespace tf2
{
inline
KDL::Frame gmTransformToKDL(const geometry_msgs::TransformStamped& t)
{
return KDL::Frame(KDL::Rotation::Quaternion(t.transform.rotation.x, t.transform.rotation.y,
t.transform.rotation.z, t.transform.rotation.w),
KDL::Vector(t.transform.translation.x, t.transform.translation.y, t.transform.translation.z));
}
/********************/
/** Vector3Stamped **/
/********************/
// method to extract timestamp from object
template <>
inline
const ros::Time& getTimestamp(const geometry_msgs::Vector3Stamped& t) {return t.header.stamp;}
// method to extract frame id from object
template <>
inline
const std::string& getFrameId(const geometry_msgs::Vector3Stamped& t) {return t.header.frame_id;}
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const geometry_msgs::Vector3Stamped& t_in, geometry_msgs::Vector3Stamped& t_out, const geometry_msgs::TransformStamped& transform)
{
KDL::Vector v_out = gmTransformToKDL(transform).M * KDL::Vector(t_in.vector.x, t_in.vector.y, t_in.vector.z);
t_out.vector.x = v_out[0];
t_out.vector.y = v_out[1];
t_out.vector.z = v_out[2];
t_out.header.stamp = transform.header.stamp;
t_out.header.frame_id = transform.header.frame_id;
}
inline
geometry_msgs::Vector3Stamped toMsg(const geometry_msgs::Vector3Stamped& in)
{
return in;
}
inline
void fromMsg(const geometry_msgs::Vector3Stamped& msg, geometry_msgs::Vector3Stamped& out)
{
out = msg;
}
/******************/
/** PointStamped **/
/******************/
// method to extract timestamp from object
template <>
inline
const ros::Time& getTimestamp(const geometry_msgs::PointStamped& t) {return t.header.stamp;}
// method to extract frame id from object
template <>
inline
const std::string& getFrameId(const geometry_msgs::PointStamped& t) {return t.header.frame_id;}
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const geometry_msgs::PointStamped& t_in, geometry_msgs::PointStamped& t_out, const geometry_msgs::TransformStamped& transform)
{
KDL::Vector v_out = gmTransformToKDL(transform) * KDL::Vector(t_in.point.x, t_in.point.y, t_in.point.z);
t_out.point.x = v_out[0];
t_out.point.y = v_out[1];
t_out.point.z = v_out[2];
t_out.header.stamp = transform.header.stamp;
t_out.header.frame_id = transform.header.frame_id;
}
inline
geometry_msgs::PointStamped toMsg(const geometry_msgs::PointStamped& in)
{
return in;
}
inline
void fromMsg(const geometry_msgs::PointStamped& msg, geometry_msgs::PointStamped& out)
{
out = msg;
}
/*****************/
/** PoseStamped **/
/*****************/
// method to extract timestamp from object
template <>
inline
const ros::Time& getTimestamp(const geometry_msgs::PoseStamped& t) {return t.header.stamp;}
// method to extract frame id from object
template <>
inline
const std::string& getFrameId(const geometry_msgs::PoseStamped& t) {return t.header.frame_id;}
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const geometry_msgs::PoseStamped& t_in, geometry_msgs::PoseStamped& t_out, const geometry_msgs::TransformStamped& transform)
{
KDL::Vector v(t_in.pose.position.x, t_in.pose.position.y, t_in.pose.position.z);
KDL::Rotation r = KDL::Rotation::Quaternion(t_in.pose.orientation.x, t_in.pose.orientation.y, t_in.pose.orientation.z, t_in.pose.orientation.w);
KDL::Frame v_out = gmTransformToKDL(transform) * KDL::Frame(r, v);
t_out.pose.position.x = v_out.p[0];
t_out.pose.position.y = v_out.p[1];
t_out.pose.position.z = v_out.p[2];
v_out.M.GetQuaternion(t_out.pose.orientation.x, t_out.pose.orientation.y, t_out.pose.orientation.z, t_out.pose.orientation.w);
t_out.header.stamp = transform.header.stamp;
t_out.header.frame_id = transform.header.frame_id;
}
inline
geometry_msgs::PoseStamped toMsg(const geometry_msgs::PoseStamped& in)
{
return in;
}
inline
void fromMsg(const geometry_msgs::PoseStamped& msg, geometry_msgs::PoseStamped& out)
{
out = msg;
}
/****************/
/** Quaternion **/
/****************/
inline
geometry_msgs::Quaternion toMsg(const tf2::Quaternion& in)
{
geometry_msgs::Quaternion out;
out.w = in.getW();
out.x = in.getX();
out.y = in.getY();
out.z = in.getZ();
return out;
}
inline
void fromMsg(const geometry_msgs::Quaternion& in, tf2::Quaternion& out)
{
// w at the end in the constructor
out = tf2::Quaternion(in.x, in.y, in.z, in.w);
}
/***********************/
/** QuaternionStamped **/
/***********************/
// method to extract timestamp from object
template <>
inline
const ros::Time& getTimestamp(const geometry_msgs::QuaternionStamped& t) {return t.header.stamp;}
// method to extract frame id from object
template <>
inline
const std::string& getFrameId(const geometry_msgs::QuaternionStamped& t) {return t.header.frame_id;}
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const geometry_msgs::QuaternionStamped& t_in, geometry_msgs::QuaternionStamped& t_out, const geometry_msgs::TransformStamped& transform)
{
tf2::Quaternion q_out = tf2::Quaternion(transform.transform.rotation.x, transform.transform.rotation.y,
transform.transform.rotation.z, transform.transform.rotation.w)*
tf2::Quaternion(t_in.quaternion.x, t_in.quaternion.y, t_in.quaternion.z, t_in.quaternion.w);
t_out.quaternion = toMsg(q_out);
t_out.header.stamp = transform.header.stamp;
t_out.header.frame_id = transform.header.frame_id;
}
inline
geometry_msgs::QuaternionStamped toMsg(const geometry_msgs::QuaternionStamped& in)
{
return in;
}
inline
void fromMsg(const geometry_msgs::QuaternionStamped& msg, geometry_msgs::QuaternionStamped& out)
{
out = msg;
}
template <>
inline
geometry_msgs::QuaternionStamped toMsg(const tf2::Stamped<tf2::Quaternion>& in)
{
geometry_msgs::QuaternionStamped out;
out.header.stamp = in.stamp_;
out.header.frame_id = in.frame_id_;
out.quaternion.w = in.getW();
out.quaternion.x = in.getX();
out.quaternion.y = in.getY();
out.quaternion.z = in.getZ();
return out;
}
template <>
inline
void fromMsg(const geometry_msgs::QuaternionStamped& in, tf2::Stamped<tf2::Quaternion>& out)
{
out.stamp_ = in.header.stamp;
out.frame_id_ = in.header.frame_id;
tf2::Quaternion tmp;
fromMsg(in.quaternion, tmp);
out.setData(tmp);
}
/**********************/
/** TransformStamped **/
/**********************/
// method to extract timestamp from object
template <>
inline
const ros::Time& getTimestamp(const geometry_msgs::TransformStamped& t) {return t.header.stamp;}
// method to extract frame id from object
template <>
inline
const std::string& getFrameId(const geometry_msgs::TransformStamped& t) {return t.header.frame_id;}
// this method needs to be implemented by client library developers
template <>
inline
void doTransform(const geometry_msgs::TransformStamped& t_in, geometry_msgs::TransformStamped& t_out, const geometry_msgs::TransformStamped& transform)
{
KDL::Vector v(t_in.transform.translation.x, t_in.transform.translation.y,
t_in.transform.translation.z);
KDL::Rotation r = KDL::Rotation::Quaternion(t_in.transform.rotation.x,
t_in.transform.rotation.y, t_in.transform.rotation.z, t_in.transform.rotation.w);
KDL::Frame v_out = gmTransformToKDL(transform) * KDL::Frame(r, v);
t_out.transform.translation.x = v_out.p[0];
t_out.transform.translation.y = v_out.p[1];
t_out.transform.translation.z = v_out.p[2];
v_out.M.GetQuaternion(t_out.transform.rotation.x, t_out.transform.rotation.y,
t_out.transform.rotation.z, t_out.transform.rotation.w);
t_out.header.stamp = transform.header.stamp;
t_out.header.frame_id = transform.header.frame_id;
}
inline
geometry_msgs::TransformStamped toMsg(const geometry_msgs::TransformStamped& in)
{
return in;
}
inline
void fromMsg(const geometry_msgs::TransformStamped& msg, geometry_msgs::TransformStamped& out)
{
out = msg;
}
/***************/
/** Transform **/
/***************/
inline
geometry_msgs::Transform toMsg(const tf2::Transform& in)
{
geometry_msgs::Transform out;
out.translation.x = in.getOrigin().getX();
out.translation.y = in.getOrigin().getY();
out.translation.z = in.getOrigin().getZ();
out.rotation = toMsg(in.getRotation());
return out;
}
inline
void fromMsg(const geometry_msgs::Transform& in, tf2::Transform& out)
{
out.setOrigin(tf2::Vector3(in.translation.x, in.translation.y, in.translation.z));
// w at the end in the constructor
out.setRotation(tf2::Quaternion(in.rotation.x, in.rotation.y, in.rotation.z, in.rotation.w));
}
/**********/
/** Pose **/
/**********/
inline
/** This section is about converting */
void toMsg(const tf2::Transform& in, geometry_msgs::Pose& out )
{
out.position.x = in.getOrigin().getX();
out.position.y = in.getOrigin().getY();
out.position.z = in.getOrigin().getZ();
out.orientation = toMsg(in.getRotation());
}
inline
void fromMsg(const geometry_msgs::Pose& in, tf2::Transform& out)
{
out.setOrigin(tf2::Vector3(in.position.x, in.position.y, in.position.z));
// w at the end in the constructor
out.setRotation(tf2::Quaternion(in.orientation.x, in.orientation.y, in.orientation.z, in.orientation.w));
}
} // namespace
#endif // TF2_GEOMETRY_MSGS_H
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/scripts/test.py | #!/usr/bin/python
import unittest
import rospy
import PyKDL
import tf2_ros
import tf2_geometry_msgs
from geometry_msgs.msg import TransformStamped, PointStamped, Vector3Stamped, PoseStamped
class GeometryMsgs(unittest.TestCase):
def test_transform(self):
b = tf2_ros.Buffer()
t = TransformStamped()
t.transform.translation.x = 1
t.transform.rotation.x = 1
t.header.stamp = rospy.Time(2.0)
t.header.frame_id = 'a'
t.child_frame_id = 'b'
b.set_transform(t, 'eitan_rocks')
out = b.lookup_transform('a','b', rospy.Time(2.0), rospy.Duration(2.0))
self.assertEqual(out.transform.translation.x, 1)
self.assertEqual(out.transform.rotation.x, 1)
self.assertEqual(out.header.frame_id, 'a')
self.assertEqual(out.child_frame_id, 'b')
v = PointStamped()
v.header.stamp = rospy.Time(2)
v.header.frame_id = 'a'
v.point.x = 1
v.point.y = 2
v.point.z = 3
out = b.transform(v, 'b')
self.assertEqual(out.point.x, 0)
self.assertEqual(out.point.y, -2)
self.assertEqual(out.point.z, -3)
v = PoseStamped()
v.header.stamp = rospy.Time(2)
v.header.frame_id = 'a'
v.pose.position.x = 1
v.pose.position.y = 2
v.pose.position.z = 3
v.pose.orientation.x = 1
out = b.transform(v, 'b')
self.assertEqual(out.pose.position.x, 0)
self.assertEqual(out.pose.position.y, -2)
self.assertEqual(out.pose.position.z, -3)
# Translation shouldn't affect Vector3
t = TransformStamped()
t.transform.translation.x = 1
t.transform.translation.y = 2
t.transform.translation.z = 3
t.transform.rotation.w = 1
v = Vector3Stamped()
v.vector.x = 1
v.vector.y = 0
v.vector.z = 0
out = tf2_geometry_msgs.do_transform_vector3(v, t)
self.assertEqual(out.vector.x, 1)
self.assertEqual(out.vector.y, 0)
self.assertEqual(out.vector.z, 0)
# Rotate Vector3 180 deg about y
t = TransformStamped()
t.transform.translation.x = 1
t.transform.translation.y = 2
t.transform.translation.z = 3
t.transform.rotation.y = 1
v = Vector3Stamped()
v.vector.x = 1
v.vector.y = 0
v.vector.z = 0
out = tf2_geometry_msgs.do_transform_vector3(v, t)
self.assertEqual(out.vector.x, -1)
self.assertEqual(out.vector.y, 0)
self.assertEqual(out.vector.z, 0)
if __name__ == '__main__':
import rosunit
rospy.init_node('test_tf2_geometry_msgs_python')
rosunit.unitrun("test_tf2_geometry_msgs", "test_tf2_geometry_msgs_python", GeometryMsgs)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/src/tf2_geometry_msgs/__init__.py | from tf2_geometry_msgs import *
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_geometry_msgs/src/tf2_geometry_msgs/tf2_geometry_msgs.py | # Copyright (c) 2008, Willow Garage, Inc.
# 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 Willow Garage, Inc. 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 OWNER 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.
# author: Wim Meeussen
from geometry_msgs.msg import PoseStamped, Vector3Stamped, PointStamped
import PyKDL
import rospy
import tf2_ros
def to_msg_msg(msg):
return msg
tf2_ros.ConvertRegistration().add_to_msg(Vector3Stamped, to_msg_msg)
tf2_ros.ConvertRegistration().add_to_msg(PoseStamped, to_msg_msg)
tf2_ros.ConvertRegistration().add_to_msg(PointStamped, to_msg_msg)
def from_msg_msg(msg):
return msg
tf2_ros.ConvertRegistration().add_from_msg(Vector3Stamped, from_msg_msg)
tf2_ros.ConvertRegistration().add_from_msg(PoseStamped, from_msg_msg)
tf2_ros.ConvertRegistration().add_from_msg(PointStamped, from_msg_msg)
def transform_to_kdl(t):
return PyKDL.Frame(PyKDL.Rotation.Quaternion(t.transform.rotation.x, t.transform.rotation.y,
t.transform.rotation.z, t.transform.rotation.w),
PyKDL.Vector(t.transform.translation.x,
t.transform.translation.y,
t.transform.translation.z))
# PointStamped
def do_transform_point(point, transform):
p = transform_to_kdl(transform) * PyKDL.Vector(point.point.x, point.point.y, point.point.z)
res = PointStamped()
res.point.x = p[0]
res.point.y = p[1]
res.point.z = p[2]
res.header = transform.header
return res
tf2_ros.TransformRegistration().add(PointStamped, do_transform_point)
# Vector3Stamped
def do_transform_vector3(vector3, transform):
transform.transform.translation.x = 0;
transform.transform.translation.y = 0;
transform.transform.translation.z = 0;
p = transform_to_kdl(transform) * PyKDL.Vector(vector3.vector.x, vector3.vector.y, vector3.vector.z)
res = Vector3Stamped()
res.vector.x = p[0]
res.vector.y = p[1]
res.vector.z = p[2]
res.header = transform.header
return res
tf2_ros.TransformRegistration().add(Vector3Stamped, do_transform_vector3)
# PoseStamped
def do_transform_pose(pose, transform):
f = transform_to_kdl(transform) * PyKDL.Frame(PyKDL.Rotation.Quaternion(pose.pose.orientation.x, pose.pose.orientation.y,
pose.pose.orientation.z, pose.pose.orientation.w),
PyKDL.Vector(pose.pose.position.x, pose.pose.position.y, pose.pose.position.z))
res = PoseStamped()
res.pose.position.x = f.p[0]
res.pose.position.y = f.p[1]
res.pose.position.z = f.p[2]
(res.pose.orientation.x, res.pose.orientation.y, res.pose.orientation.z, res.pose.orientation.w) = f.M.GetQuaternion()
res.header = transform.header
return res
tf2_ros.TransformRegistration().add(PoseStamped, do_transform_pose)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
project(tf2_ros)
if(NOT ANDROID)
set(TF2_PY tf2_py)
endif()
find_package(catkin REQUIRED COMPONENTS
actionlib
actionlib_msgs
geometry_msgs
message_filters
roscpp
rosgraph
rospy
tf2
tf2_msgs
${TF2_PY}
)
find_package(Boost REQUIRED COMPONENTS thread)
catkin_python_setup()
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS
actionlib
actionlib_msgs
geometry_msgs
message_filters
roscpp
rosgraph
tf2
tf2_msgs
${TF2_PY}
)
include_directories(include ${catkin_INCLUDE_DIRS})
# tf2_ros library
add_library(${PROJECT_NAME}
src/buffer.cpp
src/transform_listener.cpp
src/buffer_client.cpp
src/buffer_server.cpp
src/transform_broadcaster.cpp
src/static_transform_broadcaster.cpp
)
add_dependencies(${PROJECT_NAME} tf2_msgs_gencpp)
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
# buffer_server executable
add_executable(${PROJECT_NAME}_buffer_server src/buffer_server_main.cpp)
add_dependencies(${PROJECT_NAME}_buffer_server tf2_msgs_gencpp)
target_link_libraries(${PROJECT_NAME}_buffer_server
${PROJECT_NAME}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
)
set_target_properties(${PROJECT_NAME}_buffer_server
PROPERTIES OUTPUT_NAME buffer_server
)
# static_transform_publisher
add_executable(${PROJECT_NAME}_static_transform_publisher
src/static_transform_broadcaster_program.cpp
)
add_dependencies(${PROJECT_NAME}_static_transform_publisher tf2_msgs_gencpp)
target_link_libraries(${PROJECT_NAME}_static_transform_publisher
${PROJECT_NAME}
${catkin_LIBRARIES}
)
set_target_properties(${PROJECT_NAME}_static_transform_publisher
PROPERTIES OUTPUT_NAME static_transform_publisher
)
# Install rules
install(TARGETS
${PROJECT_NAME} ${PROJECT_NAME}_buffer_server
${PROJECT_NAME}_static_transform_publisher
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
# Tests
if(CATKIN_ENABLE_TESTING)
# new requirements for testing
find_package(catkin REQUIRED COMPONENTS
actionlib
actionlib_msgs
geometry_msgs
message_filters
roscpp
rosgraph
rospy
rostest
tf2
tf2_msgs
${TF2_PY}
)
# tf2_ros_test_listener
add_executable(${PROJECT_NAME}_test_listener EXCLUDE_FROM_ALL test/listener_unittest.cpp)
add_dependencies(${PROJECT_NAME}_test_listener tf2_msgs_gencpp)
add_executable(${PROJECT_NAME}_test_time_reset EXCLUDE_FROM_ALL test/time_reset_test.cpp)
add_dependencies(${PROJECT_NAME}_test_time_reset tf2_msgs_gencpp)
target_link_libraries(${PROJECT_NAME}_test_listener
${PROJECT_NAME}
${catkin_LIBRARIES}
${GTEST_LIBRARIES}
)
target_link_libraries(${PROJECT_NAME}_test_time_reset
${PROJECT_NAME}
${catkin_LIBRARIES}
${GTEST_LIBRARIES}
)
add_dependencies(tests ${PROJECT_NAME}_test_listener)
add_dependencies(tests ${PROJECT_NAME}_test_time_reset)
add_rostest(test/transform_listener_unittest.launch)
add_rostest(test/transform_listener_time_reset_test.launch)
endif()
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/package.xml | <package>
<name>tf2_ros</name>
<version>0.5.13</version>
<description>
This package contains the ROS bindings for the tf2 library, for both Python and C++.
</description>
<author>Eitan Marder-Eppstein</author>
<author>Wim Meeussen</author>
<maintainer email="tfoote@osrfoundation.org">Tully Foote</maintainer>
<license>BSD</license>
<url type="website">http://www.ros.org/wiki/tf2_ros</url>
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>actionlib</build_depend>
<build_depend>actionlib_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend version_gte="1.11.1">message_filters</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rosgraph</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>tf2</build_depend>
<build_depend>tf2_msgs</build_depend>
<build_depend>tf2_py</build_depend>
<run_depend>actionlib</run_depend>
<run_depend>actionlib_msgs</run_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>message_filters</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rosgraph</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>tf2</run_depend>
<run_depend>tf2_msgs</run_depend>
<run_depend>tf2_py</run_depend>
<test_depend>rostest</test_depend>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/rosdoc.yaml | - builder: doxygen
name: C++ API
output_dir: c++
file_patterns: '*.c *.cpp *.h *.cc *.hh *.dox'
- builder: sphinx
name: Python API
output_dir: python
sphinx_root_dir: doc
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/setup.py | #!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=['tf2_ros'],
package_dir={'': 'src'},
requires=['rospy', 'actionlib', 'actionlib_msgs', 'tf2_msgs',
'tf2_py', 'geometry_msgs']
)
setup(**d)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/.tar | {!!python/unicode 'url': 'https://github.com/ros-gbp/geometry2-release/archive/release/indigo/tf2_ros/0.5.13-0.tar.gz',
!!python/unicode 'version': geometry2-release-release-indigo-tf2_ros-0.5.13-0}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/CHANGELOG.rst | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package tf2_ros
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.5.13 (2016-03-04)
-------------------
* fix documentation warnings
* Adding tests to package
* Contributors: Laurent GEORGE, Vincent Rabaud
0.5.12 (2015-08-05)
-------------------
* remove annoying gcc warning
This is because the roslog macro cannot have two arguments that are
formatting strings: we need to concatenate them first.
* break canTransform loop only for non-tiny negative time deltas
(At least) with Python 2 ros.Time.now() is not necessarily monotonic
and one can experience negative time deltas (usually well below 1s)
on real hardware under full load. This check was originally introduced
to allow for backjumps with rosbag replays, and only there it makes sense.
So we'll add a small duration threshold to ignore backjumps due to
non-monotonic clocks.
* Contributors: Vincent Rabaud, v4hn
0.5.11 (2015-04-22)
-------------------
* do not short circuit waitForTransform timeout when running inside pytf. Fixes `#102 <https://github.com/ros/geometry_experimental/issues/102>`_
roscpp is not initialized inside pytf which means that ros::ok is not
valid. This was causing the timer to abort immediately.
This breaks support for pytf with respect to early breaking out of a loop re `#26 <https://github.com/ros/geometry_experimental/issues/26>`_.
This is conceptually broken in pytf, and is fixed in tf2_ros python implementation.
If you want this behavior I recommend switching to the tf2 python bindings.
* inject timeout information into error string for canTransform with timeout
* Contributors: Tully Foote
0.5.10 (2015-04-21)
-------------------
* switch to use a shared lock with upgrade instead of only a unique lock. For `#91 <https://github.com/ros/geometry_experimental/issues/91>`_
* Update message_filter.h
* filters: fix unsupported old messages with frame_id starting with '/'
* Enabled tf2 documentation
* make sure the messages get processed before testing the effects. Fixes `#88 <https://github.com/ros/geometry_experimental/issues/88>`_
* allowing to use message filters with PCL types
* Contributors: Brice Rebsamen, Jackie Kay, Tully Foote, Vincent Rabaud, jmtatsch
0.5.9 (2015-03-25)
------------------
* changed queue_size in Python transform boradcaster to match that in c++
* Contributors: mrath
0.5.8 (2015-03-17)
------------------
* fix deadlock `#79 <https://github.com/ros/geometry_experimental/issues/79>`_
* break out of loop if ros is shutdown. Fixes `#26 <https://github.com/ros/geometry_experimental/issues/26>`_
* remove useless Makefile files
* Fix static broadcaster with rpy args
* Contributors: Paul Bovbel, Tully Foote, Vincent Rabaud
0.5.7 (2014-12-23)
------------------
* Added 6 param transform again
Yes, using Euler angles is a bad habit. But it is much more convenient if you just need a rotation by 90° somewhere to set it up in Euler angles. So I added the option to supply only the 3 angles.
* Remove tf2_py dependency for Android
* Contributors: Achim Königs, Gary Servin
0.5.6 (2014-09-18)
------------------
* support if canTransform(...): in python `#57 <https://github.com/ros/geometry_experimental/issues/57>`_
* Support clearing the cache when time jumps backwards `#68 <https://github.com/ros/geometry_experimental/issues/68>`_
* Contributors: Tully Foote
0.5.5 (2014-06-23)
------------------
0.5.4 (2014-05-07)
------------------
* surpressing autostart on the server objects to not incur warnings
* switch to boost signals2 following `ros/ros_comm#267 <https://github.com/ros/ros_comm/issues/267>`_, blocking `ros/geometry#23 <https://github.com/ros/geometry/issues/23>`_
* fix compilation with gcc 4.9
* make can_transform correctly wait
* explicitly set the publish queue size for rospy
* Contributors: Tully Foote, Vincent Rabaud, v4hn
0.5.3 (2014-02-21)
------------------
0.5.2 (2014-02-20)
------------------
0.5.1 (2014-02-14)
------------------
* adding const to MessageEvent data
* Contributors: Tully Foote
0.5.0 (2014-02-14)
------------------
* TF2 uses message events to get connection header information
* Contributors: Kevin Watts
0.4.10 (2013-12-26)
-------------------
* adding support for static transforms in python listener. Fixes `#46 <https://github.com/ros/geometry_experimental/issues/46>`_
* Contributors: Tully Foote
0.4.9 (2013-11-06)
------------------
0.4.8 (2013-11-06)
------------------
* fixing pytf failing to sleep https://github.com/ros/geometry/issues/30
* moving python documentation to tf2_ros from tf2 to follow the code
* Fixed static_transform_publisher duplicate check, added rostest.
0.4.7 (2013-08-28)
------------------
* fixing new conditional to cover the case that time has not progressed yet port forward of `ros/geometry#35 <https://github.com/ros/geometry/issues/35>`_ in the python implementation
* fixing new conditional to cover the case that time has not progressed yet port forward of `ros/geometry#35 <https://github.com/ros/geometry/issues/35>`_
0.4.6 (2013-08-28)
------------------
* patching python implementation for `#24 <https://github.com/ros/geometry_experimental/issues/24>`_ as well
* Stop waiting if time jumps backwards. fixes `#24 <https://github.com/ros/geometry_experimental/issues/24>`_
* patch to work around uninitiaized time. `#30 https://github.com/ros/geometry/issues/30`_
* Removing unnecessary CATKIN_DEPENDS `#18 <https://github.com/ros/geometry_experimental/issues/18>`_
0.4.5 (2013-07-11)
------------------
* Revert "cherrypicking groovy patch for `#10 <https://github.com/ros/geometry_experimental/issues/10>`_ into hydro"
This reverts commit 296d4916706d64f719b8c1592ab60d3686f994e1.
It was not starting up correctly.
* fixing usage string to show quaternions and using quaternions in the test app
* cherrypicking groovy patch for `#10 <https://github.com/ros/geometry_experimental/issues/10>`_ into hydro
0.4.4 (2013-07-09)
------------------
* making repo use CATKIN_ENABLE_TESTING correctly and switching rostest to be a test_depend with that change.
* reviving unrun unittest and adding CATKIN_ENABLE_TESTING guards
0.4.3 (2013-07-05)
------------------
0.4.2 (2013-07-05)
------------------
0.4.1 (2013-07-05)
------------------
* adding queue accessors lost in the new API
* exposing dedicated thread logic in BufferCore and checking in Buffer
* adding methods to enable backwards compatability for passing through to tf::Transformer
0.4.0 (2013-06-27)
------------------
* splitting rospy dependency into tf2_py so tf2 is pure c++ library.
* moving convert methods back into tf2 because it does not have any ros dependencies beyond ros::Time which is already a dependency of tf2
* Cleaning up unnecessary dependency on roscpp
* converting contents of tf2_ros to be properly namespaced in the tf2_ros namespace
* fixing return by value for tranform method without preallocatoin
* Cleaning up packaging of tf2 including:
removing unused nodehandle
cleaning up a few dependencies and linking
removing old backup of package.xml
making diff minimally different from tf version of library
* Restoring test packages and bullet packages.
reverting 3570e8c42f9b394ecbfd9db076b920b41300ad55 to get back more of the packages previously implemented
reverting 04cf29d1b58c660fdc999ab83563a5d4b76ab331 to fix `#7 <https://github.com/ros/geometry_experimental/issues/7>`_
* Added link against catkin_LIBRARIES for tf2_ros lib, also CMakeLists.txt clean up
0.3.6 (2013-03-03)
------------------
0.3.5 (2013-02-15 14:46)
------------------------
* 0.3.4 -> 0.3.5
0.3.4 (2013-02-15 13:14)
------------------------
* 0.3.3 -> 0.3.4
0.3.3 (2013-02-15 11:30)
------------------------
* 0.3.2 -> 0.3.3
0.3.2 (2013-02-15 00:42)
------------------------
* 0.3.1 -> 0.3.2
0.3.1 (2013-02-14)
------------------
* 0.3.0 -> 0.3.1
0.3.0 (2013-02-13)
------------------
* switching to version 0.3.0
* Merge pull request `#2 <https://github.com/ros/geometry_experimental/issues/2>`_ from KaijenHsiao/groovy-devel
added setup.py and catkin_python_setup() to tf2_ros
* added setup.py and catkin_python_setup() to tf2_ros
* fixing cmake target collisions
* fixing catkin message dependencies
* removing packages with missing deps
* catkin fixes
* catkinizing geometry-experimental
* catkinizing tf2_ros
* catching None result in buffer client before it becomes an AttributeError, raising tf2.TransformException instead
* oneiric linker fixes, bump version to 0.2.3
* fix deprecated use of Header
* merged faust's changes 864 and 865 into non_optimized branch: BufferCore instead of Buffer in TransformListener, and added a constructor that takes a NodeHandle.
* add buffer server binary
* fix compilation on 32bit
* add missing file
* build buffer server
* TransformListener only needs a BufferCore
* Add TransformListener constructor that takes a NodeHandle so you can specify a callback queue to use
* Add option to use a callback queue in the message filter
* move the message filter to tf2_ros
* add missing std_msgs dependency
* missed 2 lines in last commit
* removing auto clearing from listener for it's unexpected from a library
* static transform tested and working
* subscriptions to tf_static unshelved
* static transform publisher executable running
* latching static transform publisher
* cleaning out old commented code
* Only query rospy.Time.now() when the timeout is greater than 0
* debug comments removed
* move to tf2_ros completed. tests pass again
* merge tf2_cpp and tf2_py into tf2_ros
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/test/transform_listener_time_reset_test.launch | <launch>
<test test-name="transform_listener_time_reset_test" pkg="tf2_ros" type="tf2_ros_test_time_reset" />
<param name="/use_sim_time" value="True"/>
</launch> | 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/test/transform_listener_unittest.launch | <launch>
<test test-name="transform_listener_unittest" pkg="tf2_ros" type="tf2_ros_test_listener" />
</launch> | 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/test/time_reset_test.cpp | /*
* Copyright (c) 2014, Open Source Robotics Foundation
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
#include <gtest/gtest.h>
#include <tf2_ros/transform_broadcaster.h>
#include <tf2_ros/transform_listener.h>
#include <sys/time.h>
#include <rosgraph_msgs/Clock.h>
using namespace tf2;
TEST(tf2_ros_transform_listener, time_backwards)
{
tf2_ros::Buffer buffer;
tf2_ros::TransformListener tfl(buffer);
tf2_ros::TransformBroadcaster tfb;
ros::NodeHandle nh = ros::NodeHandle();
ros::Publisher clock = nh.advertise<rosgraph_msgs::Clock>("/clock", 5);
rosgraph_msgs::Clock c;
c.clock = ros::Time(100);
clock.publish(c);
// basic test
ASSERT_FALSE(buffer.canTransform("foo", "bar", ros::Time(101, 0)));
// set the transform
geometry_msgs::TransformStamped msg;
msg.header.stamp = ros::Time(100, 0);
msg.header.frame_id = "foo";
msg.child_frame_id = "bar";
msg.transform.rotation.x = 1.0;
tfb.sendTransform(msg);
msg.header.stamp = ros::Time(102, 0);
tfb.sendTransform(msg);
// make sure it arrives
ros::spinOnce();
sleep(1);
// verify it's been set
ASSERT_TRUE(buffer.canTransform("foo", "bar", ros::Time(101, 0)));
c.clock = ros::Time(90);
clock.publish(c);
// make sure it arrives
ros::spinOnce();
sleep(1);
//Send anoterh message to trigger clock test on an unrelated frame
msg.header.stamp = ros::Time(110, 0);
msg.header.frame_id = "foo2";
msg.child_frame_id = "bar2";
tfb.sendTransform(msg);
// make sure it arrives
ros::spinOnce();
sleep(1);
//verify the data's been cleared
ASSERT_FALSE(buffer.canTransform("foo", "bar", ros::Time(101, 0)));
}
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
ros::init(argc, argv, "transform_listener_backwards_reset");
return RUN_ALL_TESTS();
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/test/listener_unittest.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
#include <gtest/gtest.h>
#include <tf2_ros/transform_listener.h>
#include <sys/time.h>
void seed_rand()
{
//Seed random number generator with current microseond count
timeval temp_time_struct;
gettimeofday(&temp_time_struct,NULL);
srand(temp_time_struct.tv_usec);
};
void generate_rand_vectors(double scale, uint64_t runs, std::vector<double>& xvalues, std::vector<double>& yvalues, std::vector<double>&zvalues)
{
seed_rand();
for ( uint64_t i = 0; i < runs ; i++ )
{
xvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
yvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
zvalues[i] = 1.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
}
}
using namespace tf2;
TEST(tf2_ros_transform, transform_listener)
{
tf2_ros::Buffer buffer;
tf2_ros::TransformListener tfl(buffer);
}
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
ros::init(argc, argv, "transform_listener_unittest");
return RUN_ALL_TESTS();
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include/tf2_ros/transform_listener.h | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Tully Foote */
#ifndef TF2_ROS_TRANSFORMLISTENER_H
#define TF2_ROS_TRANSFORMLISTENER_H
#include "std_msgs/Empty.h"
#include "tf2_msgs/TFMessage.h"
#include "ros/ros.h"
#include "ros/callback_queue.h"
#include "tf2_ros/buffer.h"
#include "boost/thread.hpp"
namespace tf2_ros{
class TransformListener
{
public:
/**@brief Constructor for transform listener */
TransformListener(tf2::BufferCore& buffer, bool spin_thread = true);
TransformListener(tf2::BufferCore& buffer, const ros::NodeHandle& nh, bool spin_thread = true);
~TransformListener();
private:
/// Initialize this transform listener, subscribing, advertising services, etc.
void init();
void initWithThread();
/// Callback function for ros message subscriptoin
void subscription_callback(const ros::MessageEvent<tf2_msgs::TFMessage const>& msg_evt);
void static_subscription_callback(const ros::MessageEvent<tf2_msgs::TFMessage const>& msg_evt);
void subscription_callback_impl(const ros::MessageEvent<tf2_msgs::TFMessage const>& msg_evt, bool is_static);
ros::CallbackQueue tf_message_callback_queue_;
boost::thread* dedicated_listener_thread_;
ros::NodeHandle node_;
ros::Subscriber message_subscriber_tf_;
ros::Subscriber message_subscriber_tf_static_;
tf2::BufferCore& buffer_;
bool using_dedicated_thread_;
ros::Time last_update_;
void dedicatedListenerThread()
{
while (using_dedicated_thread_)
{
tf_message_callback_queue_.callAvailable(ros::WallDuration(0.01));
}
};
};
}
#endif //TF_TRANSFORMLISTENER_H
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include/tf2_ros/transform_broadcaster.h | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Tully Foote */
#ifndef TF2_ROS_TRANSFORMBROADCASTER_H
#define TF2_ROS_TRANSFORMBROADCASTER_H
#include "ros/ros.h"
#include "geometry_msgs/TransformStamped.h"
namespace tf2_ros
{
/** \brief This class provides an easy way to publish coordinate frame transform information.
* It will handle all the messaging and stuffing of messages. And the function prototypes lay out all the
* necessary data needed for each message. */
class TransformBroadcaster{
public:
/** \brief Constructor (needs a ros::Node reference) */
TransformBroadcaster();
/** \brief Send a StampedTransform
* The stamped data structure includes frame_id, and time, and parent_id already. */
// void sendTransform(const StampedTransform & transform);
/** \brief Send a vector of StampedTransforms
* The stamped data structure includes frame_id, and time, and parent_id already. */
//void sendTransform(const std::vector<StampedTransform> & transforms);
/** \brief Send a TransformStamped message
* The stamped data structure includes frame_id, and time, and parent_id already. */
void sendTransform(const geometry_msgs::TransformStamped & transform);
/** \brief Send a vector of TransformStamped messages
* The stamped data structure includes frame_id, and time, and parent_id already. */
void sendTransform(const std::vector<geometry_msgs::TransformStamped> & transforms);
private:
/// Internal reference to ros::Node
ros::NodeHandle node_;
ros::Publisher publisher_;
};
}
#endif //TF_TRANSFORMBROADCASTER_H
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include/tf2_ros/static_transform_broadcaster.h | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Tully Foote */
#ifndef TF2_ROS_STATICTRANSFORMBROADCASTER_H
#define TF2_ROS_STATICTRANSFORMBROADCASTER_H
#include "ros/ros.h"
#include "geometry_msgs/TransformStamped.h"
#include "tf2_msgs/TFMessage.h"
namespace tf2_ros
{
/** \brief This class provides an easy way to publish coordinate frame transform information.
* It will handle all the messaging and stuffing of messages. And the function prototypes lay out all the
* necessary data needed for each message. */
class StaticTransformBroadcaster{
public:
/** \brief Constructor (needs a ros::Node reference) */
StaticTransformBroadcaster();
/** \brief Send a TransformStamped message
* The stamped data structure includes frame_id, and time, and parent_id already. */
void sendTransform(const geometry_msgs::TransformStamped & transform);
/** \brief Send a vector of TransformStamped messages
* The stamped data structure includes frame_id, and time, and parent_id already. */
void sendTransform(const std::vector<geometry_msgs::TransformStamped> & transforms);
private:
/// Internal reference to ros::Node
ros::NodeHandle node_;
ros::Publisher publisher_;
tf2_msgs::TFMessage net_message_;
};
}
#endif //TF_STATICTRANSFORMBROADCASTER_H
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include/tf2_ros/buffer_server.h | /*********************************************************************
*
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*
* Author: Eitan Marder-Eppstein
*********************************************************************/
#ifndef TF2_ROS_BUFFER_SERVER_H_
#define TF2_ROS_BUFFER_SERVER_H_
#include <actionlib/server/action_server.h>
#include <tf2_msgs/LookupTransformAction.h>
#include <geometry_msgs/TransformStamped.h>
#include <tf2_ros/buffer.h>
namespace tf2_ros
{
class BufferServer
{
private:
typedef actionlib::ActionServer<tf2_msgs::LookupTransformAction> LookupTransformServer;
typedef LookupTransformServer::GoalHandle GoalHandle;
struct GoalInfo
{
GoalHandle handle;
ros::Time end_time;
};
public:
BufferServer(const Buffer& buffer, const std::string& ns,
bool auto_start = true, ros::Duration check_period = ros::Duration(0.01));
void start();
private:
void goalCB(GoalHandle gh);
void cancelCB(GoalHandle gh);
void checkTransforms(const ros::TimerEvent& e);
bool canTransform(GoalHandle gh);
geometry_msgs::TransformStamped lookupTransform(GoalHandle gh);
const Buffer& buffer_;
LookupTransformServer server_;
std::list<GoalInfo> active_goals_;
boost::mutex mutex_;
ros::Timer check_timer_;
};
}
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include/tf2_ros/message_filter.h | /*
* Copyright (c) 2010, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Josh Faust */
#ifndef TF2_ROS_MESSAGE_FILTER_H
#define TF2_ROS_MESSAGE_FILTER_H
#include <tf2/buffer_core.h>
#include <string>
#include <list>
#include <vector>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <message_filters/connection.h>
#include <message_filters/simple_filter.h>
#include <ros/node_handle.h>
#include <ros/callback_queue_interface.h>
#include <ros/init.h>
#define TF2_ROS_MESSAGEFILTER_DEBUG(fmt, ...) \
ROS_DEBUG_NAMED("message_filter", std::string(std::string("MessageFilter [target=%s]: ") + std::string(fmt)).c_str(), getTargetFramesString().c_str(), __VA_ARGS__)
#define TF2_ROS_MESSAGEFILTER_WARN(fmt, ...) \
ROS_WARN_NAMED("message_filter", std::string(std::string("MessageFilter [target=%s]: ") + std::string(fmt)).c_str(), getTargetFramesString().c_str(), __VA_ARGS__)
namespace tf2_ros
{
namespace filter_failure_reasons
{
enum FilterFailureReason
{
/// The message buffer overflowed, and this message was pushed off the back of the queue, but the reason it was unable to be transformed is unknown.
Unknown,
/// The timestamp on the message is more than the cache length earlier than the newest data in the transform cache
OutTheBack,
/// The frame_id on the message is empty
EmptyFrameID,
};
}
typedef filter_failure_reasons::FilterFailureReason FilterFailureReason;
class MessageFilterBase
{
public:
typedef std::vector<std::string> V_string;
virtual ~MessageFilterBase(){}
virtual void clear() = 0;
virtual void setTargetFrame(const std::string& target_frame) = 0;
virtual void setTargetFrames(const V_string& target_frames) = 0;
virtual void setTolerance(const ros::Duration& tolerance) = 0;
};
/**
* \brief Follows the patterns set by the message_filters package to implement a filter which only passes messages through once there is transform data available
*
* The callbacks used in this class are of the same form as those used by roscpp's message callbacks.
*
* MessageFilter is templated on a message type.
*
* \section example_usage Example Usage
*
* If you want to hook a MessageFilter into a ROS topic:
\verbatim
message_filters::Subscriber<MessageType> sub(node_handle_, "topic", 10);
tf::MessageFilter<MessageType> tf_filter(sub, tf_listener_, "/map", 10);
tf_filter.registerCallback(&MyClass::myCallback, this);
\endverbatim
*/
template<class M>
class MessageFilter : public MessageFilterBase, public message_filters::SimpleFilter<M>
{
public:
typedef boost::shared_ptr<M const> MConstPtr;
typedef ros::MessageEvent<M const> MEvent;
typedef boost::function<void(const MConstPtr&, FilterFailureReason)> FailureCallback;
typedef boost::signals2::signal<void(const MConstPtr&, FilterFailureReason)> FailureSignal;
// If you hit this assert your message does not have a header, or does not have the HasHeader trait defined for it
// Actually, we need to check that the message has a header, or that it
// has the FrameId and Stamp traits. However I don't know how to do that
// so simply commenting out for now.
//ROS_STATIC_ASSERT(ros::message_traits::HasHeader<M>::value);
/**
* \brief Constructor
*
* \param bc The tf2::BufferCore this filter should use
* \param target_frame The frame this filter should attempt to transform to. To use multiple frames, pass an empty string here and use the setTargetFrames() function.
* \param queue_size The number of messages to queue up before throwing away old ones. 0 means infinite (dangerous).
* \param nh The NodeHandle whose callback queue we should add callbacks to
*/
MessageFilter(tf2::BufferCore& bc, const std::string& target_frame, uint32_t queue_size, const ros::NodeHandle& nh)
: bc_(bc)
, queue_size_(queue_size)
, callback_queue_(nh.getCallbackQueue())
{
init();
setTargetFrame(target_frame);
}
/**
* \brief Constructor
*
* \param f The filter to connect this filter's input to. Often will be a message_filters::Subscriber.
* \param bc The tf2::BufferCore this filter should use
* \param target_frame The frame this filter should attempt to transform to. To use multiple frames, pass an empty string here and use the setTargetFrames() function.
* \param queue_size The number of messages to queue up before throwing away old ones. 0 means infinite (dangerous).
* \param nh The NodeHandle whose callback queue we should add callbacks to
*/
template<class F>
MessageFilter(F& f, tf2::BufferCore& bc, const std::string& target_frame, uint32_t queue_size, const ros::NodeHandle& nh)
: bc_(bc)
, queue_size_(queue_size)
, callback_queue_(nh.getCallbackQueue())
{
init();
setTargetFrame(target_frame);
connectInput(f);
}
/**
* \brief Constructor
*
* \param bc The tf2::BufferCore this filter should use
* \param target_frame The frame this filter should attempt to transform to. To use multiple frames, pass an empty string here and use the setTargetFrames() function.
* \param queue_size The number of messages to queue up before throwing away old ones. 0 means infinite (dangerous).
* \param cbqueue The callback queue to add callbacks to. If NULL, callbacks will happen from whatever thread either
* a) add() is called, which will generally be when the previous filter in the chain outputs a message, or
* b) tf2::BufferCore::setTransform() is called
*/
MessageFilter(tf2::BufferCore& bc, const std::string& target_frame, uint32_t queue_size, ros::CallbackQueueInterface* cbqueue)
: bc_(bc)
, queue_size_(queue_size)
, callback_queue_(cbqueue)
{
init();
setTargetFrame(target_frame);
}
/**
* \brief Constructor
*
* \param f The filter to connect this filter's input to. Often will be a message_filters::Subscriber.
* \param bc The tf2::BufferCore this filter should use
* \param target_frame The frame this filter should attempt to transform to. To use multiple frames, pass an empty string here and use the setTargetFrames() function.
* \param queue_size The number of messages to queue up before throwing away old ones. 0 means infinite (dangerous).
* \param cbqueue The callback queue to add callbacks to. If NULL, callbacks will happen from whatever thread either
* a) add() is called, which will generally be when the previous filter in the chain outputs a message, or
* b) tf2::BufferCore::setTransform() is called
*/
template<class F>
MessageFilter(F& f, tf2::BufferCore& bc, const std::string& target_frame, uint32_t queue_size, ros::CallbackQueueInterface* cbqueue)
: bc_(bc)
, queue_size_(queue_size)
, callback_queue_(cbqueue)
{
init();
setTargetFrame(target_frame);
connectInput(f);
}
/**
* \brief Connect this filter's input to another filter's output. If this filter is already connected, disconnects first.
*/
template<class F>
void connectInput(F& f)
{
message_connection_.disconnect();
message_connection_ = f.registerCallback(&MessageFilter::incomingMessage, this);
}
/**
* \brief Destructor
*/
~MessageFilter()
{
message_connection_.disconnect();
clear();
TF2_ROS_MESSAGEFILTER_DEBUG("Successful Transforms: %llu, Discarded due to age: %llu, Transform messages received: %llu, Messages received: %llu, Total dropped: %llu",
(long long unsigned int)successful_transform_count_,
(long long unsigned int)failed_out_the_back_count_, (long long unsigned int)transform_message_count_,
(long long unsigned int)incoming_message_count_, (long long unsigned int)dropped_message_count_);
}
/**
* \brief Set the frame you need to be able to transform to before getting a message callback
*/
void setTargetFrame(const std::string& target_frame)
{
V_string frames;
frames.push_back(target_frame);
setTargetFrames(frames);
}
/**
* \brief Set the frames you need to be able to transform to before getting a message callback
*/
void setTargetFrames(const V_string& target_frames)
{
boost::mutex::scoped_lock frames_lock(target_frames_mutex_);
target_frames_.resize(target_frames.size());
std::transform(target_frames.begin(), target_frames.end(), target_frames_.begin(), this->stripSlash);
expected_success_count_ = target_frames_.size() + (time_tolerance_.isZero() ? 0 : 1);
std::stringstream ss;
for (V_string::iterator it = target_frames_.begin(); it != target_frames_.end(); ++it)
{
ss << *it << " ";
}
target_frames_string_ = ss.str();
}
/**
* \brief Get the target frames as a string for debugging
*/
std::string getTargetFramesString()
{
boost::mutex::scoped_lock lock(target_frames_mutex_);
return target_frames_string_;
};
/**
* \brief Set the required tolerance for the notifier to return true
*/
void setTolerance(const ros::Duration& tolerance)
{
boost::mutex::scoped_lock lock(target_frames_mutex_);
time_tolerance_ = tolerance;
expected_success_count_ = target_frames_.size() + (time_tolerance_.isZero() ? 0 : 1);
}
/**
* \brief Clear any messages currently in the queue
*/
void clear()
{
boost::unique_lock< boost::shared_mutex > unique_lock(messages_mutex_);
TF2_ROS_MESSAGEFILTER_DEBUG("%s", "Cleared");
bc_.removeTransformableCallback(callback_handle_);
callback_handle_ = bc_.addTransformableCallback(boost::bind(&MessageFilter::transformable, this, _1, _2, _3, _4, _5));
messages_.clear();
message_count_ = 0;
warned_about_empty_frame_id_ = false;
}
void add(const MEvent& evt)
{
if (target_frames_.empty())
{
return;
}
namespace mt = ros::message_traits;
const MConstPtr& message = evt.getMessage();
std::string frame_id = stripSlash(mt::FrameId<M>::value(*message));
ros::Time stamp = mt::TimeStamp<M>::value(*message);
if (frame_id.empty())
{
messageDropped(evt, filter_failure_reasons::EmptyFrameID);
return;
}
// iterate through the target frames and add requests for each of them
MessageInfo info;
info.handles.reserve(expected_success_count_);
{
V_string target_frames_copy;
// Copy target_frames_ to avoid deadlock from #79
{
boost::mutex::scoped_lock frames_lock(target_frames_mutex_);
target_frames_copy = target_frames_;
}
V_string::iterator it = target_frames_copy.begin();
V_string::iterator end = target_frames_copy.end();
for (; it != end; ++it)
{
const std::string& target_frame = *it;
tf2::TransformableRequestHandle handle = bc_.addTransformableRequest(callback_handle_, target_frame, frame_id, stamp);
if (handle == 0xffffffffffffffffULL) // never transformable
{
messageDropped(evt, filter_failure_reasons::OutTheBack);
return;
}
else if (handle == 0)
{
++info.success_count;
}
else
{
info.handles.push_back(handle);
}
if (!time_tolerance_.isZero())
{
handle = bc_.addTransformableRequest(callback_handle_, target_frame, frame_id, stamp + time_tolerance_);
if (handle == 0xffffffffffffffffULL) // never transformable
{
messageDropped(evt, filter_failure_reasons::OutTheBack);
return;
}
else if (handle == 0)
{
++info.success_count;
}
else
{
info.handles.push_back(handle);
}
}
}
}
// We can transform already
if (info.success_count == expected_success_count_)
{
messageReady(evt);
}
else
{
// If this message is about to push us past our queue size, erase the oldest message
if (queue_size_ != 0 && message_count_ + 1 > queue_size_)
{
// While we're using the reference keep a shared lock on the messages.
boost::shared_lock< boost::shared_mutex > shared_lock(messages_mutex_);
++dropped_message_count_;
const MessageInfo& front = messages_.front();
TF2_ROS_MESSAGEFILTER_DEBUG("Removed oldest message because buffer is full, count now %d (frame_id=%s, stamp=%f)", message_count_,
(mt::FrameId<M>::value(*front.event.getMessage())).c_str(), mt::TimeStamp<M>::value(*front.event.getMessage()).toSec());
V_TransformableRequestHandle::const_iterator it = front.handles.begin();
V_TransformableRequestHandle::const_iterator end = front.handles.end();
for (; it != end; ++it)
{
bc_.cancelTransformableRequest(*it);
}
messageDropped(front.event, filter_failure_reasons::Unknown);
// Unlock the shared lock and get a unique lock. Upgradeable lock is used in transformable.
// There can only be one upgrade lock. It's important the cancelTransformableRequest not deadlock with transformable.
// They both require the transformable_requests_mutex_ in BufferCore.
shared_lock.unlock();
// There is a very slight race condition if an older message arrives in this gap.
boost::unique_lock< boost::shared_mutex > unique_lock(messages_mutex_);
messages_.pop_front();
--message_count_;
}
// Add the message to our list
info.event = evt;
// Lock access to the messages_ before modifying them.
boost::unique_lock< boost::shared_mutex > unique_lock(messages_mutex_);
messages_.push_back(info);
++message_count_;
}
TF2_ROS_MESSAGEFILTER_DEBUG("Added message in frame %s at time %.3f, count now %d", frame_id.c_str(), stamp.toSec(), message_count_);
++incoming_message_count_;
}
/**
* \brief Manually add a message into this filter.
* \note If the message (or any other messages in the queue) are immediately transformable this will immediately call through to the output callback, possibly
* multiple times
*/
void add(const MConstPtr& message)
{
boost::shared_ptr<std::map<std::string, std::string> > header(new std::map<std::string, std::string>);
(*header)["callerid"] = "unknown";
ros::WallTime n = ros::WallTime::now();
ros::Time t(n.sec, n.nsec);
add(MEvent(message, header, t));
}
/**
* \brief Register a callback to be called when a message is about to be dropped
* \param callback The callback to call
*/
message_filters::Connection registerFailureCallback(const FailureCallback& callback)
{
boost::mutex::scoped_lock lock(failure_signal_mutex_);
return message_filters::Connection(boost::bind(&MessageFilter::disconnectFailure, this, _1), failure_signal_.connect(callback));
}
virtual void setQueueSize( uint32_t new_queue_size )
{
queue_size_ = new_queue_size;
}
virtual uint32_t getQueueSize()
{
return queue_size_;
}
private:
void init()
{
message_count_ = 0;
successful_transform_count_ = 0;
failed_out_the_back_count_ = 0;
transform_message_count_ = 0;
incoming_message_count_ = 0;
dropped_message_count_ = 0;
time_tolerance_ = ros::Duration(0.0);
warned_about_empty_frame_id_ = false;
expected_success_count_ = 1;
callback_handle_ = bc_.addTransformableCallback(boost::bind(&MessageFilter::transformable, this, _1, _2, _3, _4, _5));
}
void transformable(tf2::TransformableRequestHandle request_handle, const std::string& target_frame, const std::string& source_frame,
ros::Time time, tf2::TransformableResult result)
{
namespace mt = ros::message_traits;
boost::upgrade_lock< boost::shared_mutex > lock(messages_mutex_);
// find the message this request is associated with
typename L_MessageInfo::iterator msg_it = messages_.begin();
typename L_MessageInfo::iterator msg_end = messages_.end();
for (; msg_it != msg_end; ++msg_it)
{
MessageInfo& info = *msg_it;
V_TransformableRequestHandle::const_iterator handle_it = std::find(info.handles.begin(), info.handles.end(), request_handle);
if (handle_it != info.handles.end())
{
// found msg_it
++info.success_count;
break;
}
}
if (msg_it == msg_end)
{
return;
}
const MessageInfo& info = *msg_it;
if (info.success_count < expected_success_count_)
{
return;
}
bool can_transform = true;
const MConstPtr& message = info.event.getMessage();
std::string frame_id = stripSlash(mt::FrameId<M>::value(*message));
ros::Time stamp = mt::TimeStamp<M>::value(*message);
if (result == tf2::TransformAvailable)
{
boost::mutex::scoped_lock frames_lock(target_frames_mutex_);
// make sure we can still perform all the necessary transforms
typename V_string::iterator it = target_frames_.begin();
typename V_string::iterator end = target_frames_.end();
for (; it != end; ++it)
{
const std::string& target = *it;
if (!bc_.canTransform(target, frame_id, stamp))
{
can_transform = false;
break;
}
if (!time_tolerance_.isZero())
{
if (!bc_.canTransform(target, frame_id, stamp + time_tolerance_))
{
can_transform = false;
break;
}
}
}
}
else
{
can_transform = false;
}
// We will be mutating messages now, require unique lock
boost::upgrade_to_unique_lock< boost::shared_mutex > uniqueLock(lock);
if (can_transform)
{
TF2_ROS_MESSAGEFILTER_DEBUG("Message ready in frame %s at time %.3f, count now %d", frame_id.c_str(), stamp.toSec(), message_count_ - 1);
++successful_transform_count_;
messageReady(info.event);
}
else
{
++dropped_message_count_;
TF2_ROS_MESSAGEFILTER_DEBUG("Discarding message in frame %s at time %.3f, count now %d", frame_id.c_str(), stamp.toSec(), message_count_ - 1);
messageDropped(info.event, filter_failure_reasons::Unknown);
}
messages_.erase(msg_it);
--message_count_;
}
/**
* \brief Callback that happens when we receive a message on the message topic
*/
void incomingMessage(const ros::MessageEvent<M const>& evt)
{
add(evt);
}
void checkFailures()
{
if (next_failure_warning_.isZero())
{
next_failure_warning_ = ros::WallTime::now() + ros::WallDuration(15);
}
if (ros::WallTime::now() >= next_failure_warning_)
{
if (incoming_message_count_ - message_count_ == 0)
{
return;
}
double dropped_pct = (double)dropped_message_count_ / (double)(incoming_message_count_ - message_count_);
if (dropped_pct > 0.95)
{
TF2_ROS_MESSAGEFILTER_WARN("Dropped %.2f%% of messages so far. Please turn the [%s.message_notifier] rosconsole logger to DEBUG for more information.", dropped_pct*100, ROSCONSOLE_DEFAULT_NAME);
next_failure_warning_ = ros::WallTime::now() + ros::WallDuration(60);
if ((double)failed_out_the_back_count_ / (double)dropped_message_count_ > 0.5)
{
TF2_ROS_MESSAGEFILTER_WARN(" The majority of dropped messages were due to messages growing older than the TF cache time. The last message's timestamp was: %f, and the last frame_id was: %s", last_out_the_back_stamp_.toSec(), last_out_the_back_frame_.c_str());
}
}
}
}
struct CBQueueCallback : public ros::CallbackInterface
{
CBQueueCallback(MessageFilter* filter, const MEvent& event, bool success, FilterFailureReason reason)
: event_(event)
, filter_(filter)
, reason_(reason)
, success_(success)
{}
virtual CallResult call()
{
if (success_)
{
filter_->signalMessage(event_);
}
else
{
filter_->signalFailure(event_, reason_);
}
return Success;
}
private:
MEvent event_;
MessageFilter* filter_;
FilterFailureReason reason_;
bool success_;
};
void messageDropped(const MEvent& evt, FilterFailureReason reason)
{
if (callback_queue_)
{
ros::CallbackInterfacePtr cb(new CBQueueCallback(this, evt, false, reason));
callback_queue_->addCallback(cb, (uint64_t)this);
}
else
{
signalFailure(evt, reason);
}
}
void messageReady(const MEvent& evt)
{
if (callback_queue_)
{
ros::CallbackInterfacePtr cb(new CBQueueCallback(this, evt, true, filter_failure_reasons::Unknown));
callback_queue_->addCallback(cb, (uint64_t)this);
}
else
{
this->signalMessage(evt);
}
}
void disconnectFailure(const message_filters::Connection& c)
{
boost::mutex::scoped_lock lock(failure_signal_mutex_);
c.getBoostConnection().disconnect();
}
void signalFailure(const MEvent& evt, FilterFailureReason reason)
{
boost::mutex::scoped_lock lock(failure_signal_mutex_);
failure_signal_(evt.getMessage(), reason);
}
static
std::string stripSlash(const std::string& in)
{
if ( !in.empty() && (in[0] == '/'))
{
std::string out = in;
out.erase(0, 1);
return out;
}
return in;
}
tf2::BufferCore& bc_; ///< The Transformer used to determine if transformation data is available
V_string target_frames_; ///< The frames we need to be able to transform to before a message is ready
std::string target_frames_string_;
boost::mutex target_frames_mutex_; ///< A mutex to protect access to the target_frames_ list and target_frames_string.
uint32_t queue_size_; ///< The maximum number of messages we queue up
tf2::TransformableCallbackHandle callback_handle_;
typedef std::vector<tf2::TransformableRequestHandle> V_TransformableRequestHandle;
struct MessageInfo
{
MessageInfo()
: success_count(0)
{}
MEvent event;
V_TransformableRequestHandle handles;
uint32_t success_count;
};
typedef std::list<MessageInfo> L_MessageInfo;
L_MessageInfo messages_;
uint32_t message_count_; ///< The number of messages in the list. Used because \<container\>.size() may have linear cost
boost::shared_mutex messages_mutex_; ///< The mutex used for locking message list operations
uint32_t expected_success_count_;
bool warned_about_empty_frame_id_;
uint64_t successful_transform_count_;
uint64_t failed_out_the_back_count_;
uint64_t transform_message_count_;
uint64_t incoming_message_count_;
uint64_t dropped_message_count_;
ros::Time last_out_the_back_stamp_;
std::string last_out_the_back_frame_;
ros::WallTime next_failure_warning_;
ros::Duration time_tolerance_; ///< Provide additional tolerance on time for messages which are stamped but can have associated duration
message_filters::Connection message_connection_;
FailureSignal failure_signal_;
boost::mutex failure_signal_mutex_;
ros::CallbackQueueInterface* callback_queue_;
};
} // namespace tf2
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include/tf2_ros/buffer.h | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Wim Meeussen */
#ifndef TF2_ROS_BUFFER_H
#define TF2_ROS_BUFFER_H
#include <tf2_ros/buffer_interface.h>
#include <tf2/buffer_core.h>
#include <tf2_msgs/FrameGraph.h>
#include <ros/ros.h>
#include <tf2/convert.h>
namespace tf2_ros
{
// extend the BufferInterface class and BufferCore class
class Buffer: public BufferInterface, public tf2::BufferCore
{
public:
using tf2::BufferCore::lookupTransform;
using tf2::BufferCore::canTransform;
/**
* @brief Constructor for a Buffer object
* @param cache_time How long to keep a history of transforms
* @param debug Whether to advertise the view_frames service that exposes debugging information from the buffer
* @return
*/
Buffer(ros::Duration cache_time = ros::Duration(BufferCore::DEFAULT_CACHE_TIME), bool debug = false);
/** \brief Get the transform between two frames by frame ID.
* \param target_frame The frame to which data should be transformed
* \param source_frame The frame where the data originated
* \param time The time at which the value of the transform is desired. (0 will get the latest)
* \param timeout How long to block before failing
* \return The transform between the frames
*
* Possible exceptions tf2::LookupException, tf2::ConnectivityException,
* tf2::ExtrapolationException, tf2::InvalidArgumentException
*/
virtual geometry_msgs::TransformStamped
lookupTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout) const;
/** \brief Get the transform between two frames by frame ID assuming fixed frame.
* \param target_frame The frame to which data should be transformed
* \param target_time The time to which the data should be transformed. (0 will get the latest)
* \param source_frame The frame where the data originated
* \param source_time The time at which the source_frame should be evaluated. (0 will get the latest)
* \param fixed_frame The frame in which to assume the transform is constant in time.
* \param timeout How long to block before failing
* \return The transform between the frames
*
* Possible exceptions tf2::LookupException, tf2::ConnectivityException,
* tf2::ExtrapolationException, tf2::InvalidArgumentException
*/
virtual geometry_msgs::TransformStamped
lookupTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout) const;
/** \brief Test if a transform is possible
* \param target_frame The frame into which to transform
* \param source_frame The frame from which to transform
* \param target_time The time at which to transform
* \param timeout How long to block before failing
* \param errstr A pointer to a string which will be filled with why the transform failed, if not NULL
* \return True if the transform is possible, false otherwise
*/
virtual bool
canTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& target_time, const ros::Duration timeout, std::string* errstr = NULL) const;
/** \brief Test if a transform is possible
* \param target_frame The frame into which to transform
* \param target_time The time into which to transform
* \param source_frame The frame from which to transform
* \param source_time The time from which to transform
* \param fixed_frame The frame in which to treat the transform as constant in time
* \param timeout How long to block before failing
* \param errstr A pointer to a string which will be filled with why the transform failed, if not NULL
* \return True if the transform is possible, false otherwise
*/
virtual bool
canTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout, std::string* errstr = NULL) const;
private:
bool getFrames(tf2_msgs::FrameGraph::Request& req, tf2_msgs::FrameGraph::Response& res) ;
// conditionally error if dedicated_thread unset.
bool checkAndErrorDedicatedThreadPresent(std::string* errstr) const;
ros::ServiceServer frames_server_;
}; // class
static const std::string threading_error = "Do not call canTransform or lookupTransform with a timeout unless you are using another thread for populating data. Without a dedicated thread it will always timeout. If you have a seperate thread servicing tf messages, call setUsingDedicatedThread(true) on your Buffer instance.";
} // namespace
#endif // TF2_ROS_BUFFER_H
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include/tf2_ros/buffer_client.h | /*********************************************************************
*
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*
* Author: Eitan Marder-Eppstein
*********************************************************************/
#ifndef TF2_ROS_BUFFER_CLIENT_H_
#define TF2_ROS_BUFFER_CLIENT_H_
#include <tf2_ros/buffer_interface.h>
#include <actionlib/client/simple_action_client.h>
#include <tf2_msgs/LookupTransformAction.h>
namespace tf2_ros
{
class BufferClient : public BufferInterface
{
public:
typedef actionlib::SimpleActionClient<tf2_msgs::LookupTransformAction> LookupActionClient;
/** \brief BufferClient constructor
* \param ns The namespace in which to look for a BufferServer
* \param check_frequency The frequency in Hz to check whether the BufferServer has completed a request
* \param timeout_padding The amount of time to allow passed the desired timeout on the client side for communication lag
*/
BufferClient(std::string ns, double check_frequency = 10.0, ros::Duration timeout_padding = ros::Duration(2.0));
/** \brief Get the transform between two frames by frame ID.
* \param target_frame The frame to which data should be transformed
* \param source_frame The frame where the data originated
* \param time The time at which the value of the transform is desired. (0 will get the latest)
* \param timeout How long to block before failing
* \return The transform between the frames
*
* Possible exceptions tf2::LookupException, tf2::ConnectivityException,
* tf2::ExtrapolationException, tf2::InvalidArgumentException
*/
virtual geometry_msgs::TransformStamped
lookupTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout = ros::Duration(0.0)) const;
/** \brief Get the transform between two frames by frame ID assuming fixed frame.
* \param target_frame The frame to which data should be transformed
* \param target_time The time to which the data should be transformed. (0 will get the latest)
* \param source_frame The frame where the data originated
* \param source_time The time at which the source_frame should be evaluated. (0 will get the latest)
* \param fixed_frame The frame in which to assume the transform is constant in time.
* \param timeout How long to block before failing
* \return The transform between the frames
*
* Possible exceptions tf2::LookupException, tf2::ConnectivityException,
* tf2::ExtrapolationException, tf2::InvalidArgumentException
*/
virtual geometry_msgs::TransformStamped
lookupTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout = ros::Duration(0.0)) const;
/** \brief Test if a transform is possible
* \param target_frame The frame into which to transform
* \param source_frame The frame from which to transform
* \param time The time at which to transform
* \param timeout How long to block before failing
* \param errstr A pointer to a string which will be filled with why the transform failed, if not NULL
* \return True if the transform is possible, false otherwise
*/
virtual bool
canTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout = ros::Duration(0.0), std::string* errstr = NULL) const;
/** \brief Test if a transform is possible
* \param target_frame The frame into which to transform
* \param target_time The time into which to transform
* \param source_frame The frame from which to transform
* \param source_time The time from which to transform
* \param fixed_frame The frame in which to treat the transform as constant in time
* \param timeout How long to block before failing
* \param errstr A pointer to a string which will be filled with why the transform failed, if not NULL
* \return True if the transform is possible, false otherwise
*/
virtual bool
canTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout = ros::Duration(0.0), std::string* errstr = NULL) const;
bool waitForServer(const ros::Duration& timeout = ros::Duration(0))
{
return client_.waitForServer(timeout);
}
private:
geometry_msgs::TransformStamped processGoal(const tf2_msgs::LookupTransformGoal& goal) const;
geometry_msgs::TransformStamped processResult(const tf2_msgs::LookupTransformResult& result) const;
mutable LookupActionClient client_;
double check_frequency_;
ros::Duration timeout_padding_;
};
};
#endif
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/include/tf2_ros/buffer_interface.h | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Wim Meeussen */
#ifndef TF2_ROS_BUFFER_INTERFACE_H
#define TF2_ROS_BUFFER_INTERFACE_H
#include <tf2/buffer_core.h>
#include <tf2/transform_datatypes.h>
#include <tf2/exceptions.h>
#include <geometry_msgs/TransformStamped.h>
#include <sstream>
#include <tf2/convert.h>
namespace tf2_ros
{
// extend the TFCore class and the TFCpp class
class BufferInterface
{
public:
/** \brief Get the transform between two frames by frame ID.
* \param target_frame The frame to which data should be transformed
* \param source_frame The frame where the data originated
* \param time The time at which the value of the transform is desired. (0 will get the latest)
* \param timeout How long to block before failing
* \return The transform between the frames
*
* Possible exceptions tf2::LookupException, tf2::ConnectivityException,
* tf2::ExtrapolationException, tf2::InvalidArgumentException
*/
virtual geometry_msgs::TransformStamped
lookupTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout) const = 0;
/** \brief Get the transform between two frames by frame ID assuming fixed frame.
* \param target_frame The frame to which data should be transformed
* \param target_time The time to which the data should be transformed. (0 will get the latest)
* \param source_frame The frame where the data originated
* \param source_time The time at which the source_frame should be evaluated. (0 will get the latest)
* \param fixed_frame The frame in which to assume the transform is constant in time.
* \param timeout How long to block before failing
* \return The transform between the frames
*
* Possible exceptions tf2::LookupException, tf2::ConnectivityException,
* tf2::ExtrapolationException, tf2::InvalidArgumentException
*/
virtual geometry_msgs::TransformStamped
lookupTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout) const = 0;
/** \brief Test if a transform is possible
* \param target_frame The frame into which to transform
* \param source_frame The frame from which to transform
* \param time The time at which to transform
* \param timeout How long to block before failing
* \param errstr A pointer to a string which will be filled with why the transform failed, if not NULL
* \return True if the transform is possible, false otherwise
*/
virtual bool
canTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout, std::string* errstr = NULL) const = 0;
/** \brief Test if a transform is possible
* \param target_frame The frame into which to transform
* \param target_time The time into which to transform
* \param source_frame The frame from which to transform
* \param source_time The time from which to transform
* \param fixed_frame The frame in which to treat the transform as constant in time
* \param timeout How long to block before failing
* \param errstr A pointer to a string which will be filled with why the transform failed, if not NULL
* \return True if the transform is possible, false otherwise
*/
virtual bool
canTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout, std::string* errstr = NULL) const = 0;
// Transform, simple api, with pre-allocation
template <class T>
T& transform(const T& in, T& out,
const std::string& target_frame, ros::Duration timeout=ros::Duration(0.0)) const
{
// do the transform
tf2::doTransform(in, out, lookupTransform(target_frame, tf2::getFrameId(in), tf2::getTimestamp(in), timeout));
return out;
}
// transform, simple api, no pre-allocation
template <class T>
T transform(const T& in,
const std::string& target_frame, ros::Duration timeout=ros::Duration(0.0)) const
{
T out;
return transform(in, out, target_frame, timeout);
}
//transform, simple api, different types, pre-allocation
template <class A, class B>
B& transform(const A& in, B& out,
const std::string& target_frame, ros::Duration timeout=ros::Duration(0.0)) const
{
A copy = transform(in, target_frame, timeout);
tf2::convert(copy, out);
return out;
}
// Transform, advanced api, with pre-allocation
template <class T>
T& transform(const T& in, T& out,
const std::string& target_frame, const ros::Time& target_time,
const std::string& fixed_frame, ros::Duration timeout=ros::Duration(0.0)) const
{
// do the transform
tf2::doTransform(in, out, lookupTransform(target_frame, target_time,
tf2::getFrameId(in), tf2::getTimestamp(in),
fixed_frame, timeout));
return out;
}
// transform, advanced api, no pre-allocation
template <class T>
T transform(const T& in,
const std::string& target_frame, const ros::Time& target_time,
const std::string& fixed_frame, ros::Duration timeout=ros::Duration(0.0)) const
{
T out;
return transform(in, out, target_frame, target_time, fixed_frame, timeout);
}
// Transform, advanced api, different types, with pre-allocation
template <class A, class B>
B& transform(const A& in, B& out,
const std::string& target_frame, const ros::Time& target_time,
const std::string& fixed_frame, ros::Duration timeout=ros::Duration(0.0)) const
{
// do the transform
A copy = transform(in, target_frame, target_time, fixed_frame, timeout);
tf2::convert(copy, out);
return out;
}
}; // class
} // namespace
#endif // TF2_ROS_BUFFER_INTERFACE_H
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/doc/index.rst | tf2_ros
=======
This is the Python API reference of the tf2_ros package.
.. toctree::
:maxdepth: 2
tf2_ros
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/doc/conf.py | # -*- coding: utf-8 -*-
#
# tf documentation build configuration file, created by
# sphinx-quickstart on Mon Jun 1 14:21:53 2009.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import roslib
roslib.load_manifest('tf')
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.append(os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.pngmath']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'tf'
copyright = u'2009, Willow Garage, Inc.'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'tfdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'tf.tex', u'stereo\\_utils Documentation',
u'Tully Foote and Eitan Marder-Eppstein', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'http://docs.python.org/': None,
'http://docs.opencv.org/3.0-last-rst/': None,
'http://docs.scipy.org/doc/numpy' : None
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/doc/mainpage.dox | /**
\mainpage
\htmlinclude manifest.html
\b tf2_cpp is ...
<!--
Provide an overview of your package.
-->
\section codeapi Code API
<!--
Provide links to specific auto-generated API documentation within your
package that is of particular interest to a reader. Doxygen will
document pretty much every part of your code, so do your best here to
point the reader to the actual API.
If your codebase is fairly large or has different sets of APIs, you
should use the doxygen 'group' tag to keep these APIs together. For
example, the roscpp documentation has 'libros' group.
-->
*/
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/doc/tf2_ros.rst | tf2
----------------
.. currentmodule:: tf2
.. exception:: TransformException
base class for tf exceptions. Because :exc:`tf2.TransformException` is the
base class for other exceptions, you can catch all tf exceptions
by writing::
try:
# do some tf2 work
except tf2.TransformException:
print "some tf2 exception happened"
.. exception:: ConnectivityException
subclass of :exc:`TransformException`.
Raised when that the fixed_frame tree is not connected between the frames requested.
.. exception:: LookupException
subclass of :exc:`TransformException`.
Raised when a tf method has attempted to access a frame, but
the frame is not in the graph.
The most common reason for this is that the frame is not
being published, or a parent frame was not set correctly
causing the tree to be broken.
.. exception:: ExtrapolationException
subclass of :exc:`TransformException`
Raised when a tf method would have required extrapolation beyond current limits.
.. exception:: InvalidArgumentException
subclass of :exc:`TransformException`.
Raised when the arguments to the method are called improperly formed. An example of why this might be raised is if an argument is nan.
BufferCore
-----------
.. class:: tf2.BufferCore(cache_time = rospy.Duration(10))
:param cache_time: how long the buffer should retain transformation information in the past.
The BufferCore object is the core of tf2. It maintains a
time-varying graph of transforms, and permits asynchronous graph
modification and queries:
.. doctest::
>>> import rospy
>>> import tf2
>>> import geometry_msgs.msg
>>> t = tf2.BufferCore(rospy.Duration(10.0))
>>> t.getFrameStrings()
[]
>>> m = geometry_msgs.msg.TransformStamped()
>>> m.header.frame_id = 'THISFRAME'
>>> m.child_frame_id = 'CHILD'
>>> m.transform.translation.x = 2.71828183
>>> m.transform.rotation.w = 1.0
>>> t.setTransform(m)
>>> t.getFrameStrings()
['/CHILD', '/THISFRAME']
>>> t.lookupTransform('THISFRAME', 'CHILD', rospy.Time(0))
((2.71828183, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0))
>>> t.lookupTransform('CHILD', 'THISFRAME', rospy.Time(0))
((-2.71828183, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0))
The transformer refers to frames using strings, and represents
transformations using translation (x, y, z) and quaternions (x, y,
z, w) expressed as Python a :class:`tuple`.
Transformer also does not mandate any particular
linear algebra library.
Transformer does not handle ROS messages directly; the only ROS type it
uses is `rospy.Time() <http://www.ros.org/doc/api/rospy/html/rospy.rostime-module.html>`_.
To use tf with ROS messages, see :class:`TransformerROS` and :class:`TransformListener`.
.. method:: allFramesAsYAML() -> string
Returns a string representing all frames, intended for debugging tools.
.. method:: allFramesAsString() -> string
Returns a human-readable string representing all frames
.. method:: setTransform(transform, authority = "")
:param transform: transform object, see below
:param authority: string giving authority for this transformation.
Adds a new transform to the Transformer graph. transform is an object with the following structure::
header
stamp time stamp, rospy.Time
frame_id string, parent frame
child_frame_id string, child frame
transform
translation
x float
y float
z float
rotation
x float
y float
z float
w float
These members exactly match those of a ROS TransformStamped message.
.. method:: canTransform(target_frame, source_frame, time) -> bool
:param target_frame: transformation target frame in tf, string
:param source_frame: transformation source frame in tf, string
:param time: time of the transformation, use ``rospy.Time()`` to indicate present time.
Returns True if the Transformer can determine the transform from source_frame to target_frame at time.
.. method:: canTransformFull(target_frame, target_time, source_frame, source_time, fixed_frame) -> bool
Extended version of :meth:`canTransform`.
:param target_time: The time at which to transform into the target_frame.
:param source_time: The time at which to transform from the source frame.
:param fixed_frame: The frame in which to jump from source_time to target_time.
.. method:: clear() -> None
Clear all transformations from the buffer.
.. method:: lookupTransform(target_frame, source_frame, time) -> geometry_msgs.msg.TransformStamped
:param target_frame: transformation target frame in tf, string
:param source_frame: transformation source frame in tf, string
:param time: time of the transformation, use ``rospy.Time()`` to indicate most recent common time.
:returns: position as a translation (x, y, z) and orientation as a quaternion (x, y, z, w)
:raises: :exc:`tf2.ConnectivityException`, :exc:`tf2.LookupException`, or :exc:`tf2.ExtrapolationException`, or :exc:`tf2.InvalidArgumentException`
Returns the transform from source_frame to target_frame at time. Raises one of the exceptions if the transformation is not possible.
Note that a time of zero means latest common time, so::
t.lookupTransform("a", "b", rospy.Time())
will return the transform from "a" to "b" at the latest time available in all transforms between "a" and "b".
.. method:: lookupTransformFull(target_frame, target_time, source_frame, source_time, fixed_frame) -> geometry_msgs.msg.TransformStamped
:param target_frame: transformation target frame in tf, string
:param target_time: time of transformation in target_frame, a :class:`rospy.Time`
:param source_frame: transformation source frame in tf, string
:param source_time: time of transformation in target_frame, a :class:`rospy.Time`
:param fixed_frame: reference frame common to both target_frame and source_frame.
:raises: :exc:`tf2.ConnectivityException`, :exc:`tf2.LookupException`, or :exc:`tf2.ExtrapolationException`, or :exc:`tf2.InvalidArgumentException`
Extended version of :meth:`lookupTransform`.
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/buffer_client.cpp | /*********************************************************************
*
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*
* Author: Eitan Marder-Eppstein
*********************************************************************/
#include <tf2_ros/buffer_client.h>
namespace tf2_ros
{
BufferClient::BufferClient(std::string ns, double check_frequency, ros::Duration timeout_padding):
client_(ns),
check_frequency_(check_frequency),
timeout_padding_(timeout_padding)
{
}
geometry_msgs::TransformStamped BufferClient::lookupTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout) const
{
//populate the goal message
tf2_msgs::LookupTransformGoal goal;
goal.target_frame = target_frame;
goal.source_frame = source_frame;
goal.source_time = time;
goal.timeout = timeout;
goal.advanced = false;
return processGoal(goal);
}
geometry_msgs::TransformStamped BufferClient::lookupTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout) const
{
//populate the goal message
tf2_msgs::LookupTransformGoal goal;
goal.target_frame = target_frame;
goal.source_frame = source_frame;
goal.source_time = source_time;
goal.timeout = timeout;
goal.target_time = target_time;
goal.fixed_frame = fixed_frame;
goal.advanced = true;
return processGoal(goal);
}
geometry_msgs::TransformStamped BufferClient::processGoal(const tf2_msgs::LookupTransformGoal& goal) const
{
client_.sendGoal(goal);
ros::Rate r(check_frequency_);
bool timed_out = false;
ros::Time start_time = ros::Time::now();
while(ros::ok() && !client_.getState().isDone() && !timed_out)
{
timed_out = ros::Time::now() > start_time + goal.timeout + timeout_padding_;
r.sleep();
}
//this shouldn't happen, but could in rare cases where the server hangs
if(timed_out)
{
//make sure to cancel the goal the server is pursuing
client_.cancelGoal();
throw tf2::TimeoutException("The LookupTransform goal sent to the BufferServer did not come back in the specified time. Something is likely wrong with the server.");
}
if(client_.getState() != actionlib::SimpleClientGoalState::SUCCEEDED)
throw tf2::TimeoutException("The LookupTransform goal sent to the BufferServer did not come back with SUCCEEDED status. Something is likely wrong with the server.");
//process the result for errors and return it
return processResult(*client_.getResult());
}
geometry_msgs::TransformStamped BufferClient::processResult(const tf2_msgs::LookupTransformResult& result) const
{
//if there's no error, then we'll just return the transform
if(result.error.error != result.error.NO_ERROR){
//otherwise, we'll have to throw the appropriate exception
if(result.error.error == result.error.LOOKUP_ERROR)
throw tf2::LookupException(result.error.error_string);
if(result.error.error == result.error.CONNECTIVITY_ERROR)
throw tf2::ConnectivityException(result.error.error_string);
if(result.error.error == result.error.EXTRAPOLATION_ERROR)
throw tf2::ExtrapolationException(result.error.error_string);
if(result.error.error == result.error.INVALID_ARGUMENT_ERROR)
throw tf2::InvalidArgumentException(result.error.error_string);
if(result.error.error == result.error.TIMEOUT_ERROR)
throw tf2::TimeoutException(result.error.error_string);
throw tf2::TransformException(result.error.error_string);
}
return result.transform;
}
bool BufferClient::canTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout, std::string* errstr) const
{
try
{
lookupTransform(target_frame, source_frame, time, timeout);
return true;
}
catch(tf2::TransformException& ex)
{
if(errstr)
*errstr = ex.what();
return false;
}
}
bool BufferClient::canTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout, std::string* errstr) const
{
try
{
lookupTransform(target_frame, target_time, source_frame, source_time, fixed_frame, timeout);
return true;
}
catch(tf2::TransformException& ex)
{
if(errstr)
*errstr = ex.what();
return false;
}
}
};
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/transform_listener.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Tully Foote */
#include "tf2_ros/transform_listener.h"
using namespace tf2_ros;
TransformListener::TransformListener(tf2::BufferCore& buffer, bool spin_thread):
dedicated_listener_thread_(NULL), buffer_(buffer), using_dedicated_thread_(false)
{
if (spin_thread)
initWithThread();
else
init();
}
TransformListener::TransformListener(tf2::BufferCore& buffer, const ros::NodeHandle& nh, bool spin_thread)
: dedicated_listener_thread_(NULL)
, node_(nh)
, buffer_(buffer)
, using_dedicated_thread_(false)
{
if (spin_thread)
initWithThread();
else
init();
}
TransformListener::~TransformListener()
{
using_dedicated_thread_ = false;
if (dedicated_listener_thread_)
{
dedicated_listener_thread_->join();
delete dedicated_listener_thread_;
}
}
void TransformListener::init()
{
message_subscriber_tf_ = node_.subscribe<tf2_msgs::TFMessage>("/tf", 100, boost::bind(&TransformListener::subscription_callback, this, _1)); ///\todo magic number
message_subscriber_tf_static_ = node_.subscribe<tf2_msgs::TFMessage>("/tf_static", 100, boost::bind(&TransformListener::static_subscription_callback, this, _1)); ///\todo magic number
}
void TransformListener::initWithThread()
{
using_dedicated_thread_ = true;
ros::SubscribeOptions ops_tf = ros::SubscribeOptions::create<tf2_msgs::TFMessage>("/tf", 100, boost::bind(&TransformListener::subscription_callback, this, _1), ros::VoidPtr(), &tf_message_callback_queue_); ///\todo magic number
message_subscriber_tf_ = node_.subscribe(ops_tf);
ros::SubscribeOptions ops_tf_static = ros::SubscribeOptions::create<tf2_msgs::TFMessage>("/tf_static", 100, boost::bind(&TransformListener::static_subscription_callback, this, _1), ros::VoidPtr(), &tf_message_callback_queue_); ///\todo magic number
message_subscriber_tf_static_ = node_.subscribe(ops_tf_static);
dedicated_listener_thread_ = new boost::thread(boost::bind(&TransformListener::dedicatedListenerThread, this));
//Tell the buffer we have a dedicated thread to enable timeouts
buffer_.setUsingDedicatedThread(true);
}
void TransformListener::subscription_callback(const ros::MessageEvent<tf2_msgs::TFMessage const>& msg_evt)
{
subscription_callback_impl(msg_evt, false);
}
void TransformListener::static_subscription_callback(const ros::MessageEvent<tf2_msgs::TFMessage const>& msg_evt)
{
subscription_callback_impl(msg_evt, true);
}
void TransformListener::subscription_callback_impl(const ros::MessageEvent<tf2_msgs::TFMessage const>& msg_evt, bool is_static)
{
ros::Time now = ros::Time::now();
if(now < last_update_){
ROS_WARN("Detected jump back in time. Clearing TF buffer.");
buffer_.clear();
}
last_update_ = now;
const tf2_msgs::TFMessage& msg_in = *(msg_evt.getConstMessage());
std::string authority = msg_evt.getPublisherName(); // lookup the authority
for (unsigned int i = 0; i < msg_in.transforms.size(); i++)
{
try
{
buffer_.setTransform(msg_in.transforms[i], authority, is_static);
}
catch (tf2::TransformException& ex)
{
///\todo Use error reporting
std::string temp = ex.what();
ROS_ERROR("Failure to set recieved transform from %s to %s with error: %s\n", msg_in.transforms[i].child_frame_id.c_str(), msg_in.transforms[i].header.frame_id.c_str(), temp.c_str());
}
}
};
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/static_transform_broadcaster.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Tully Foote */
#include "ros/ros.h"
#include "tf2_msgs/TFMessage.h"
#include "tf2_ros/static_transform_broadcaster.h"
namespace tf2_ros {
StaticTransformBroadcaster::StaticTransformBroadcaster()
{
publisher_ = node_.advertise<tf2_msgs::TFMessage>("/tf_static", 100, true);
};
void StaticTransformBroadcaster::sendTransform(const geometry_msgs::TransformStamped & msgtf)
{
std::vector<geometry_msgs::TransformStamped> v1;
v1.push_back(msgtf);
sendTransform(v1);
}
void StaticTransformBroadcaster::sendTransform(const std::vector<geometry_msgs::TransformStamped> & msgtf)
{
for (std::vector<geometry_msgs::TransformStamped>::const_iterator it_in = msgtf.begin(); it_in != msgtf.end(); ++it_in)
{
bool match_found = false;
for (std::vector<geometry_msgs::TransformStamped>::iterator it_msg = net_message_.transforms.begin(); it_msg != net_message_.transforms.end(); ++it_msg)
{
if (it_in->child_frame_id == it_msg->child_frame_id)
{
*it_msg = *it_in;
match_found = true;
break;
}
}
if (! match_found)
net_message_.transforms.push_back(*it_in);
}
publisher_.publish(net_message_);
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/buffer.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Wim Meeussen */
#include "tf2_ros/buffer.h"
#include <ros/assert.h>
#include <sstream>
namespace tf2_ros
{
Buffer::Buffer(ros::Duration cache_time, bool debug) :
BufferCore(cache_time)
{
if(debug && !ros::service::exists("~tf2_frames", false))
{
ros::NodeHandle n("~");
frames_server_ = n.advertiseService("tf2_frames", &Buffer::getFrames, this);
}
}
geometry_msgs::TransformStamped
Buffer::lookupTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout) const
{
canTransform(target_frame, source_frame, time, timeout);
return lookupTransform(target_frame, source_frame, time);
}
geometry_msgs::TransformStamped
Buffer::lookupTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout) const
{
canTransform(target_frame, target_time, source_frame, source_time, fixed_frame, timeout);
return lookupTransform(target_frame, target_time, source_frame, source_time, fixed_frame);
}
/** This is a workaround for the case that we're running inside of
rospy and ros::Time is not initialized inside the c++ instance.
This makes the system fall back to Wall time if not initialized.
*/
ros::Time now_fallback_to_wall()
{
try
{
return ros::Time::now();
}
catch (ros::TimeNotInitializedException ex)
{
ros::WallTime wt = ros::WallTime::now();
return ros::Time(wt.sec, wt.nsec);
}
}
/** This is a workaround for the case that we're running inside of
rospy and ros::Time is not initialized inside the c++ instance.
This makes the system fall back to Wall time if not initialized.
https://github.com/ros/geometry/issues/30
*/
void sleep_fallback_to_wall(const ros::Duration& d)
{
try
{
d.sleep();
}
catch (ros::TimeNotInitializedException ex)
{
ros::WallDuration wd = ros::WallDuration(d.sec, d.nsec);
wd.sleep();
}
}
void conditionally_append_timeout_info(std::string * errstr, const ros::Time& start_time,
const ros::Duration& timeout)
{
if (errstr)
{
std::stringstream ss;
ss << ". canTransform returned after "<< (now_fallback_to_wall() - start_time).toSec() \
<<" timeout was " << timeout.toSec() << ".";
(*errstr) += ss.str();
}
}
bool
Buffer::canTransform(const std::string& target_frame, const std::string& source_frame,
const ros::Time& time, const ros::Duration timeout, std::string* errstr) const
{
if (!checkAndErrorDedicatedThreadPresent(errstr))
return false;
// poll for transform if timeout is set
ros::Time start_time = now_fallback_to_wall();
while (now_fallback_to_wall() < start_time + timeout &&
!canTransform(target_frame, source_frame, time) &&
(now_fallback_to_wall()+ros::Duration(3.0) >= start_time) && //don't wait when we detect a bag loop
(ros::ok() || !ros::isInitialized())) // Make sure we haven't been stopped (won't work for pytf)
{
sleep_fallback_to_wall(ros::Duration(0.01));
}
bool retval = canTransform(target_frame, source_frame, time, errstr);
conditionally_append_timeout_info(errstr, start_time, timeout);
return retval;
}
bool
Buffer::canTransform(const std::string& target_frame, const ros::Time& target_time,
const std::string& source_frame, const ros::Time& source_time,
const std::string& fixed_frame, const ros::Duration timeout, std::string* errstr) const
{
if (!checkAndErrorDedicatedThreadPresent(errstr))
return false;
// poll for transform if timeout is set
ros::Time start_time = now_fallback_to_wall();
while (now_fallback_to_wall() < start_time + timeout &&
!canTransform(target_frame, target_time, source_frame, source_time, fixed_frame) &&
(now_fallback_to_wall()+ros::Duration(3.0) >= start_time) && //don't wait when we detect a bag loop
(ros::ok() || !ros::isInitialized())) // Make sure we haven't been stopped (won't work for pytf)
{
sleep_fallback_to_wall(ros::Duration(0.01));
}
bool retval = canTransform(target_frame, target_time, source_frame, source_time, fixed_frame, errstr);
conditionally_append_timeout_info(errstr, start_time, timeout);
return retval;
}
bool Buffer::getFrames(tf2_msgs::FrameGraph::Request& req, tf2_msgs::FrameGraph::Response& res)
{
res.frame_yaml = allFramesAsYAML();
return true;
}
bool Buffer::checkAndErrorDedicatedThreadPresent(std::string* error_str) const
{
if (isUsingDedicatedThread())
return true;
if (error_str)
*error_str = tf2_ros::threading_error;
ROS_ERROR("%s", tf2_ros::threading_error.c_str());
return false;
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/transform_broadcaster.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
/** \author Tully Foote */
#include "ros/ros.h"
#include "tf2_msgs/TFMessage.h"
#include "tf2_ros/transform_broadcaster.h"
namespace tf2_ros {
TransformBroadcaster::TransformBroadcaster()
{
publisher_ = node_.advertise<tf2_msgs::TFMessage>("/tf", 100);
};
void TransformBroadcaster::sendTransform(const geometry_msgs::TransformStamped & msgtf)
{
std::vector<geometry_msgs::TransformStamped> v1;
v1.push_back(msgtf);
sendTransform(v1);
}
void TransformBroadcaster::sendTransform(const std::vector<geometry_msgs::TransformStamped> & msgtf)
{
tf2_msgs::TFMessage message;
for (std::vector<geometry_msgs::TransformStamped>::const_iterator it = msgtf.begin(); it != msgtf.end(); ++it)
{
message.transforms.push_back(*it);
}
publisher_.publish(message);
}
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/static_transform_broadcaster_program.cpp | /*
* Copyright (c) 2008, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*/
#include <cstdio>
#include <tf2/LinearMath/Quaternion.h>
#include "tf2_ros/static_transform_broadcaster.h"
int main(int argc, char ** argv)
{
//Initialize ROS
ros::init(argc, argv,"static_transform_publisher", ros::init_options::AnonymousName);
tf2_ros::StaticTransformBroadcaster broadcaster;
if(argc == 10)
{
if (strcmp(argv[8], argv[9]) == 0)
{
ROS_FATAL("target_frame and source frame are the same (%s, %s) this cannot work", argv[8], argv[9]);
return 1;
}
geometry_msgs::TransformStamped msg;
msg.transform.translation.x = atof(argv[1]);
msg.transform.translation.y = atof(argv[2]);
msg.transform.translation.z = atof(argv[3]);
msg.transform.rotation.x = atof(argv[4]);
msg.transform.rotation.y = atof(argv[5]);
msg.transform.rotation.z = atof(argv[6]);
msg.transform.rotation.w = atof(argv[7]);
msg.header.stamp = ros::Time::now();
msg.header.frame_id = argv[8];
msg.child_frame_id = argv[9];
broadcaster.sendTransform(msg);
ROS_INFO("Spinning until killed publishing %s to %s", msg.header.frame_id.c_str(), msg.child_frame_id.c_str());
ros::spin();
return 0;
}
else if (argc == 9)
{
if (strcmp(argv[7], argv[8]) == 0)
{
ROS_FATAL("target_frame and source frame are the same (%s, %s) this cannot work", argv[8], argv[9]);
return 1;
}
geometry_msgs::TransformStamped msg;
msg.transform.translation.x = atof(argv[1]);
msg.transform.translation.y = atof(argv[2]);
msg.transform.translation.z = atof(argv[3]);
tf2::Quaternion quat;
quat.setRPY(atof(argv[6]), atof(argv[5]), atof(argv[4]));
msg.transform.rotation.x = quat.x();
msg.transform.rotation.y = quat.y();
msg.transform.rotation.z = quat.z();
msg.transform.rotation.w = quat.w();
msg.header.stamp = ros::Time::now();
msg.header.frame_id = argv[7];
msg.child_frame_id = argv[8];
broadcaster.sendTransform(msg);
ROS_INFO("Spinning until killed publishing %s to %s", msg.header.frame_id.c_str(), msg.child_frame_id.c_str());
ros::spin();
return 0;
}
else
{
printf("A command line utility for manually sending a transform.\n");
//printf("It will periodicaly republish the given transform. \n");
printf("Usage: static_transform_publisher x y z qx qy qz qw frame_id child_frame_id \n");
printf("OR \n");
printf("Usage: static_transform_publisher x y z yaw pitch roll frame_id child_frame_id \n");
printf("\nThis transform is the transform of the coordinate frame from frame_id into the coordinate frame \n");
printf("of the child_frame_id. \n");
ROS_ERROR("static_transform_publisher exited due to not having the right number of arguments");
return -1;
}
};
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/buffer_server_main.cpp | /*********************************************************************
*
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*
* Author: Wim Meeussen
*********************************************************************/
#include <tf2_ros/buffer_server.h>
#include <tf2_ros/transform_listener.h>
#include <ros/ros.h>
class MyClass
{
public:
MyClass() {}
MyClass(double d) {}
};
class BlankClass
{
public:
BlankClass() {}
};
int main(int argc, char** argv)
{
ros::init(argc, argv, "tf_buffer");
ros::NodeHandle nh;
double buffer_size;
nh.param("buffer_size", buffer_size, 120.0);
// WIM: this works fine:
tf2_ros::Buffer buffer_core(ros::Duration(buffer_size+0)); // WTF??
tf2_ros::TransformListener listener(buffer_core);
tf2_ros::BufferServer buffer_server(buffer_core, "tf2_buffer_server", false);
buffer_server.start();
// But you should probably read this instead:
// http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=439
ros::spin();
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/buffer_server.cpp | /*********************************************************************
*
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
* 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 Willow Garage, Inc. 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 OWNER 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.
*
* Author: Eitan Marder-Eppstein
*********************************************************************/
#include <tf2_ros/buffer_server.h>
namespace tf2_ros
{
BufferServer::BufferServer(const Buffer& buffer, const std::string& ns, bool auto_start, ros::Duration check_period):
buffer_(buffer),
server_(ros::NodeHandle(),
ns,
boost::bind(&BufferServer::goalCB, this, _1),
boost::bind(&BufferServer::cancelCB, this, _1),
auto_start)
{
ros::NodeHandle n;
check_timer_ = n.createTimer(check_period, boost::bind(&BufferServer::checkTransforms, this, _1));
}
void BufferServer::checkTransforms(const ros::TimerEvent& e)
{
boost::mutex::scoped_lock l(mutex_);
for(std::list<GoalInfo>::iterator it = active_goals_.begin(); it != active_goals_.end();)
{
GoalInfo& info = *it;
//we want to lookup a transform if the time on the goal
//has expired, or a transform is available
if(canTransform(info.handle) || info.end_time < ros::Time::now())
{
tf2_msgs::LookupTransformResult result;
//try to populate the result, catching exceptions if they occur
try
{
result.transform = lookupTransform(info.handle);
}
catch (tf2::ConnectivityException &ex)
{
result.error.error = result.error.CONNECTIVITY_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::LookupException &ex)
{
result.error.error = result.error.LOOKUP_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::ExtrapolationException &ex)
{
result.error.error = result.error.EXTRAPOLATION_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::InvalidArgumentException &ex)
{
result.error.error = result.error.INVALID_ARGUMENT_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::TimeoutException &ex)
{
result.error.error = result.error.TIMEOUT_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::TransformException &ex)
{
result.error.error = result.error.TRANSFORM_ERROR;
result.error.error_string = ex.what();
}
//make sure to pass the result to the client
//even failed transforms are considered a success
//since the request was successfully processed
it = active_goals_.erase(it);
info.handle.setSucceeded(result);
}
else
++it;
}
}
void BufferServer::cancelCB(GoalHandle gh)
{
boost::mutex::scoped_lock l(mutex_);
//we need to find the goal in the list and remove it... also setting it as canceled
//if its not in the list, we won't do anything since it will have already been set
//as completed
for(std::list<GoalInfo>::iterator it = active_goals_.begin(); it != active_goals_.end();)
{
GoalInfo& info = *it;
if(info.handle == gh)
{
it = active_goals_.erase(it);
info.handle.setCanceled();
return;
}
else
++it;
}
}
void BufferServer::goalCB(GoalHandle gh)
{
//we'll accept all goals we get
gh.setAccepted();
//if the transform isn't immediately available, we'll push it onto our list to check
//along with the time that the goal will end
GoalInfo goal_info;
goal_info.handle = gh;
goal_info.end_time = ros::Time::now() + gh.getGoal()->timeout;
//we can do a quick check here to see if the transform is valid
//we'll also do this if the end time has been reached
if(canTransform(gh) || goal_info.end_time <= ros::Time::now())
{
tf2_msgs::LookupTransformResult result;
try
{
result.transform = lookupTransform(gh);
}
catch (tf2::ConnectivityException &ex)
{
result.error.error = result.error.CONNECTIVITY_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::LookupException &ex)
{
result.error.error = result.error.LOOKUP_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::ExtrapolationException &ex)
{
result.error.error = result.error.EXTRAPOLATION_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::InvalidArgumentException &ex)
{
result.error.error = result.error.INVALID_ARGUMENT_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::TimeoutException &ex)
{
result.error.error = result.error.TIMEOUT_ERROR;
result.error.error_string = ex.what();
}
catch (tf2::TransformException &ex)
{
result.error.error = result.error.TRANSFORM_ERROR;
result.error.error_string = ex.what();
}
gh.setSucceeded(result);
return;
}
boost::mutex::scoped_lock l(mutex_);
active_goals_.push_back(goal_info);
}
bool BufferServer::canTransform(GoalHandle gh)
{
const tf2_msgs::LookupTransformGoal::ConstPtr& goal = gh.getGoal();
//check whether we need to used the advanced or simple api
if(!goal->advanced)
return buffer_.canTransform(goal->target_frame, goal->source_frame, goal->source_time);
return buffer_.canTransform(goal->target_frame, goal->target_time,
goal->source_frame, goal->source_time, goal->fixed_frame);
}
geometry_msgs::TransformStamped BufferServer::lookupTransform(GoalHandle gh)
{
const tf2_msgs::LookupTransformGoal::ConstPtr& goal = gh.getGoal();
//check whether we need to used the advanced or simple api
if(!goal->advanced)
return buffer_.lookupTransform(goal->target_frame, goal->source_frame, goal->source_time);
return buffer_.lookupTransform(goal->target_frame, goal->target_time,
goal->source_frame, goal->source_time, goal->fixed_frame);
}
void BufferServer::start()
{
server_.start();
}
};
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/tf2_ros/transform_listener.py | # Copyright (c) 2008, Willow Garage, Inc.
# 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 Willow Garage, Inc. 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 OWNER 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.
# author: Wim Meeussen
import roslib; roslib.load_manifest('tf2_ros')
import rospy
import rospy
import tf2_ros
import threading
from tf2_msgs.msg import TFMessage
class TransformListener():
def __init__(self, buffer):
self.listenerthread = TransformListenerThread(buffer)
self.listenerthread.setDaemon(True)
self.listenerthread.start()
class TransformListenerThread(threading.Thread):
def __init__(self, buffer):
self.buffer = buffer
threading.Thread.__init__(self)
def run(self):
rospy.Subscriber("/tf", TFMessage, self.callback)
rospy.Subscriber("/tf_static", TFMessage, self.static_callback)
rospy.spin()
def callback(self, data):
who = data._connection_header.get('callerid', "default_authority")
for transform in data.transforms:
self.buffer.set_transform(transform, who)
def static_callback(self, data):
who = data._connection_header.get('callerid', "default_authority")
for transform in data.transforms:
self.buffer.set_transform_static(transform, who)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/tf2_ros/transform_broadcaster.py | # Software License Agreement (BSD License)
#
# Copyright (c) 2008, Willow Garage, Inc.
# 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 Willow Garage 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 OWNER 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.
import rospy
from tf2_msgs.msg import TFMessage
from geometry_msgs.msg import TransformStamped
class TransformBroadcaster:
"""
:class:`TransformBroadcaster` is a convenient way to send transformation updates on the ``"/tf"`` message topic.
"""
def __init__(self):
self.pub_tf = rospy.Publisher("/tf", TFMessage, queue_size=100)
def sendTransform(self, transform):
if not isinstance(transform, list):
transform = [transform]
self.pub_tf.publish(TFMessage(transform))
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/tf2_ros/__init__.py | #! /usr/bin/python
#***********************************************************
#* Software License Agreement (BSD License)
#*
#* Copyright (c) 2009, Willow Garage, Inc.
#* 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 Willow Garage, Inc. 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 OWNER 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.
#*
#* Author: Eitan Marder-Eppstein
#***********************************************************
from tf2_py import *
from buffer_interface import *
from buffer import *
from buffer_client import *
from transform_listener import *
from transform_broadcaster import *
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/tf2_ros/buffer_client.py | #! /usr/bin/python
#***********************************************************
#* Software License Agreement (BSD License)
#*
#* Copyright (c) 2009, Willow Garage, Inc.
#* 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 Willow Garage, Inc. 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 OWNER 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.
#*
#* Author: Eitan Marder-Eppstein
#***********************************************************
PKG = 'tf2_ros'
import roslib; roslib.load_manifest(PKG)
import rospy
import actionlib
import tf2_py as tf2
import tf2_ros
from tf2_msgs.msg import LookupTransformAction, LookupTransformGoal
from actionlib_msgs.msg import GoalStatus
class BufferClient(tf2_ros.BufferInterface):
def __init__(self, ns, check_frequency = 10.0, timeout_padding = rospy.Duration.from_sec(2.0)):
tf2_ros.BufferInterface.__init__(self)
self.client = actionlib.SimpleActionClient(ns, LookupTransformAction)
self.check_frequency = check_frequency
self.timeout_padding = timeout_padding
def wait_for_server(self, timeout = rospy.Duration()):
return self.client.wait_for_server(timeout)
# lookup, simple api
def lookup_transform(self, target_frame, source_frame, time, timeout=rospy.Duration(0.0)):
goal = LookupTransformGoal()
goal.target_frame = target_frame;
goal.source_frame = source_frame;
goal.source_time = time;
goal.timeout = timeout;
goal.advanced = False;
return self.__process_goal(goal)
# lookup, advanced api
def lookup_transform_full(self, target_frame, target_time, source_frame, source_time, fixed_frame, timeout=rospy.Duration(0.0)):
goal = LookupTransformGoal()
goal.target_frame = target_frame;
goal.source_frame = source_frame;
goal.source_time = source_time;
goal.timeout = timeout;
goal.target_time = target_time;
goal.fixed_frame = fixed_frame;
goal.advanced = True;
return self.__process_goal(goal)
# can, simple api
def can_transform(self, target_frame, source_frame, time, timeout=rospy.Duration(0.0)):
try:
self.lookup_transform(target_frame, source_frame, time, timeout)
return True
except tf2.TransformException:
return False
# can, advanced api
def can_transform_full(self, target_frame, target_time, source_frame, source_time, fixed_frame, timeout=rospy.Duration(0.0)):
try:
self.lookup_transform_full(target_frame, target_time, source_frame, source_time, fixed_frame, timeout)
return True
except tf2.TransformException:
return False
def __is_done(self, state):
if state == GoalStatus.REJECTED or state == GoalStatus.ABORTED or \
state == GoalStatus.RECALLED or state == GoalStatus.PREEMPTED or \
state == GoalStatus.SUCCEEDED or state == GoalStatus.LOST:
return True
return False
def __process_goal(self, goal):
self.client.send_goal(goal)
r = rospy.Rate(self.check_frequency)
timed_out = False
start_time = rospy.Time.now()
while not rospy.is_shutdown() and not self.__is_done(self.client.get_state()) and not timed_out:
if rospy.Time.now() > start_time + goal.timeout + self.timeout_padding:
timed_out = True
r.sleep()
#This shouldn't happen, but could in rare cases where the server hangs
if timed_out:
self.client.cancel_goal()
raise tf2.TimeoutException("The LookupTransform goal sent to the BufferServer did not come back in the specified time. Something is likely wrong with the server")
if self.client.get_state() != GoalStatus.SUCCEEDED:
raise tf2.TimeoutException("The LookupTransform goal sent to the BufferServer did not come back with SUCCEEDED status. Something is likely wrong with the server.")
return self.__process_result(self.client.get_result())
def __process_result(self, result):
if result == None or result.error == None:
raise tf2.TransformException("The BufferServer returned None for result or result.error! Something is likely wrong with the server.")
if result.error.error != result.error.NO_ERROR:
if result.error.error == result.error.LOOKUP_ERROR:
raise tf2.LookupException(result.error.error_string)
if result.error.error == result.error.CONNECTIVITY_ERROR:
raise tf2.ConnectivityException(result.error.error_string)
if result.error.error == result.error.EXTRAPOLATION_ERROR:
raise tf2.ExtrapolationException(result.error.error_string)
if result.error.error == result.error.INVALID_ARGUMENT_ERROR:
raise tf2.InvalidArgumentException(result.error.error_string)
if result.error.error == result.error.TIMEOUT_ERROR:
raise tf2.TimeoutException(result.error.error_string)
raise tf2.TransformException(result.error.error_string)
return result.transform
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/tf2_ros/buffer.py | # Copyright (c) 2008, Willow Garage, Inc.
# 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 Willow Garage, Inc. 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 OWNER 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.
# author: Wim Meeussen
import roslib; roslib.load_manifest('tf2_ros')
import rospy
import tf2_py as tf2
import tf2_ros
from tf2_msgs.srv import FrameGraph, FrameGraphResponse
import rosgraph.masterapi
class Buffer(tf2.BufferCore, tf2_ros.BufferInterface):
def __init__(self, cache_time = None, debug = True):
if cache_time != None:
tf2.BufferCore.__init__(self, cache_time)
else:
tf2.BufferCore.__init__(self)
tf2_ros.BufferInterface.__init__(self)
if debug:
#Check to see if the service has already been advertised in this node
try:
m = rosgraph.masterapi.Master(rospy.get_name())
m.lookupService('~tf2_frames')
except (rosgraph.masterapi.Error, rosgraph.masterapi.Failure):
self.frame_server = rospy.Service('~tf2_frames', FrameGraph, self.__get_frames)
def __get_frames(self, req):
return FrameGraphResponse(self.all_frames_as_yaml())
# lookup, simple api
def lookup_transform(self, target_frame, source_frame, time, timeout=rospy.Duration(0.0)):
self.can_transform(target_frame, source_frame, time, timeout)
return self.lookup_transform_core(target_frame, source_frame, time)
# lookup, advanced api
def lookup_transform_full(self, target_frame, target_time, source_frame, source_time, fixed_frame, timeout=rospy.Duration(0.0)):
self.can_transform_full(target_frame, target_time, source_frame, source_time, fixed_frame, timeout)
return self.lookup_transform_full_core(target_frame, target_time, source_frame, source_time, fixed_frame)
# can, simple api
def can_transform(self, target_frame, source_frame, time, timeout=rospy.Duration(0.0), return_debug_tuple=False):
if timeout != rospy.Duration(0.0):
start_time = rospy.Time.now()
r= rospy.Rate(20)
while (rospy.Time.now() < start_time + timeout and
not self.can_transform_core(target_frame, source_frame, time)[0] and
(rospy.Time.now()+rospy.Duration(3.0)) >= start_time): # big jumps in time are likely bag loops, so break for them
r.sleep()
core_result = self.can_transform_core(target_frame, source_frame, time)
if return_debug_tuple:
return core_result
return core_result[0]
# can, advanced api
def can_transform_full(self, target_frame, target_time, source_frame, source_time, fixed_frame, timeout=rospy.Duration(0.0),
return_debug_tuple=False):
if timeout != rospy.Duration(0.0):
start_time = rospy.Time.now()
r= rospy.Rate(20)
while (rospy.Time.now() < start_time + timeout and
not self.can_transform_full_core(target_frame, target_time, source_frame, source_time, fixed_frame)[0] and
(rospy.Time.now()+rospy.Duration(3.0)) >= start_time): # big jumps in time are likely bag loops, so break for them
r.sleep()
core_result = self.can_transform_full_core(target_frame, target_time, source_frame, source_time, fixed_frame)
if return_debug_tuple:
return core_result
return core_result[0]
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_ros/src/tf2_ros/buffer_interface.py | # Copyright (c) 2008, Willow Garage, Inc.
# 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 Willow Garage, Inc. 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 OWNER 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.
# author: Wim Meeussen
import roslib; roslib.load_manifest('tf2_ros')
import rospy
import tf2_py as tf2
import tf2_ros
from copy import deepcopy
from std_msgs.msg import Header
class BufferInterface:
def __init__(self):
self.registration = tf2_ros.TransformRegistration()
# transform, simple api
def transform(self, object_stamped, target_frame, timeout=rospy.Duration(0.0), new_type = None):
do_transform = self.registration.get(type(object_stamped))
res = do_transform(object_stamped, self.lookup_transform(target_frame, object_stamped.header.frame_id,
object_stamped.header.stamp, timeout))
if new_type == None:
return res
return convert(res, new_type)
# transform, advanced api
def transform_full(self, object_stamped, target_frame, target_time, fixed_frame, timeout=rospy.Duration(0.0), new_type = None):
do_transform = self.registration.get(type(object_stamped))
res = do_transform(object_stamped, self.lookup_transform_full(target_frame, target_time,
object_stamped.header.frame_id, object_stamped.header.stamp,
fixed_frame, timeout))
if new_type == None:
return res
return convert(res, new_type)
# lookup, simple api
def lookup_transform(self, target_frame, source_frame, time, timeout=rospy.Duration(0.0)):
raise NotImplementedException()
# lookup, advanced api
def lookup_transform_full(self, target_frame, target_time, source_frame, source_time, fixed_frame, timeout=rospy.Duration(0.0)):
raise NotImplementedException()
# can, simple api
def can_transform(self, target_frame, source_frame, time, timeout=rospy.Duration(0.0)):
raise NotImplementedException()
# can, advanced api
def can_transform_full(self, target_frame, target_time, source_frame, source_time, fixed_frame, timeout=rospy.Duration(0.0)):
raise NotImplementedException()
def Stamped(obj, stamp, frame_id):
obj.header = Header(frame_id=frame_id, stamp=stamp)
return obj
class TypeException(Exception):
def __init__(self, errstr):
self.errstr = errstr
class NotImplementedException(Exception):
def __init__(self):
self.errstr = 'CanTransform or LookupTransform not implemented'
class TransformRegistration():
__type_map = {}
def print_me(self):
print TransformRegistration.__type_map
def add(self, key, callback):
TransformRegistration.__type_map[key] = callback
def get(self, key):
if not key in TransformRegistration.__type_map:
raise TypeException('Type %s if not loaded or supported'% str(key))
else:
return TransformRegistration.__type_map[key]
class ConvertRegistration():
__to_msg_map = {}
__from_msg_map = {}
__convert_map = {}
def add_from_msg(self, key, callback):
ConvertRegistration.__from_msg_map[key] = callback
def add_to_msg(self, key, callback):
ConvertRegistration.__to_msg_map[key] = callback
def add_convert(self, key, callback):
ConvertRegistration.__convert_map[key] = callback
def get_from_msg(self, key):
if not key in ConvertRegistration.__from_msg_map:
raise TypeException('Type %s if not loaded or supported'% str(key))
else:
return ConvertRegistration.__from_msg_map[key]
def get_to_msg(self, key):
if not key in ConvertRegistration.__to_msg_map:
raise TypeException('Type %s if not loaded or supported'%str(key))
else:
return ConvertRegistration.__to_msg_map[key]
def get_convert(self, key):
if not key in ConvertRegistration.__convert_map:
raise TypeException("Type %s if not loaded or supported" % str(key))
else:
return ConvertRegistration.__convert_map[key]
def convert(a, b_type):
c = ConvertRegistration()
#check if an efficient conversion function between the types exists
try:
f = c.get_convert((type(a), b_type))
print "efficient copy"
return f(a)
except TypeException:
if type(a) == b_type:
print "deep copy"
return deepcopy(a)
f_to = c.get_to_msg(type(a))
f_from = c.get_from_msg(b_type)
print "message copy"
return f_from(f_to(a))
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_py/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
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
)
###########
## 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.
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)
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}
)
#############
## Testing ##
#############
## 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()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_py/package.xml | <?xml version="1.0"?>
<package>
<name>tf2_py</name>
<version>0.5.13</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>
<!-- 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> -->
<!-- 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>
<!-- 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 -->
</export>
</package> | 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_py/setup.py | #!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=['tf2_py'],
package_dir={'': 'src'},
requires=['rospy', 'geometry_msgs', 'tf2_msgs']
)
setup(**d)
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_py/.tar | {!!python/unicode 'url': 'https://github.com/ros-gbp/geometry2-release/archive/release/indigo/tf2_py/0.5.13-0.tar.gz',
!!python/unicode 'version': geometry2-release-release-indigo-tf2_py-0.5.13-0}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2 | apollo_public_repos/apollo-platform/ros/geometry2/tf2_py/CHANGELOG.rst | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package tf2_py
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.5.13 (2016-03-04)
-------------------
0.5.12 (2015-08-05)
-------------------
0.5.11 (2015-04-22)
-------------------
0.5.10 (2015-04-21)
-------------------
0.5.9 (2015-03-25)
------------------
0.5.8 (2015-03-17)
------------------
0.5.7 (2014-12-23)
------------------
0.5.6 (2014-09-18)
------------------
0.5.5 (2014-06-23)
------------------
0.5.4 (2014-05-07)
------------------
0.5.3 (2014-02-21)
------------------
0.5.2 (2014-02-20)
------------------
0.5.1 (2014-02-14)
------------------
0.5.0 (2014-02-14)
------------------
0.4.10 (2013-12-26)
-------------------
* adding support for static transforms in python listener. Fixes `#46 <https://github.com/ros/geometry_experimental/issues/46>`_
* Contributors: Tully Foote
0.4.9 (2013-11-06)
------------------
0.4.8 (2013-11-06)
------------------
0.4.7 (2013-08-28)
------------------
0.4.6 (2013-08-28)
------------------
0.4.5 (2013-07-11)
------------------
0.4.4 (2013-07-09)
------------------
* tf2_py: Fixes warning, implicit conversion of NULL
0.4.3 (2013-07-05)
------------------
0.4.2 (2013-07-05)
------------------
0.4.1 (2013-07-05)
------------------
0.4.0 (2013-06-27)
------------------
* splitting rospy dependency into tf2_py so tf2 is pure c++ library.
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_py | apollo_public_repos/apollo-platform/ros/geometry2/tf2_py/src/tf2_py.cpp | #include <Python.h>
#include <tf2/buffer_core.h>
#include <tf2/exceptions.h>
// Run x (a tf method, catching TF's exceptions and reraising them as Python exceptions)
//
#define WRAP(x) \
do { \
try \
{ \
x; \
} \
catch (const tf2::ConnectivityException &e) \
{ \
PyErr_SetString(tf2_connectivityexception, e.what()); \
return NULL; \
} \
catch (const tf2::LookupException &e) \
{ \
PyErr_SetString(tf2_lookupexception, e.what()); \
return NULL; \
} \
catch (const tf2::ExtrapolationException &e) \
{ \
PyErr_SetString(tf2_extrapolationexception, e.what()); \
return NULL; \
} \
catch (const tf2::InvalidArgumentException &e) \
{ \
PyErr_SetString(tf2_invalidargumentexception, e.what()); \
return NULL; \
} \
catch (const tf2::TimeoutException &e) \
{ \
PyErr_SetString(tf2_timeoutexception, e.what()); \
return NULL; \
} \
catch (const tf2::TransformException &e) \
{ \
PyErr_SetString(tf2_exception, e.what()); \
return NULL; \
} \
} while (0)
static PyObject *pModulerospy = NULL;
static PyObject *pModulegeometrymsgs = NULL;
static PyObject *tf2_exception = NULL;
static PyObject *tf2_connectivityexception = NULL, *tf2_lookupexception = NULL, *tf2_extrapolationexception = NULL,
*tf2_invalidargumentexception = NULL, *tf2_timeoutexception = NULL;
struct buffer_core_t {
PyObject_HEAD
tf2::BufferCore *bc;
};
static PyTypeObject buffer_core_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*size*/
"_tf2.BufferCore", /*name*/
sizeof(buffer_core_t), /*basicsize*/
};
static PyObject *PyObject_BorrowAttrString(PyObject* o, const char *name)
{
PyObject *r = PyObject_GetAttrString(o, name);
if (r != NULL)
Py_DECREF(r);
return r;
}
static PyObject *transform_converter(const geometry_msgs::TransformStamped* transform)
{
PyObject *pclass, *pargs, *pinst = NULL;
pclass = PyObject_GetAttrString(pModulegeometrymsgs, "TransformStamped");
if(pclass == NULL)
{
printf("Can't get geometry_msgs.msg.TransformedStamped\n");
return NULL;
}
pargs = Py_BuildValue("()");
if(pargs == NULL)
{
printf("Can't build argument list\n");
return NULL;
}
pinst = PyEval_CallObject(pclass, pargs);
Py_DECREF(pclass);
Py_DECREF(pargs);
if(pinst == NULL)
{
printf("Can't create class\n");
return NULL;
}
//we need to convert the time to python
PyObject *rospy_time = PyObject_GetAttrString(pModulerospy, "Time");
PyObject *args = Py_BuildValue("ii", transform->header.stamp.sec, transform->header.stamp.nsec);
PyObject *time_obj = PyObject_CallObject(rospy_time, args);
Py_DECREF(args);
Py_DECREF(rospy_time);
PyObject* pheader = PyObject_GetAttrString(pinst, "header");
PyObject_SetAttrString(pheader, "stamp", time_obj);
Py_DECREF(time_obj);
PyObject_SetAttrString(pheader, "frame_id", PyString_FromString((transform->header.frame_id).c_str()));
Py_DECREF(pheader);
PyObject *ptransform = PyObject_GetAttrString(pinst, "transform");
PyObject *ptranslation = PyObject_GetAttrString(ptransform, "translation");
PyObject *protation = PyObject_GetAttrString(ptransform, "rotation");
Py_DECREF(ptransform);
PyObject_SetAttrString(pinst, "child_frame_id", PyString_FromString((transform->child_frame_id).c_str()));
PyObject_SetAttrString(ptranslation, "x", PyFloat_FromDouble(transform->transform.translation.x));
PyObject_SetAttrString(ptranslation, "y", PyFloat_FromDouble(transform->transform.translation.y));
PyObject_SetAttrString(ptranslation, "z", PyFloat_FromDouble(transform->transform.translation.z));
Py_DECREF(ptranslation);
PyObject_SetAttrString(protation, "x", PyFloat_FromDouble(transform->transform.rotation.x));
PyObject_SetAttrString(protation, "y", PyFloat_FromDouble(transform->transform.rotation.y));
PyObject_SetAttrString(protation, "z", PyFloat_FromDouble(transform->transform.rotation.z));
PyObject_SetAttrString(protation, "w", PyFloat_FromDouble(transform->transform.rotation.w));
Py_DECREF(protation);
return pinst;
}
static int rostime_converter(PyObject *obj, ros::Time *rt)
{
PyObject *tsr = PyObject_CallMethod(obj, (char*)"to_sec", NULL);
if (tsr == NULL) {
PyErr_SetString(PyExc_TypeError, "time must have a to_sec method, e.g. rospy.Time or rospy.Duration");
return 0;
} else {
(*rt).fromSec(PyFloat_AsDouble(tsr));
Py_DECREF(tsr);
return 1;
}
}
static int rosduration_converter(PyObject *obj, ros::Duration *rt)
{
PyObject *tsr = PyObject_CallMethod(obj, (char*)"to_sec", NULL);
if (tsr == NULL) {
PyErr_SetString(PyExc_TypeError, "time must have a to_sec method, e.g. rospy.Time or rospy.Duration");
return 0;
} else {
(*rt).fromSec(PyFloat_AsDouble(tsr));
Py_DECREF(tsr);
return 1;
}
}
static int BufferCore_init(PyObject *self, PyObject *args, PyObject *kw)
{
ros::Duration cache_time;
cache_time.fromSec(tf2::BufferCore::DEFAULT_CACHE_TIME);
if (!PyArg_ParseTuple(args, "|O&", rosduration_converter, &cache_time))
return -1;
((buffer_core_t*)self)->bc = new tf2::BufferCore(cache_time);
return 0;
}
/* This may need to be implemented later if we decide to have it in the core
static PyObject *getTFPrefix(PyObject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
tf::Transformer *t = ((transformer_t*)self)->t;
return PyString_FromString(t->getTFPrefix().c_str());
}
*/
static PyObject *allFramesAsYAML(PyObject *self, PyObject *args)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
return PyString_FromString(bc->allFramesAsYAML().c_str());
}
static PyObject *allFramesAsString(PyObject *self, PyObject *args)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
return PyString_FromString(bc->allFramesAsString().c_str());
}
static PyObject *canTransformCore(PyObject *self, PyObject *args, PyObject *kw)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
char *target_frame, *source_frame;
ros::Time time;
static const char *keywords[] = { "target_frame", "source_frame", "time", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kw, "ssO&", (char**)keywords, &target_frame, &source_frame, rostime_converter, &time))
return NULL;
std::string error_msg;
bool can_transform = bc->canTransform(target_frame, source_frame, time, &error_msg);
//return PyBool_FromLong(t->canTransform(target_frame, source_frame, time));
return Py_BuildValue("bs", can_transform, error_msg.c_str());
}
static PyObject *canTransformFullCore(PyObject *self, PyObject *args, PyObject *kw)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
char *target_frame, *source_frame, *fixed_frame;
ros::Time target_time, source_time;
static const char *keywords[] = { "target_frame", "target_time", "source_frame", "source_time", "fixed_frame", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO&sO&s", (char**)keywords,
&target_frame,
rostime_converter,
&target_time,
&source_frame,
rostime_converter,
&source_time,
&fixed_frame))
return NULL;
std::string error_msg;
bool can_transform = bc->canTransform(target_frame, target_time, source_frame, source_time, fixed_frame, &error_msg);
//return PyBool_FromLong(t->canTransform(target_frame, target_time, source_frame, source_time, fixed_frame));
return Py_BuildValue("bs", can_transform, error_msg.c_str());
}
/* Debugging stuff that may need to be implemented later
static PyObject *asListOfStrings(std::vector< std::string > los)
{
PyObject *r = PyList_New(los.size());
size_t i;
for (i = 0; i < los.size(); i++) {
PyList_SetItem(r, i, PyString_FromString(los[i].c_str()));
}
return r;
}
static PyObject *chain(PyObject *self, PyObject *args, PyObject *kw)
{
tf::Transformer *t = ((transformer_t*)self)->t;
char *target_frame, *source_frame, *fixed_frame;
ros::Time target_time, source_time;
std::vector< std::string > output;
static const char *keywords[] = { "target_frame", "target_time", "source_frame", "source_time", "fixed_frame", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO&sO&s", (char**)keywords,
&target_frame,
rostime_converter,
&target_time,
&source_frame,
rostime_converter,
&source_time,
&fixed_frame))
return NULL;
WRAP(t->chainAsVector(target_frame, target_time, source_frame, source_time, fixed_frame, output));
return asListOfStrings(output);
}
static PyObject *getLatestCommonTime(PyObject *self, PyObject *args, PyObject *kw)
{
tf::Transformer *t = ((transformer_t*)self)->t;
char *source, *dest;
std::string error_string;
ros::Time time;
if (!PyArg_ParseTuple(args, "ss", &source, &dest))
return NULL;
int r = t->getLatestCommonTime(source, dest, time, &error_string);
if (r == 0) {
PyObject *rospy_time = PyObject_GetAttrString(pModulerospy, "Time");
PyObject *args = Py_BuildValue("ii", time.sec, time.nsec);
PyObject *ob = PyObject_CallObject(rospy_time, args);
Py_DECREF(args);
Py_DECREF(rospy_time);
return ob;
} else {
PyErr_SetString(tf_exception, error_string.c_str());
return NULL;
}
}
*/
static PyObject *lookupTransformCore(PyObject *self, PyObject *args, PyObject *kw)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
char *target_frame, *source_frame;
ros::Time time;
static const char *keywords[] = { "target_frame", "source_frame", "time", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kw, "ssO&", (char**)keywords, &target_frame, &source_frame, rostime_converter, &time))
return NULL;
geometry_msgs::TransformStamped transform;
WRAP(transform = bc->lookupTransform(target_frame, source_frame, time));
geometry_msgs::Vector3 origin = transform.transform.translation;
geometry_msgs::Quaternion rotation = transform.transform.rotation;
//TODO: Create a converter that will actually return a python message
return Py_BuildValue("O&", transform_converter, &transform);
//return Py_BuildValue("(ddd)(dddd)",
// origin.x, origin.y, origin.z,
// rotation.x, rotation.y, rotation.z, rotation.w);
}
static PyObject *lookupTransformFullCore(PyObject *self, PyObject *args, PyObject *kw)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
char *target_frame, *source_frame, *fixed_frame;
ros::Time target_time, source_time;
static const char *keywords[] = { "target_frame", "target_time", "source_frame", "source_time", "fixed_frame", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO&sO&s", (char**)keywords,
&target_frame,
rostime_converter,
&target_time,
&source_frame,
rostime_converter,
&source_time,
&fixed_frame))
return NULL;
geometry_msgs::TransformStamped transform;
WRAP(transform = bc->lookupTransform(target_frame, target_time, source_frame, source_time, fixed_frame));
geometry_msgs::Vector3 origin = transform.transform.translation;
geometry_msgs::Quaternion rotation = transform.transform.rotation;
//TODO: Create a converter that will actually return a python message
return Py_BuildValue("O&", transform_converter, &transform);
}
/*
static PyObject *lookupTwistCore(PyObject *self, PyObject *args, PyObject *kw)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
char *tracking_frame, *observation_frame;
ros::Time time;
ros::Duration averaging_interval;
static const char *keywords[] = { "tracking_frame", "observation_frame", "time", "averaging_interval", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kw, "ssO&O&", (char**)keywords, &tracking_frame, &observation_frame, rostime_converter, &time, rosduration_converter, &averaging_interval))
return NULL;
geometry_msgs::Twist twist;
WRAP(twist = bc->lookupTwist(tracking_frame, observation_frame, time, averaging_interval));
return Py_BuildValue("(ddd)(ddd)",
twist.linear.x, twist.linear.y, twist.linear.z,
twist.angular.x, twist.angular.y, twist.angular.z);
}
static PyObject *lookupTwistFullCore(PyObject *self, PyObject *args)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
char *tracking_frame, *observation_frame, *reference_frame, *reference_point_frame;
ros::Time time;
ros::Duration averaging_interval;
double px, py, pz;
if (!PyArg_ParseTuple(args, "sss(ddd)sO&O&",
&tracking_frame,
&observation_frame,
&reference_frame,
&px, &py, &pz,
&reference_point_frame,
rostime_converter, &time,
rosduration_converter, &averaging_interval))
return NULL;
geometry_msgs::Twist twist;
tf::Point pt(px, py, pz);
WRAP(twist = bc->lookupTwist(tracking_frame, observation_frame, reference_frame, pt, reference_point_frame, time, averaging_interval));
return Py_BuildValue("(ddd)(ddd)",
twist.linear.x, twist.linear.y, twist.linear.z,
twist.angular.x, twist.angular.y, twist.angular.z);
}
*/
static PyObject *setTransform(PyObject *self, PyObject *args)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
PyObject *py_transform;
char *authority;
if (!PyArg_ParseTuple(args, "Os", &py_transform, &authority))
return NULL;
geometry_msgs::TransformStamped transform;
PyObject *header = PyObject_BorrowAttrString(py_transform, "header");
transform.child_frame_id = PyString_AsString(PyObject_BorrowAttrString(py_transform, "child_frame_id"));
transform.header.frame_id = PyString_AsString(PyObject_BorrowAttrString(header, "frame_id"));
if (rostime_converter(PyObject_BorrowAttrString(header, "stamp"), &transform.header.stamp) != 1)
return NULL;
PyObject *mtransform = PyObject_BorrowAttrString(py_transform, "transform");
PyObject *translation = PyObject_BorrowAttrString(mtransform, "translation");
transform.transform.translation.x = PyFloat_AsDouble(PyObject_BorrowAttrString(translation, "x"));
transform.transform.translation.y = PyFloat_AsDouble(PyObject_BorrowAttrString(translation, "y"));
transform.transform.translation.z = PyFloat_AsDouble(PyObject_BorrowAttrString(translation, "z"));
PyObject *rotation = PyObject_BorrowAttrString(mtransform, "rotation");
transform.transform.rotation.x = PyFloat_AsDouble(PyObject_BorrowAttrString(rotation, "x"));
transform.transform.rotation.y = PyFloat_AsDouble(PyObject_BorrowAttrString(rotation, "y"));
transform.transform.rotation.z = PyFloat_AsDouble(PyObject_BorrowAttrString(rotation, "z"));
transform.transform.rotation.w = PyFloat_AsDouble(PyObject_BorrowAttrString(rotation, "w"));
bc->setTransform(transform, authority);
Py_RETURN_NONE;
}
static PyObject *setTransformStatic(PyObject *self, PyObject *args)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
PyObject *py_transform;
char *authority;
if (!PyArg_ParseTuple(args, "Os", &py_transform, &authority))
return NULL;
geometry_msgs::TransformStamped transform;
PyObject *header = PyObject_BorrowAttrString(py_transform, "header");
transform.child_frame_id = PyString_AsString(PyObject_BorrowAttrString(py_transform, "child_frame_id"));
transform.header.frame_id = PyString_AsString(PyObject_BorrowAttrString(header, "frame_id"));
if (rostime_converter(PyObject_BorrowAttrString(header, "stamp"), &transform.header.stamp) != 1)
return NULL;
PyObject *mtransform = PyObject_BorrowAttrString(py_transform, "transform");
PyObject *translation = PyObject_BorrowAttrString(mtransform, "translation");
transform.transform.translation.x = PyFloat_AsDouble(PyObject_BorrowAttrString(translation, "x"));
transform.transform.translation.y = PyFloat_AsDouble(PyObject_BorrowAttrString(translation, "y"));
transform.transform.translation.z = PyFloat_AsDouble(PyObject_BorrowAttrString(translation, "z"));
PyObject *rotation = PyObject_BorrowAttrString(mtransform, "rotation");
transform.transform.rotation.x = PyFloat_AsDouble(PyObject_BorrowAttrString(rotation, "x"));
transform.transform.rotation.y = PyFloat_AsDouble(PyObject_BorrowAttrString(rotation, "y"));
transform.transform.rotation.z = PyFloat_AsDouble(PyObject_BorrowAttrString(rotation, "z"));
transform.transform.rotation.w = PyFloat_AsDouble(PyObject_BorrowAttrString(rotation, "w"));
// only difference to above is is_static == True
bc->setTransform(transform, authority, true);
Py_RETURN_NONE;
}
static PyObject *clear(PyObject *self, PyObject *args)
{
tf2::BufferCore *bc = ((buffer_core_t*)self)->bc;
bc->clear();
Py_RETURN_NONE;
}
/* May come back eventually, but not in public api right now
static PyObject *frameExists(PyObject *self, PyObject *args)
{
tf::Transformer *t = ((transformer_t*)self)->t;
char *frame_id_str;
if (!PyArg_ParseTuple(args, "s", &frame_id_str))
return NULL;
return PyBool_FromLong(t->frameExists(frame_id_str));
}
static PyObject *getFrameStrings(PyObject *self, PyObject *args)
{
tf::Transformer *t = ((transformer_t*)self)->t;
std::vector< std::string > ids;
t->getFrameStrings(ids);
return asListOfStrings(ids);
}
*/
static struct PyMethodDef buffer_core_methods[] =
{
{"all_frames_as_yaml", allFramesAsYAML, METH_VARARGS},
{"all_frames_as_string", allFramesAsString, METH_VARARGS},
{"set_transform", setTransform, METH_VARARGS},
{"set_transform_static", setTransformStatic, METH_VARARGS},
{"can_transform_core", (PyCFunction)canTransformCore, METH_KEYWORDS},
{"can_transform_full_core", (PyCFunction)canTransformFullCore, METH_KEYWORDS},
//{"chain", (PyCFunction)chain, METH_KEYWORDS},
{"clear", (PyCFunction)clear, METH_KEYWORDS},
//{"frameExists", (PyCFunction)frameExists, METH_VARARGS},
//{"getFrameStrings", (PyCFunction)getFrameStrings, METH_VARARGS},
//{"getLatestCommonTime", (PyCFunction)getLatestCommonTime, METH_VARARGS},
{"lookup_transform_core", (PyCFunction)lookupTransformCore, METH_KEYWORDS},
{"lookup_transform_full_core", (PyCFunction)lookupTransformFullCore, METH_KEYWORDS},
//{"lookupTwistCore", (PyCFunction)lookupTwistCore, METH_KEYWORDS},
//{"lookupTwistFullCore", lookupTwistFullCore, METH_VARARGS},
//{"getTFPrefix", (PyCFunction)getTFPrefix, METH_VARARGS},
{NULL, NULL}
};
static PyMethodDef module_methods[] = {
// {"Transformer", mkTransformer, METH_VARARGS},
{0, 0, 0},
};
extern "C" void init_tf2()
{
PyObject *item, *m, *d;
#if PYTHON_API_VERSION >= 1007
tf2_exception = PyErr_NewException((char*)"tf2.TransformException", NULL, NULL);
tf2_connectivityexception = PyErr_NewException((char*)"tf2.ConnectivityException", tf2_exception, NULL);
tf2_lookupexception = PyErr_NewException((char*)"tf2.LookupException", tf2_exception, NULL);
tf2_extrapolationexception = PyErr_NewException((char*)"tf2.ExtrapolationException", tf2_exception, NULL);
tf2_invalidargumentexception = PyErr_NewException((char*)"tf2.InvalidArgumentException", tf2_exception, NULL);
tf2_timeoutexception = PyErr_NewException((char*)"tf2.TimeoutException", tf2_exception, NULL);
#else
tf2_exception = PyString_FromString("tf2.error");
tf2_connectivityexception = PyString_FromString("tf2.ConnectivityException");
tf2_lookupexception = PyString_FromString("tf2.LookupException");
tf2_extrapolationexception = PyString_FromString("tf2.ExtrapolationException");
tf2_invalidargumentexception = PyString_FromString("tf2.InvalidArgumentException");
tf2_timeoutexception = PyString_FromString("tf2.TimeoutException");
#endif
pModulerospy = PyImport_Import(item= PyString_FromString("rospy")); Py_DECREF(item);
pModulegeometrymsgs = PyImport_ImportModule("geometry_msgs.msg");
if(pModulegeometrymsgs == NULL)
{
printf("Cannot load geometry_msgs module");
return;
}
buffer_core_Type.tp_alloc = PyType_GenericAlloc;
buffer_core_Type.tp_new = PyType_GenericNew;
buffer_core_Type.tp_init = BufferCore_init;
buffer_core_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
buffer_core_Type.tp_methods = buffer_core_methods;
if (PyType_Ready(&buffer_core_Type) != 0)
return;
m = Py_InitModule("_tf2", module_methods);
PyModule_AddObject(m, "BufferCore", (PyObject *)&buffer_core_Type);
d = PyModule_GetDict(m);
PyDict_SetItemString(d, "TransformException", tf2_exception);
PyDict_SetItemString(d, "ConnectivityException", tf2_connectivityexception);
PyDict_SetItemString(d, "LookupException", tf2_lookupexception);
PyDict_SetItemString(d, "ExtrapolationException", tf2_extrapolationexception);
PyDict_SetItemString(d, "InvalidArgumentException", tf2_invalidargumentexception);
PyDict_SetItemString(d, "TimeoutException", tf2_timeoutexception);
}
| 0 |
apollo_public_repos/apollo-platform/ros/geometry2/tf2_py/src | apollo_public_repos/apollo-platform/ros/geometry2/tf2_py/src/tf2_py/__init__.py | #! /usr/bin/python
#***********************************************************
#* Software License Agreement (BSD License)
#*
#* Copyright (c) 2009, Willow Garage, Inc.
#* 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 Willow Garage, Inc. 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 OWNER 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.
#*
#* Author: Eitan Marder-Eppstein
#***********************************************************
from _tf2 import *
| 0 |
apollo_public_repos/apollo-platform/ros | apollo_public_repos/apollo-platform/ros/genlisp/CMakeLists.txt | cmake_minimum_required(VERSION 2.8.3)
project(genlisp)
find_package(catkin REQUIRED COMPONENTS genmsg)
catkin_package(
CATKIN_DEPENDS genmsg
CFG_EXTRAS genlisp-extras.cmake
)
add_subdirectory(scripts)
file(WRITE ${CATKIN_DEVEL_PREFIX}/${GENMSG_LANGS_DESTINATION}/genlisp "LISP")
install(FILES ${CATKIN_DEVEL_PREFIX}/${GENMSG_LANGS_DESTINATION}/genlisp
DESTINATION ${GENMSG_LANGS_DESTINATION})
# drop marker file to prevent rospack from spending time on crawling this folder
file(WRITE ${CATKIN_DEVEL_PREFIX}/share/common-lisp/rospack_nosubdirs "")
install(FILES ${CATKIN_DEVEL_PREFIX}/share/common-lisp/rospack_nosubdirs
DESTINATION share/common-lisp)
catkin_python_setup()
| 0 |
apollo_public_repos/apollo-platform/ros | apollo_public_repos/apollo-platform/ros/genlisp/package.xml | <?xml version="1.0"?>
<package>
<name>genlisp</name>
<version>0.4.15</version>
<description>
Common-Lisp ROS message and service generators.
</description>
<maintainer email="dthomas@osrfoundation.org">Dirk Thomas</maintainer>
<maintainer email="georg.bartels@cs.uni-bremen.de">Georg Bartels</maintainer>
<license>BSD</license>
<url type="website">http://www.ros.org/wiki/roslisp</url>
<author email="bhaskara@willowgarage.com">Bhaskara Marti</author>
<buildtool_depend version_gte="0.5.78">catkin</buildtool_depend>
<build_depend>genmsg</build_depend>
<run_depend>genmsg</run_depend>
<export>
<message_generator>lisp</message_generator>
</export>
</package>
| 0 |
apollo_public_repos/apollo-platform/ros | apollo_public_repos/apollo-platform/ros/genlisp/setup.py | #!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
d = generate_distutils_setup(
packages=['genlisp'],
package_dir={'': 'src'},
requires=['genmsg']
)
setup(**d)
| 0 |
apollo_public_repos/apollo-platform/ros | apollo_public_repos/apollo-platform/ros/genlisp/.tar | {!!python/unicode 'url': 'https://github.com/ros-gbp/genlisp-release/archive/release/indigo/genlisp/0.4.15-0.tar.gz',
!!python/unicode 'version': genlisp-release-release-indigo-genlisp-0.4.15-0}
| 0 |
apollo_public_repos/apollo-platform/ros/genlisp | apollo_public_repos/apollo-platform/ros/genlisp/cmake/genlisp-extras.cmake.em | @[if DEVELSPACE]@
# bin and template dir variables in develspace
set(GENLISP_BIN "@(CMAKE_CURRENT_SOURCE_DIR)/scripts/gen_lisp.py")
set(GENLISP_TEMPLATE_DIR "@(CMAKE_CURRENT_SOURCE_DIR)/scripts")
@[else]@
# bin and template dir variables in installspace
set(GENLISP_BIN "${genlisp_DIR}/../../../@(CATKIN_PACKAGE_BIN_DESTINATION)/gen_lisp.py")
set(GENLISP_TEMPLATE_DIR "${genlisp_DIR}/..")
@[end if]@
# Generate .msg or .srv -> .lisp
# The generated .lisp files should be added ALL_GEN_OUTPUT_FILES_lisp
macro(_generate_lisp ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
file(MAKE_DIRECTORY ${ARG_GEN_OUTPUT_DIR})
#Create input and output filenames
get_filename_component(MSG_NAME ${ARG_MSG} NAME)
get_filename_component(MSG_SHORT_NAME ${ARG_MSG} NAME_WE)
set(MSG_GENERATED_NAME ${MSG_SHORT_NAME}.lisp)
set(GEN_OUTPUT_FILE ${ARG_GEN_OUTPUT_DIR}/${MSG_GENERATED_NAME})
assert(CATKIN_ENV)
add_custom_command(OUTPUT ${GEN_OUTPUT_FILE}
DEPENDS ${GENLISP_BIN} ${ARG_MSG} ${ARG_MSG_DEPS}
COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENLISP_BIN} ${ARG_MSG}
${ARG_IFLAGS}
-p ${ARG_PKG}
-o ${ARG_GEN_OUTPUT_DIR}
COMMENT "Generating Lisp code from ${ARG_PKG}/${MSG_NAME}"
)
list(APPEND ALL_GEN_OUTPUT_FILES_lisp ${GEN_OUTPUT_FILE})
endmacro()
#genlisp uses the same program to generate srv and msg files, so call the same macro
macro(_generate_msg_lisp ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
_generate_lisp(${ARG_PKG} ${ARG_MSG} "${ARG_IFLAGS}" "${ARG_MSG_DEPS}" "${ARG_GEN_OUTPUT_DIR}/msg")
endmacro()
#genlisp uses the same program to generate srv and msg files, so call the same macro
macro(_generate_srv_lisp ARG_PKG ARG_SRV ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
_generate_lisp(${ARG_PKG} ${ARG_SRV} "${ARG_IFLAGS}" "${ARG_MSG_DEPS}" "${ARG_GEN_OUTPUT_DIR}/srv")
endmacro()
macro(_generate_module_lisp ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES)
endmacro()
set(common_lisp_INSTALL_DIR share/common-lisp)
set(genlisp_INSTALL_DIR ${common_lisp_INSTALL_DIR}/ros)
| 0 |
apollo_public_repos/apollo-platform/ros/genlisp | apollo_public_repos/apollo-platform/ros/genlisp/scripts/srv.lisp.template | @###############################################
@#
@# ROS message source code generation for C++
@#
@# EmPy template for generating <msg>.h files
@#
@###############################################
@# Start of Template
@#
@# Context:
@# - file_name_in (String) Source file
@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
@# - md5sum (String) MD5Sum of the .msg specification
@###############################################
#include <boost/python.hpp>
#include <@(spec.package)/@(spec.short_name).h>
using namespace boost::python;
void export_@(spec.short_name)()
{
class_<@(spec.package)::@(spec.short_name)>("@(spec.short_name)")
.def_readwrite("request", &@(spec.package)::@(spec.short_name)::request)
.def_readwrite("response", &@(spec.package)::@(spec.short_name)::response);
}
| 0 |
apollo_public_repos/apollo-platform/ros/genlisp | apollo_public_repos/apollo-platform/ros/genlisp/scripts/gen_lisp.py | #!/usr/bin/env python
# Software License Agreement (BSD License)
#
# Copyright (c) 2012, Willow Garage, Inc.
# 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 Willow Garage, Inc. 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 OWNER 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.
#
## ROS message source code generation for Lisp
##
## Converts ROS .msg files in a package into Lisp source files
import genlisp
import sys
if __name__ == "__main__":
genlisp.genlisp_main.genmain(sys.argv, 'gen_lisp.py')
| 0 |
apollo_public_repos/apollo-platform/ros/genlisp | apollo_public_repos/apollo-platform/ros/genlisp/scripts/CMakeLists.txt | install(
FILES msg.lisp.template srv.lisp.template
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
catkin_install_python(
PROGRAMS gen_lisp.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
| 0 |
apollo_public_repos/apollo-platform/ros/genlisp | apollo_public_repos/apollo-platform/ros/genlisp/scripts/msg.lisp.template | @###############################################
@#
@# ROS message source code generation for C++
@#
@# EmPy template for generating <msg>.h files
@#
@###############################################
@# Start of Template
@#
@# Context:
@# - file_name_in (String) Source file
@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
@# - md5sum (String) MD5Sum of the .msg specification
@###############################################
#include <boost/python.hpp>
#include <@(spec.package)/@(spec.short_name).h>
using namespace boost::python;
void export_@(spec.short_name)()
{
class_<@(spec.package)::@(spec.short_name)>("@(spec.short_name)")
@[for field in spec.parsed_fields()]@
.def_readwrite("@(field.name)", &@(spec.package)::@(spec.short_name)::@(field.name))
@[end for]@#field
;
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.