-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjust_kinematics.py
58 lines (48 loc) · 1.67 KB
/
just_kinematics.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
55
56
57
#!/usr/bin/python3
import math
import numpy as np
import sys
import c1c0_object_detection.arm.publish_arm_updates as arm
import c1c0_object_detection.kinematics.linear_rrt as alr
import math
WIDTH = 640
HEIGHT = 480
TARGET_POINT = [0.0, 0.0, 0.5]
if __name__ == '__main__':
detections = []
arm.init_serial()
for i in range(5):
print("serial port initialized")
startpos = arm.read_encoder_values()
startpos = [i*math.pi/180 for i in startpos]
print("arm vals read")
# inverse kinematics
# avg = [(gripper_pt1_arm[i][0] + gripper_pt2_arm[i][0])/2
# for i in range(len(gripper_pt1_arm))]
avg = TARGET_POINT
print("target calculated", avg)
# endpos = RRTNode.from_point(avg_target, startpos)
arm_config, success = alr.linear_rrt_to_point(startpos, avg[2], avg[1], avg[0], [], 5)
# send arm_config to the arm to move
print(arm_config)
if success:
for config in arm_config:
converted_array = alr.radians_to_degrees(config)[::-1]
print("WRITING ARM CONFIG", converted_array)
arm.publish_updates(converted_array, 3)
print("arm config serial written")
break
arm.close_serial()
"""
try:
if success:
for config in arm_config:
print("WRITING ARM CONFIG", config.angles)
arm.writeToSerial(config.angles.astype(int))
print("arm config serial written")
arm.close_serial()
except Exception as e:
print("error in writing to arm config")
print(e)
arm.close_serial()
"""