@@ -241,3 +241,88 @@ def test_force_mode_controller(self, tf_prefix):
241241 deactivate_controllers = ["force_mode_controller" ],
242242 ).ok
243243 )
244+
245+ def test_illegal_force_mode_types (self , tf_prefix ):
246+ self .assertTrue (
247+ self ._controller_manager_interface .switch_controller (
248+ strictness = SwitchController .Request .BEST_EFFORT ,
249+ activate_controllers = [
250+ "force_mode_controller" ,
251+ ],
252+ deactivate_controllers = [
253+ "scaled_joint_trajectory_controller" ,
254+ "joint_trajectory_controller" ,
255+ ],
256+ ).ok
257+ )
258+ self ._force_mode_controller_interface = ForceModeInterface (self .node )
259+
260+ # Create task frame for force mode
261+ point = Point (x = 0.0 , y = 0.0 , z = 0.0 )
262+ orientation = Quaternion (x = 0.0 , y = 0.0 , z = 0.0 , w = 1.0 )
263+ task_frame_pose = Pose ()
264+ task_frame_pose .position = point
265+ task_frame_pose .orientation = orientation
266+ header = std_msgs .msg .Header (seq = 1 , frame_id = tf_prefix + "base" )
267+ header .stamp .sec = int (time .time ()) + 1
268+ header .stamp .nanosec = 0
269+ frame_stamp = PoseStamped ()
270+ frame_stamp .header = header
271+ frame_stamp .pose = task_frame_pose
272+
273+ res = self ._force_mode_controller_interface .start_force_mode (task_frame = frame_stamp , type = 0 )
274+ self .assertFalse (res .success )
275+ res = self ._force_mode_controller_interface .start_force_mode (task_frame = frame_stamp , type = 4 )
276+ self .assertFalse (res .success )
277+ res = self ._force_mode_controller_interface .start_force_mode (task_frame = frame_stamp , type = 1 )
278+ self .assertTrue (res .success )
279+ res = self ._force_mode_controller_interface .stop_force_mode ()
280+ res = self ._force_mode_controller_interface .start_force_mode (task_frame = frame_stamp , type = 2 )
281+ self .assertTrue (res .success )
282+ res = self ._force_mode_controller_interface .stop_force_mode ()
283+ res = self ._force_mode_controller_interface .start_force_mode (task_frame = frame_stamp , type = 3 )
284+ self .assertTrue (res .success )
285+ res = self ._force_mode_controller_interface .stop_force_mode ()
286+
287+ def test_illegal_task_frame (self , tf_prefix ):
288+ self .assertTrue (
289+ self ._controller_manager_interface .switch_controller (
290+ strictness = SwitchController .Request .BEST_EFFORT ,
291+ activate_controllers = [
292+ "force_mode_controller" ,
293+ ],
294+ deactivate_controllers = [
295+ "scaled_joint_trajectory_controller" ,
296+ "joint_trajectory_controller" ,
297+ ],
298+ ).ok
299+ )
300+ self ._force_mode_controller_interface = ForceModeInterface (self .node )
301+
302+ # Create task frame for force mode
303+ point = Point (x = 0.0 , y = 0.0 , z = 0.0 )
304+ orientation = Quaternion (x = 0.0 , y = 0.0 , z = 0.0 , w = 1.0 )
305+ task_frame_pose = Pose ()
306+ task_frame_pose .position = point
307+ task_frame_pose .orientation = orientation
308+ header = std_msgs .msg .Header (seq = 1 , frame_id = tf_prefix + "base" )
309+ header .stamp .sec = int (time .time ()) + 1
310+ header .stamp .nanosec = 0
311+ frame_stamp = PoseStamped ()
312+ frame_stamp .header = header
313+ frame_stamp .pose = task_frame_pose
314+
315+ # Illegal frame name produces error
316+ header .frame_id = "nonexisting6t54"
317+ res = self ._force_mode_controller_interface .start_force_mode (
318+ task_frame = frame_stamp ,
319+ )
320+ self .assertFalse (res .success )
321+ header .frame_id = "base"
322+
323+ # Illegal quaternion produces error
324+ task_frame_pose .orientation = Quaternion (x = 0.0 , y = 0.0 , z = 0.0 , w = 0.0 )
325+ res = self ._force_mode_controller_interface .start_force_mode (
326+ task_frame = frame_stamp ,
327+ )
328+ self .assertFalse (res .success )
0 commit comments