2323import pytest
2424import rclpy
2525from math import isclose
26- from std_msgs .msg import Bool , Float64MultiArray
26+ from std_msgs .msg import Bool
2727from webots_ros2_msgs .msg import IntStamped
2828from webots_ros2_msgs .srv import GetBool
2929from sensor_msgs .msg import JointState
3030from geometry_msgs .msg import PointStamped
31+ from trajectory_msgs .msg import JointTrajectory , JointTrajectoryPoint
3132from launch import LaunchDescription
3233import launch
3334import launch_testing .actions
@@ -112,7 +113,7 @@ def generate_test_description():
112113 output = "screen" ,
113114 prefix = controller_manager_prefix ,
114115 arguments = [
115- "connector_and_vacuum_gripper_position_controller " ,
116+ "connector_and_vacuum_gripper_trajectory_controller " ,
116117 "--param-file" ,
117118 robot_ros2_control_params ,
118119 ]
@@ -203,8 +204,8 @@ def tearDownClass(cls):
203204 def setUp (self ):
204205 self .__node = rclpy .create_node ("connector_and_vacuum_gripper_tester" )
205206 self .joint_publisher = self .__node .create_publisher (
206- Float64MultiArray ,
207- "/robot/connector_and_vacuum_gripper_position_controller/commands " ,
207+ JointTrajectory ,
208+ "/robot/connector_and_vacuum_gripper_trajectory_controller/joint_trajectory " ,
208209 1 ,
209210 )
210211 self .wait_for_clock (self .__node , messages_to_receive = 20 )
@@ -223,11 +224,13 @@ def on_position_reached(message):
223224
224225 def testConnector (self ):
225226
226- joint_msg = Float64MultiArray ()
227+ joint_msg = JointTrajectory ()
228+ joint_msg .joint_names = ["connector_motor" , "vacuum_gripper_motor" ]
227229
228- joint_msg .data = [- 0.049 , 0.0 ]
229- joint_msg .layout .dim = []
230- joint_msg .layout .data_offset = 1
230+ joint_target = JointTrajectoryPoint ()
231+
232+ joint_target .positions = [- 0.049 , 0.0 ]
233+ joint_msg .points .append (joint_target )
231234
232235 time .sleep (5 )
233236
@@ -259,7 +262,10 @@ def testConnector(self):
259262
260263 self .assertTrue (is_locked_future .result ().value )
261264
262- joint_msg .data = [0.049 , 0.0 ]
265+ joint_target .positions = [0.049 , 0.0 ]
266+ joint_msg .points .clear ()
267+ joint_msg .points .append (joint_target )
268+
263269 self .joint_publisher .publish (joint_msg )
264270 self .wait_for_position (0 , 0.049 )
265271
0 commit comments