1- # Copyright 2019 Open Source Robotics Foundation, Inc.
2- # All rights reserved.
1+ # Copyright (c) 2019 Open Source Robotics Foundation, Inc. All rights reserved.
32#
43# Redistribution and use in source and binary forms, with or without
5- # modification, are permitted provided that the following conditions
6- # are met:
4+ # modification, are permitted provided that the following conditions are met:
75#
8- # * Redistributions of source code must retain the above copyright
9- # notice, this list of conditions and the following disclaimer.
10- # * Redistributions in binary form must reproduce the above
11- # copyright notice, this list of conditions and the following
12- # disclaimer in the documentation and/or other materials provided
13- # with the distribution.
14- # * Neither the name of the Willow Garage nor the names of its
15- # contributors may be used to endorse or promote products derived
16- # from this software without specific prior written permission.
6+ # * Redistributions of source code must retain the above copyright
7+ # notice, this list of conditions and the following disclaimer.
178#
18- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21- # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22- # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23- # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24- # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27- # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28- # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
9+ # * Redistributions in binary form must reproduce the above copyright
10+ # notice, this list of conditions and the following disclaimer in the
11+ # documentation and/or other materials provided with the distribution.
12+ #
13+ # * Neither the name of the copyright holder nor the names of its
14+ # contributors may be used to endorse or promote products derived from
15+ # this software without specific prior written permission.
16+ #
17+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2927# POSSIBILITY OF SUCH DAMAGE.
3028
31- import pytest
3229import threading
33- import time
34-
35- import rclpy
3630
37- from tf2_ros .buffer_client import BufferClient
3831from geometry_msgs .msg import TransformStamped
39- from tf2_msgs . action import LookupTransform
40- from tf2_py import BufferCore , LookupException
32+ import pytest
33+ import rclpy
4134from rclpy .executors import SingleThreadedExecutor
4235from rclpy .time import Time
36+ from tf2_msgs .action import LookupTransform
4337from tf2_msgs .msg import TF2Error
38+ from tf2_py import BufferCore , LookupException
39+ from tf2_ros .buffer_client import BufferClient
4440
4541
4642def build_transform (target_frame , source_frame , stamp ):
@@ -61,8 +57,10 @@ def build_transform(target_frame, source_frame, stamp):
6157
6258
6359class MockBufferServer ():
60+
6461 def __init__ (self , node , buffer_core ):
65- self .action_server = rclpy .action .ActionServer (node , LookupTransform , 'lookup_transform' , self .execute_callback )
62+ self .action_server = rclpy .action .ActionServer (
63+ node , LookupTransform , 'lookup_transform' , self .execute_callback )
6664 self .buffer_core = buffer_core
6765
6866 def execute_callback (self , goal_handle ):
@@ -72,9 +70,10 @@ def execute_callback(self, goal_handle):
7270
7371 try :
7472 if not goal_handle .request .advanced :
75- transform = self .buffer_core .lookup_transform_core (target_frame = goal_handle .request .target_frame ,
76- source_frame = goal_handle .request .source_frame ,
77- time = Time .from_msg (goal_handle .request .source_time ))
73+ transform = self .buffer_core .lookup_transform_core (
74+ target_frame = goal_handle .request .target_frame ,
75+ source_frame = goal_handle .request .source_frame ,
76+ time = Time .from_msg (goal_handle .request .source_time ))
7877 else :
7978 transform = self .buffer_core .lookup_transform_full_core (
8079 target_frame = goal_handle .request .target_frame ,
@@ -85,7 +84,7 @@ def execute_callback(self, goal_handle):
8584 )
8685 response .transform = transform
8786 goal_handle .succeed ()
88- except LookupException as e :
87+ except LookupException :
8988 response .error .error = TF2Error .LOOKUP_ERROR
9089 goal_handle .abort ()
9190
@@ -96,6 +95,7 @@ def destroy(self):
9695
9796
9897class TestBufferClient :
98+
9999 @classmethod
100100 def setup_class (cls ):
101101 cls .context = rclpy .context .Context ()
@@ -133,7 +133,8 @@ def spin(self):
133133
134134 def test_lookup_transform_true (self ):
135135 buffer_client = BufferClient (
136- self .node , 'lookup_transform' , check_frequency = 10.0 , timeout_padding = rclpy .duration .Duration (seconds = 0.0 ))
136+ self .node , 'lookup_transform' , check_frequency = 10.0 ,
137+ timeout_padding = rclpy .duration .Duration (seconds = 0.0 ))
137138
138139 result = buffer_client .lookup_transform (
139140 'foo' , 'bar' , rclpy .time .Time (), rclpy .duration .Duration (seconds = 5.0 ))
@@ -144,7 +145,8 @@ def test_lookup_transform_true(self):
144145
145146 def test_lookup_transform_fail (self ):
146147 buffer_client = BufferClient (
147- self .node , 'lookup_transform' , check_frequency = 10.0 , timeout_padding = rclpy .duration .Duration (seconds = 0.0 ))
148+ self .node , 'lookup_transform' , check_frequency = 10.0 ,
149+ timeout_padding = rclpy .duration .Duration (seconds = 0.0 ))
148150
149151 with pytest .raises (LookupException ) as excinfo :
150152 buffer_client .lookup_transform (
0 commit comments