Skip to content

Commit e98e77f

Browse files
committed
first
1 parent bc51efa commit e98e77f

File tree

563 files changed

+5192
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

563 files changed

+5192
-0
lines changed

.gitignore

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# image and txt file ignore
2+
.jpg
3+
.bmp
4+
.png
5+
.jpeg
6+
.txt
7+
.csv
8+
.npy
9+
10+
# Byte-compiled / optimized / DLL files
11+
__pycache__/
12+
*.py[cod]
13+
*$py.class
14+
15+
# C extensions
16+
*.so
17+
18+
# Distribution / packaging
19+
.Python
20+
build/
21+
develop-eggs/
22+
dist/
23+
downloads/
24+
eggs/
25+
.eggs/
26+
lib/
27+
lib64/
28+
parts/
29+
sdist/
30+
var/
31+
wheels/
32+
share/python-wheels/
33+
*.egg-info/
34+
.installed.cfg
35+
*.egg
36+
MANIFEST
37+
38+
# PyInstaller
39+
# Usually these files are written by a python script from a template
40+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
41+
*.manifest
42+
*.spec
43+
44+
# Installer logs
45+
pip-log.txt
46+
pip-delete-this-directory.txt
47+
48+
# Unit test / coverage reports
49+
htmlcov/
50+
.tox/
51+
.nox/
52+
.coverage
53+
.coverage.*
54+
.cache
55+
nosetests.xml
56+
coverage.xml
57+
*.cover
58+
*.py,cover
59+
.hypothesis/
60+
.pytest_cache/
61+
cover/
62+
63+
# Translations
64+
*.mo
65+
*.pot
66+
67+
# Django stuff:
68+
*.log
69+
local_settings.py
70+
db.sqlite3
71+
db.sqlite3-journal
72+
73+
# Flask stuff:
74+
instance/
75+
.webassets-cache
76+
77+
# Scrapy stuff:
78+
.scrapy
79+
80+
# Sphinx documentation
81+
docs/_build/
82+
83+
# PyBuilder
84+
.pybuilder/
85+
target/
86+
87+
# Jupyter Notebook
88+
.ipynb_checkpoints
89+
90+
# IPython
91+
profile_default/
92+
ipython_config.py
93+
94+
# pyenv
95+
# For a library or package, you might want to ignore these files since the code is
96+
# intended to run in multiple environments; otherwise, check them in:
97+
# .python-version
98+
99+
# pipenv
100+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
101+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
102+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
103+
# install all needed dependencies.
104+
#Pipfile.lock
105+
106+
# poetry
107+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
108+
# This is especially recommended for binary packages to ensure reproducibility, and is more
109+
# commonly ignored for libraries.
110+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
111+
#poetry.lock
112+
113+
# pdm
114+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
115+
#pdm.lock
116+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
117+
# in version control.
118+
# https://pdm.fming.dev/#use-with-ide
119+
.pdm.toml
120+
121+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
122+
__pypackages__/
123+
124+
# Celery stuff
125+
celerybeat-schedule
126+
celerybeat.pid
127+
128+
# SageMath parsed files
129+
*.sage.py
130+
131+
# Environments
132+
.env
133+
.venv
134+
env/
135+
venv/
136+
ENV/
137+
env.bak/
138+
venv.bak/
139+
140+
# Spyder project settings
141+
.spyderproject
142+
.spyproject
143+
144+
# Rope project settings
145+
.ropeproject
146+
147+
# mkdocs documentation
148+
/site
149+
150+
# mypy
151+
.mypy_cache/
152+
.dmypy.json
153+
dmypy.json
154+
155+
# Pyre type checker
156+
.pyre/
157+
158+
# pytype static type analyzer
159+
.pytype/
160+
161+
# Cython debug symbols
162+
cython_debug/
163+
164+
# PyCharm
165+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
166+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167+
# and can be added to the global gitignore or merged into this file. For a more nuclear
168+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
169+
#.idea/

