forked from MarkFzp/act-plus-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b0363a
commit 7902f05
Showing
34 changed files
with
23,090 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,4 +147,5 @@ ckpts/ | |
*.npy | ||
play.ipynb | ||
|
||
scr/ | ||
scr/ | ||
mycobot320_script/all_data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
#수정 | ||
base = [[(-3.07), 33.39, 32.78, 6.94, (-88.33), (-1.58)], \ | ||
[(-3.95), 66.53, 8.17, 6.32, (-88.59), (-1.84)], [(-3.95), 66.53, 8.17, 6.32, (-88.59), (-1.84)],\ | ||
[(-4.65), 56.6, 16.17, -7.47, (-91.4), (-3.95)], [(-2.54),29.44,23.81,17.92,(-88.33),(-84.81)],\ | ||
[24.08, 47.89, 0.52, 21.89, -89.03, -50.18],\ | ||
[24.08, 61.52, (-15.73), 35.5, (-89.12), (-71.19)], [24.08, 61.52, (-15.73), 35.5, (-89.12), (-71.19)]] | ||
|
||
#초기 | ||
# base = [[(-3.07), 33.39, 32.78, 6.94, (-88.33), (-1.58)], \ | ||
# [(-3.95), 66.53, 8.17, 6.32, (-88.59), (-1.84)], [(-3.95), 66.53, 8.17, 6.32, (-88.59), (-1.84)],\ | ||
# [(-4.65), 56.6, 16.17, -7.47, (-91.4), (-3.95)], [(-2.54),29.44,23.81,17.92,(-88.33),(-84.81)],\ | ||
# [24.16,23.55,37.96,10.63,(-91.58),(-84.81)], [23.81,85.42,(-50.71),44.64,(-89.38),(-71.01)], [23.81,85.42,(-50.71),44.64,(-89.38),(-71.01)]] | ||
|
||
print(len(base)) | ||
#10FPS기준 | ||
timestep = [1, 1, 1.5, 3, 1.5, 2.5, 1] | ||
framestep = [10, 10, 15, 30, 15, 25, 10] | ||
print(sum(timestep)) | ||
print(sum(framestep)) | ||
|
||
import numpy as np | ||
def cal(a,b,framestep, FPS = 10): | ||
a = np.array(a) | ||
b = np.array(b) | ||
|
||
step_time = 1 / FPS | ||
# 나눌 갯수 | ||
# num_steps = int(total_time / step_time) | ||
|
||
# 각도 간격을 나누는 함수 (등간격) | ||
angles_over_time = np.linspace(a, b, framestep) | ||
return angles_over_time[1:] | ||
# print(len(angles_over_time), angles_over_time) | ||
|
||
pre_base = np.array(base[0]) | ||
frame = [pre_base[np.newaxis, :]] | ||
# print(frame) | ||
# print(frame[0].shape) | ||
for cur_base, cur_time in zip(base[1:], framestep): | ||
cur_value = cal(pre_base, cur_base, cur_time+1) | ||
# print(cur_value) | ||
frame.append(cur_value) | ||
pre_base = cur_base | ||
angles_data = list(np.concatenate(frame, axis=0)) | ||
|
||
gripper_data = [70]*10+list(np.linspace(70, 20, 10))+[20]*85+list(np.linspace(20,70,10)) | ||
print(len(gripper_data), len(angles_data)) #그리퍼가 한개 작음, qpos에서 끝난 값이 다음 값과 연동되어 겹치는 값을 삭제하고 처음에 값을 추가시켰기 때문 | ||
|
||
cnt = 0 | ||
filename = "frame_base_action.txt" | ||
with open(filename, 'w') as f: | ||
for a, b in zip(gripper_data, angles_data): | ||
print(cnt, a,b) | ||
# 각 행의 데이터를 문자열로 변환하고 저장 | ||
f.write(str(cnt)+" : "+str(a)+" : "+str(list(b))+'\n') | ||
cnt += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
70 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
69 | ||
68 | ||
64 | ||
61 | ||
53 | ||
47 | ||
41 | ||
35 | ||
30 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
28 | ||
30 | ||
35 | ||
41 | ||
47 | ||
53 | ||
59 | ||
68 | ||
73 | ||
76 | ||
78 | ||
78 | ||
79 | ||
82 | ||
85 | ||
89 | ||
94 | ||
97 | ||
98 | ||
99 | ||
99 | ||
99 | ||
99 | ||
99 | ||
99 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import threading | ||
import time | ||
from pymycobot.mycobot import MyCobot | ||
import cv2 | ||
|
||
def print_motor_angles(mc): | ||
try: | ||
while True: | ||
# 현재 모터 각도 출력 | ||
angles = mc.get_angles() | ||
print(f"현재 모터 각도: {angles}") | ||
|
||
# 1초간 대기 | ||
time.sleep(1) | ||
|
||
except KeyboardInterrupt: | ||
print("\n스레드가 사용자에 의해 종료됨") | ||
|
||
# MyCobot 객체 초기화 | ||
mc = MyCobot('COM7', 115200) # 포트와 속도에 맞게 수정 | ||
|
||
# MyCobot 초기 설정 | ||
# mc.init_eletric_gripper() | ||
# mc.set_eletric_gripper(0) | ||
# mc.set_gripper_value(100, 20, 1) | ||
mc.set_gripper_mode(0) | ||
mc.send_angles([0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 20) | ||
|
||
# 모터 각도 출력을 담당할 스레드 생성 및 실행 | ||
thread = threading.Thread(target=print_motor_angles, args=(mc,)) | ||
thread.start() | ||
|
||
|
||
#벌리고 초기 이동 | ||
mc.init_eletric_gripper() | ||
mc.set_eletric_gripper(0) | ||
mc.set_gripper_value(100, 20, 1) | ||
time.sleep(1) | ||
mc.send_angles([0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 20) | ||
time.sleep(5) | ||
|
||
cv2.waitKey(0) | ||
print(1) | ||
|
||
try: | ||
# 5초간 기다림 | ||
time.sleep(5) | ||
|
||
except KeyboardInterrupt: | ||
print("\n메인 프로그램이 사용자에 의해 종료됨") | ||
|
||
finally: | ||
# 스레드 종료 | ||
thread.join() | ||
|
||
# 리소스 정리 | ||
mc.release_all_servos() | ||
mc.disconnect() |
Oops, something went wrong.