3535from rclpy .node import Node
3636from trajectory_msgs .msg import JointTrajectory as JTmsg , JointTrajectoryPoint
3737from ur_msgs .srv import SetIO , SetForceMode
38- from ur_msgs .action import TrajectoryUntil , ToolContact
3938from controller_manager_msgs .srv import (
4039 UnloadController ,
4140 LoadController ,
5150TIMEOUT_WAIT_SERVICE_INITIAL = 60
5251TIMEOUT_WAIT_ACTION = 10
5352
53+ MOTION_CONTROLLERS = ["passthrough_trajectory_controller" , "scaled_joint_trajectory_controller" ]
54+
5455ROBOT_JOINTS = [
5556 "shoulder_pan_joint" ,
5657 "shoulder_lift_joint" ,
@@ -148,7 +149,7 @@ def set_io(self, pin, value):
148149
149150 self .call_service (Services .Set_IO , set_io_req )
150151
151- def follow_trajectory (self , waypts , time_vec ):
152+ def follow_trajectory (self , waypts : list [ list [ float ]] , time_vec : list [ float ] ):
152153 # No other motion controllers can be active at the same time as the scaled joint controller
153154 self .switch_controllers (
154155 ["scaled_joint_trajectory_controller" ],
@@ -185,10 +186,10 @@ def follow_trajectory(self, waypts, time_vec):
185186
186187 def passthrough_trajectory (
187188 self ,
188- waypts : list [float ],
189+ waypts : list [list [ float ] ],
189190 time_vec : list [float ],
190- vels : list [float ] = [],
191- accels : list [float ] = [],
191+ vels : list [list [ float ] ] = [],
192+ accels : list [list [ float ] ] = [],
192193 goal_time_tolerance = Duration (sec = 1 ),
193194 ):
194195 # The scaled joint controller can't be active at the same time as the passthrough controller
@@ -219,9 +220,7 @@ def passthrough_trajectory(
219220 raise Exception ("trajectory was not accepted" )
220221
221222 # Verify execution
222- result = self .get_result (
223- Actions .PASSTHROUGH_TRAJECTORY , goal_response
224- )
223+ result = self .get_result (Actions .PASSTHROUGH_TRAJECTORY , goal_response )
225224 return result
226225
227226 def call_service (self , Service : Services , request ):
@@ -255,7 +254,7 @@ def load_controller(self, controller_name: str):
255254 # Find loaded controllers
256255 for controller in list_response .controller :
257256 names .append (controller .name )
258- # Check whether the passthrough controller is already loaded
257+ # Check whether the controller is already loaded
259258 try :
260259 names .index (controller_name )
261260 except ValueError :
@@ -264,9 +263,7 @@ def load_controller(self, controller_name: str):
264263 self .call_service (Services .Load_Controller , load_request )
265264 configure_request = ConfigureController .Request (name = controller_name )
266265 self .call_service (Services .Configure_Controller , configure_request )
267- list_response = robot .call_service (
268- Services .List_Controllers , ListControllers .Request ()
269- )
266+ list_response = self .call_service (Services .List_Controllers , ListControllers .Request ())
270267 names .clear ()
271268 # Update the list of controller names.
272269 for controller in list_response .controller :
@@ -286,10 +283,10 @@ def switch_controllers(self, active: list[str] = [], inactive: list[str] = []) -
286283 switch_request .activate_asap = False
287284 switch_request .timeout = Duration (sec = 2 , nanosec = 0 )
288285 return self .call_service (Services .Switch_Controller , switch_request )
289-
286+
290287 def start_force_mode (self , req : SetForceMode .Request ):
291288 return self .call_service (Services .start_force_mode , req )
292-
289+
293290 def stop_force_mode (self ):
294291 return self .call_service (Services .stop_force_mode , Trigger .Request ())
295292
@@ -299,15 +296,15 @@ def stop_force_mode(self):
299296 node = Node ("robot_driver_test" )
300297 print ("Available actions:" )
301298 for action in Actions :
302- print (action .name )
303- print (action .value .name )
304- print (action .value .action_type )
299+ print ("Action Enum name: " , action .name )
300+ print ("Action Ros name: " , action .value .name )
301+ print ("Action Ros type: " , action .value .action_type )
305302 print ("Available services:" )
306303 for service in Services :
307- print (service .name )
308- print (service .value .name )
309- print (service .value .service_type )
310-
304+ print ("Service Enum name: " , service .name )
305+ print ("Service Ros name: " , service .value .name )
306+ print ("Service Ros type: " , service .value .service_type )
307+
311308 # robot = Robot(node)
312309 # robot.switch_controllers(
313310 # ["passthrough_trajectory_controller"], ["scaled_joint_trajectory_controller"]
0 commit comments