Advertisement
zhexo

IRA Task Space test

Apr 7th, 2025
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | Source Code | 0 0
  1. #!/usr/bin/env python
  2. import rospy
  3. import csv
  4. from open_manipulator_msgs.srv import SetKinematicsPose, SetKinematicsPoseRequest
  5.  
  6. def test_pose(x, y, z):
  7.     req = SetKinematicsPoseRequest()
  8.     req.planning_group = "arm"
  9.     req.end_effector_name = "gripper"
  10.     req.kinematics_pose.pose.position.x = x
  11.     req.kinematics_pose.pose.position.y = y
  12.     req.kinematics_pose.pose.position.z = z
  13.     req.kinematics_pose.pose.orientation.x = 0.0
  14.     req.kinematics_pose.pose.orientation.y = 0.0
  15.     req.kinematics_pose.pose.orientation.z = 0.0
  16.     req.kinematics_pose.pose.orientation.w = 1.0
  17.     req.path_time = 1.5
  18.  
  19.     try:
  20.         result = move_service(req)
  21.         return result.is_planned
  22.     except:
  23.         return False
  24.  
  25. def main():
  26.     rospy.init_node('scan_task_space_limits')
  27.     rospy.wait_for_service('/goal_task_space_path')
  28.     global move_service
  29.     move_service = rospy.ServiceProxy('/goal_task_space_path', SetKinematicsPose)
  30.  
  31.     print("๐Ÿ” Pokreฤ‡em ispitivanje radnog prostora manipulatora...")
  32.  
  33.     # Definiraj testne granice
  34.     x_range = [round(x * 0.01, 2) for x in range(-30, 31, 5)]  # -0.30 do +0.30
  35.     y_range = [round(y * 0.01, 2) for y in range(0, 21, 2)]    # 0.00 do +0.20
  36.     z_range = [round(z * 0.01, 2) for z in range(5, 31, 5)]    # 0.05 do +0.30
  37.  
  38.     csv_filename = 'manipulator_task_space_scan.csv'
  39.     with open(csv_filename, mode='w', newline='') as file:
  40.         writer = csv.writer(file)
  41.         writer.writerow(['x (m)', 'y (m)', 'z (m)', 'reachable'])
  42.  
  43.         for x in x_range:
  44.             for y in y_range:
  45.                 for z in z_range:
  46.                     reachable = test_pose(x, y, z)
  47.                     status = "โœ…" if reachable else "โŒ"
  48.                     print(f"{status} x={x:.2f}, y={y:.2f}, z={z:.2f}")
  49.                     writer.writerow([x, y, z, reachable])
  50.  
  51.     print(f"\n๐Ÿ“„ Podaci spremljeni u: {csv_filename}")
  52.  
  53. if __name__ == '__main__':
  54.     main()
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement