2626# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2727# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2828# POSSIBILITY OF SUCH DAMAGE.
29+ import logging
2930import os
3031import sys
3132import time
4445from ur_msgs .msg import IOStates
4546
4647sys .path .append (os .path .dirname (__file__ ))
47- from test_common import ( # noqa: 402
48+ from test_common import ( # noqa: E402
4849 ControllerManagerInterface ,
4950 ActionInterface ,
5051 DashboardInterface ,
@@ -149,7 +150,7 @@ def io_msg_cb(msg):
149150 # Set pin 0 to 1.0
150151 test_pin = 0
151152
152- self . node . get_logger (). info (f "Setting pin { test_pin } to 1.0" )
153+ logging . info ("Setting pin %d to 1.0" , test_pin )
153154 self ._io_status_controller_interface .set_io (fun = 1 , pin = test_pin , state = 1.0 )
154155
155156 # Wait until the pin state has changed
@@ -163,7 +164,7 @@ def io_msg_cb(msg):
163164 self .assertEqual (pin_state , 1.0 )
164165
165166 # Set pin 0 to 0.0
166- self . node . get_logger (). info (f "Setting pin { test_pin } to 0.0" )
167+ logging . info ("Setting pin %d to 0.0" , test_pin )
167168 self ._io_status_controller_interface .set_io (fun = 1 , pin = test_pin , state = 0.0 )
168169
169170 # Wait until the pin state has changed back
@@ -196,8 +197,7 @@ def test_trajectory(self, tf_prefix):
196197 )
197198
198199 # Sending trajectory goal
199- self .node .get_logger ().info ("Sending simple goal" )
200-
200+ logging .info ("Sending simple goal" )
201201 goal_handle = self ._scaled_follow_joint_trajectory .send_goal (trajectory = trajectory )
202202 self .assertTrue (goal_handle .accepted )
203203
@@ -206,7 +206,6 @@ def test_trajectory(self, tf_prefix):
206206 goal_handle , TIMEOUT_EXECUTE_TRAJECTORY
207207 )
208208 self .assertEqual (result .error_code , FollowJointTrajectory .Result .SUCCESSFUL )
209- self .node .get_logger ().info ("Received result SUCCESSFUL" )
210209
211210 def test_illegal_trajectory (self , tf_prefix ):
212211 """
@@ -229,14 +228,13 @@ def test_illegal_trajectory(self, tf_prefix):
229228 )
230229
231230 # Send illegal goal
232- self . node . get_logger () .info ("Sending illegal goal" )
231+ logging .info ("Sending illegal goal" )
233232 goal_handle = self ._scaled_follow_joint_trajectory .send_goal (
234233 trajectory = trajectory ,
235234 )
236235
237236 # Verify the failure is correctly detected
238237 self .assertFalse (goal_handle .accepted )
239- self .node .get_logger ().info ("Goal response REJECTED" )
240238
241239 def test_trajectory_scaled (self , tf_prefix ):
242240 """Test robot movement."""
@@ -255,7 +253,7 @@ def test_trajectory_scaled(self, tf_prefix):
255253 )
256254
257255 # Execute trajectory
258- self . node . get_logger () .info ("Sending goal for robot to follow" )
256+ logging .info ("Sending goal for robot to follow" )
259257 goal_handle = self ._scaled_follow_joint_trajectory .send_goal (trajectory = trajectory )
260258 self .assertTrue (goal_handle .accepted )
261259
@@ -266,8 +264,6 @@ def test_trajectory_scaled(self, tf_prefix):
266264 )
267265 self .assertEqual (result .error_code , FollowJointTrajectory .Result .SUCCESSFUL )
268266
269- self .node .get_logger ().info ("Received result" )
270-
271267 def test_trajectory_scaled_aborts_on_violation (self , tf_prefix ):
272268 """Test that the robot correctly aborts the trajectory when the constraints are violated."""
273269 # Construct test trajectory
@@ -298,7 +294,7 @@ def js_cb(msg):
298294 joint_state_sub # prevent warning about unused variable
299295
300296 # Send goal
301- self . node . get_logger () .info ("Sending goal for robot to follow" )
297+ logging .info ("Sending goal for robot to follow" )
302298 goal_handle = self ._scaled_follow_joint_trajectory .send_goal (trajectory = trajectory )
303299 self .assertTrue (goal_handle .accepted )
304300
@@ -309,7 +305,6 @@ def js_cb(msg):
309305 )
310306 self .assertEqual (result .error_code , FollowJointTrajectory .Result .PATH_TOLERANCE_VIOLATED )
311307
312- # self.node.get_logger().info(f"Joint state before sleep {last_joint_state.position}")
313308 state_when_aborted = last_joint_state
314309
315310 # This section is to make sure the robot stopped moving once the trajectory was aborted
@@ -318,8 +313,10 @@ def js_cb(msg):
318313 while last_joint_state == state_when_aborted :
319314 rclpy .spin_once (self .node )
320315 state_after_sleep = last_joint_state
321- self .node .get_logger ().info (f"before: { state_when_aborted .position .tolist ()} " )
322- self .node .get_logger ().info (f"after: { state_after_sleep .position .tolist ()} " )
316+
317+ logging .info ("Joint states before sleep:\t %s" , state_when_aborted .position .tolist ())
318+ logging .info ("Joint states after sleep:\t %s" , state_after_sleep .position .tolist ())
319+
323320 self .assertTrue (
324321 all (
325322 [
0 commit comments