-
Notifications
You must be signed in to change notification settings - Fork 1
/
automatic_calib_pose_preset.py
54 lines (45 loc) · 1.52 KB
/
automatic_calib_pose_preset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This is used for setting the fixed poses used in automatic
hand-eye calibration.
"""
import rospy
import numpy as np
import yaml
import jkrc
if __name__ == '__main__':
rospy.init_node('automatic_calib_pose_preset', anonymous=True)
robot_ip = rospy.get_param("/robot_ip", default="192.168.200.100")
# Creating an array storing the 25 joint poses
joint_pose = np.array([25, 6])
# Counter
pose_number = 0
# Starting the robot
robot = jkrc.RC(robot_ip)
robot.login()
robot.power_on()
robot.enable_robot()
rospy.sleep(1)
while not rospy.is_shutdown():
try:
print("Record: r")
command = str(input())
if command == 'r':
ret = robot.get_joint_position()
if ret[0] == 0:
pose = np.array(ret[1])
joint_pose[pose_number, :] = pose
pose_number += 1
print(f"{pose_number} poses have been recorded")
else:
print("Failed to acquire the pose data!")
else:
rospy.logwarn("Invalid option!")
if pose_number == 25:
with open('../yaml/pose_for_automatic_calib.yaml', 'w', encoding='utf-8') as f:
yaml.dump(data=joint_pose.tolist(), stream=f)
robot.logout()
break
except rospy.ROSInterruptException:
rospy.logwarn("No object pose data available!")