BatchMake.py

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# -*- coding: utf-8 -*-
2+
import codecs
3+
import csv
4+
import os
5+
6+
import numpy as np
7+
8+
if __name__ == "__main__":
9+
10+
# os.chdir("Batch_Make")
11+
12+
time1 = 10
13+
time2 = 2
14+
15+
file_name = "angle_100"
16+
file_name2 = "angle_100"
17+
18+
# str_des_angle = '-36.88 24.47 50.87 -79.25 54.49 20.4'
19+
# str_des_angle = "38.55 25.87 47.36 77.0 53.21 -13.85"
20+
21+
# 保存してある関節角を読み込む
22+
robot_name = "B"
23+
cur_angle_deg = np.loadtxt(
24+
"./data/" + robot_name + "/current_angle.csv"
25+
).astype(np.float32)
26+
cur_angle_deg_str = cur_angle_deg.astype(str)
27+
str_des_angle = " ".join(cur_angle_deg_str)
28+
29+
# -----------------x_trainの取得-----------------
30+
angle = np.empty((0, 6), dtype=np.float32)
31+
with codecs.open(
32+
"data/" + robot_name + "/"+ file_name + ".csv", "r", "utf-8-sig"
33+
) as f: # ここが間違ってないか要確認
34+
angle_reader = csv.reader(f, delimiter=",")
35+
for row in angle_reader:
36+
row = np.expand_dims(row, axis=0)
37+
angle = np.append(angle, row, axis=0)
38+
f.close()
39+
40+
angle = angle.astype("float32")
41+
42+
os.chdir("../../../Batch/Kai/Calibration")
43+
44+
f = open("Calib_" + file_name2 + ".txt", "w")
45+
46+
f.write(",Get_Calib_Img,LABEL,,.exe\n")
47+
f.write(",ServoON,ServoON,0,.exe\n")
48+
f.write(",CameraON,StartCamera_Calib,NOWAIT,.exe\n")
49+
50+
# 初期位置から目標位置に移動する
51+
f.write("●,StartPos,FifthPolynomialRT,")
52+
f.write(str_des_angle + " ") # 目標位置を変更したらここを変更すること
53+
f.write(str(time1) + ",.exe\n")
54+
55+
for l in range(0, np.size(angle, axis=0)):
56+
57+
# 手先位置を微小移動させる
58+
f.write(",Move,FifthPolynomialRT,")
59+
60+
for k in range(0, 6):
61+
f.write("{0:f}".format(angle[l][k]) + " ")
62+
63+
f.write(str(time2) + ",.exe\n")
64+
f.write(",SaveImg,SaveImg_Calib,0,.exe\n")
65+
66+
f.write("●,Back2StartPos,FifthPolynomialRT,")
67+
f.write(str_des_angle + " ") # 目標位置を変更したらここを変更すること
68+
f.write(str(time2) + ",.exe\n")
69+
70+
f.write(",ServoOFF,ServoOFF,,.exe\n")
71+
f.write(",CameraOFF,EndCamera_Calib,NOWAIT,.exe")
72+
f.close()
73+
74+
print("OK\n")

CalcBetweenRobot.py

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import cv2
4+
import numpy as np
5+
import scipy.linalg
6+
7+
8+
class CalcBetweenRobot:
9+
def __init__(self):
10+
11+
self.T_cam2baseA = np.load("data/A/T_cam2base.npy")
12+
self.T_baseB2cam = np.load("data/B/T_base2cam.npy")
13+
14+
def get_T_B2A(self):
15+
16+
T_B2A = np.zeros((4, 4))
17+
18+
T_B2A = np.dot(self.T_cam2baseA, self.T_baseB2cam)
19+
20+
# T_B2A[0][2] = 0.0
21+
# T_B2A[1][2] = 0.0
22+
23+
# T_B2A[2][0] = 0.0
24+
# T_B2A[2][1] = 0.0
25+
# T_B2A[2][2] = 1.0
26+
# T_B2A[2][3] = 0.0
27+
28+
return T_B2A
29+
30+
def get_T_A2World(self, T_B2A):
31+
32+
T_World2A = np.zeros((4, 4))
33+
R = np.zeros((3, 3))
34+
35+
R = scipy.linalg.sqrtm(T_B2A[0:3, 0:3])
36+
37+
T_World2A[0:3, 0:3] = R.real
38+
39+
# T_World2A[2][2] = 1.0
40+
41+
T_World2A[0][3] = T_B2A[0][3] / 2
42+
T_World2A[1][3] = T_B2A[1][3] / 2
43+
T_World2A[2][3] = T_B2A[2][3] / 2
44+
T_World2A[3][3] = 1.0
45+
46+
return np.linalg.inv(T_World2A)
47+
48+
def get_T_B2World(self, T_B2A, T_A2World):
49+
50+
T_B2World = np.zeros((4, 4))
51+
52+
T_B2World = np.dot(T_A2World, T_B2A)
53+
54+
return T_B2World
55+
56+
def save_T(self, T_B2World, T_A2World):
57+
58+
np.save("data/T_baseB2world", T_B2World.real)
59+
np.save("data/T_baseA2world", T_A2World.real)
60+
61+
62+
def main():
63+
calc = CalcBetweenRobot()
64+
65+
T_B2A = calc.get_T_B2A()
66+
T_A2World = calc.get_T_A2World(T_B2A)
67+
T_B2World = calc.get_T_B2World(T_B2A, T_A2World)
68+
calc.save_T(T_B2World, T_A2World)
69+
70+
print(T_B2A)
71+
print(np.dot(np.linalg.inv(T_A2World), T_B2World))
72+
73+
print("fin!")
74+
75+
76+
if __name__ == "__main__":
77+
main()

0 commit comments

Comments
 (0)