Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Get position #53

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
20316f8
add camera
KANBE8810 Nov 5, 2021
6f178f5
change camera model
RikuYokoo Nov 7, 2021
cf5afc6
add camera controller
RikuYokoo Nov 7, 2021
ab9d804
保存機能の追加
KANBE8810 Nov 9, 2021
930036b
一時保存
KANBE8810 Dec 4, 2021
8548294
add super visor
RikuYokoo Dec 23, 2021
1dcb5b7
get the ball coordinates from the supervisor
RikuYokoo Dec 24, 2021
8e189ba
add get_position
yasuohayashibara Dec 26, 2021
01d81a8
get position
yasuohayashibara Dec 26, 2021
ce3a0fd
Merge branch 'pose_capture_test' into get_position
KANBE8810 Jan 2, 2022
984f9cf
ロボットの位置調整・カメラ追加
KANBE8810 Jan 3, 2022
0f71322
シュートコースのランダム化
KANBE8810 Jan 11, 2022
929ee8f
Obtain 3D coordinates to keypoints
KANBE8810 Apr 15, 2022
8ce8367
周期を揃えた
KANBE8810 Apr 25, 2022
cdd8bb1
Merge branch 'main' into get_position
KANBE8810 Apr 25, 2022
71b8981
Migrate annotation_keypoints to get_position
KANBE8810 May 18, 2022
0d3a9ed
annotation_keypointsを一部取り込み
KANBE8810 May 30, 2022
5efb5d9
2次元キーポイントが取得できるように対応
KANBE8810 Aug 18, 2022
7b25ef3
座標変換の追加,シュートコースの変更
KANBE8810 Aug 22, 2022
6f8b8b0
ボールの座標取得を追加
KANBE8810 Aug 25, 2022
5ca4478
キッカーのみに変更
KANBE8810 Aug 29, 2022
36ade05
座標取るタイミングを変更
KANBE8810 Aug 29, 2022
93129a0
斜めのキックができるように変更
KANBE8810 Sep 5, 2022
e527320
ワールドファイルの修正
KANBE8810 Sep 5, 2022
d605f2f
ファイル整理
KANBE8810 Nov 10, 2022
1b2fe80
15度-15度を追加
KANBE8810 Nov 26, 2022
229d976
add
KANBE8810 Nov 26, 2022
955e662
a
KANBE8810 Nov 28, 2022
a0330f0
fix
KANBE8810 Dec 5, 2022
c0ebddf
fix
KANBE8810 Dec 5, 2022
42f4cf9
bag fix
KANBE8810 Dec 6, 2022
d61bab4
add new world
KANBE8810 Dec 6, 2022
02890d0
fix
HirokiHasegawa777 Jan 9, 2023
6005248
add cross kick
HirokiHasegawa777 Feb 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ファイル整理
  • Loading branch information
KANBE8810 committed Nov 10, 2022
commit d605f2fe6f2b44b2f8eaae74baad823e08edd4e4
249 changes: 249 additions & 0 deletions controllers/get_position/all_fomat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
import shutil
from unittest import mock
import math
file_name = "test_file_left.txt"
file_name_end = "test_file_left_final.txt"
back_name = file_name + ".bak"

ball_file = "ball_pos_left.txt"
back_ball = ball_file + ".bak"


shutil.copy(file_name, back_name)

with open(file_name, encoding="cp932") as f:
data_lines = f.read()

# 文字列置換
data_lines = data_lines.replace("[", "")
data_lines = data_lines.replace("]", "")

# 同じファイル名で保存
with open(file_name, mode="w", encoding="cp932") as f:
f.write(data_lines)

import sys

mat = [] # 結果を入れるリスト(行列)
ans = [0,0,0]
cnt = -1 # どこのキーポイントか計測する用
with open(file_name, 'r', encoding='utf-8') as fin: # ファイルを開く
for line in fin.readlines(): # 行をすべて読み込んで1行ずつfor文で回
cnt += 1
if cnt == 12:
cnt = -1

row = [] # 行のデータを保存するリスト
toks = line.split(',') # 行をカンマで分割する
for tok in toks: # 分割したトークン列を回す
try:
num = float(tok) # 整数に変換
nn = 6 # 切り捨てしたい桁
num = math.floor(num * 10 ** nn) / (10 ** nn)
except ValueError:
print(e, file=sys.stderr) # エラーが出たら画面に出力して
continue # スキップ

row.append(num) # 行に保存

# row[0] = 4.5 - row[0]

if cnt == 1:
memo = row

if cnt == 2:
memo0 = row
ans[0] = memo[0] + memo0[0]
ans[1] = memo[1] + memo0[1]
ans[2] = memo[2] + memo0[2]
ans[0] /= 2
ans[1] /= 2
ans[2] /= 2
nn = 6
ans[0] = math.floor(ans[0] * 10 ** nn) / (10 ** nn)
ans[1] = math.floor(ans[1] * 10 ** nn) / (10 ** nn)
ans[2] = math.floor(ans[2] * 10 ** nn) / (10 ** nn)
row = ans
mat.append(row)
mat.append(memo0)
continue

mat.append(row) # 行をnumsに保存

with open(file_name, 'w') as f:
for d in mat:
f.write("%s\n" % d)

with open(file_name, encoding="cp932") as f:
data_lines = f.read()

# 文字列置換
data_lines = data_lines.replace("[", "")
data_lines = data_lines.replace("]", "")

# print(type(data_lines))

# 同じファイル名で保存
with open(file_name, mode="w", encoding="cp932") as f:
f.write(data_lines)
# print(mat) # 結果を出力

################################################

import math
import numpy as np

import shutil
from unittest import mock

shutil.copy(ball_file, back_ball)

with open(ball_file, encoding="cp932") as f:
data_lines = f.read()

# 文字列置換
data_lines = data_lines.replace("[", "")
data_lines = data_lines.replace("]", "")

# 同じファイル名で保存
with open(ball_file, mode="w", encoding="cp932") as f:
f.write(data_lines)

import sys

mat = [] # 結果を入れるリスト(行列)
ans = [0,0,0]
cnt = 0 # どこのキーポイントか計測する用

with open(ball_file, 'r', encoding='utf-8') as fin: # ファイルを開く
for line in fin.readlines(): # 行をすべて読み込んで1行ずつfor文で回
cnt += 1
cnt_check = cnt
cnt_check %= 2

row = [] # 行のデータを保存するリスト
toks = line.split(',') # 行をカンマで分割する
for tok in toks: # 分割したトークン列を回す
try:
num = float(tok) # 整数に変換
except ValueError:
print(e, file=sys.stderr) # エラーが出たら画面に出力して
continue # スキップ

row.append(num) # 行に保存
#2次元空間の場合
#角度の中心位置
x0,y0=3.0,0
#方向指定1
x1,y1=4.5,0
#方向指定2
x2=row[0]
y2=row[1]

#角度計算開始
vec1=[x1-x0,y1-y0]
vec2=[x2-x0,y2-y0]
absvec1=np.linalg.norm(vec1)
absvec2=np.linalg.norm(vec2)
inner=np.inner(vec1,vec2)
cos_theta=inner/(absvec1*absvec2)
theta=math.degrees(math.acos(cos_theta))
if row[1] < 0:
theta = theta * -1
#print('angle='+str(round(theta,2))+'deg')
mat.append(theta)


cnt = 0
with open(ball_file, 'w') as f:
for d in mat:
f.write("%s\n" % d)

################################3

import shutil
from unittest import mock
import sys

mat = [] # 結果を入れるリスト(行列)
ans = [0,0,0]
cnt = -1 # どこのキーポイントか計測する用
with open(file_name, 'r', encoding='utf-8') as fin: # ファイルを開く
for line in fin.readlines(): # 行をすべて読み込んで1行ずつfor文で回
cnt += 1
if cnt == 13:
cnt = -1

else:
line = line.replace("\n", ", ")

mat.append(line) # 行をnumsに保存

with open(file_name, 'w') as f:
for d in mat:
f.write("%s" % d)

with open(file_name, encoding="cp932") as f:
data_lines = f.read()

# 文字列置換
data_lines = data_lines.replace("[", "")
data_lines = data_lines.replace("]", "")

# 同じファイル名で保存
with open(file_name, mode="w", encoding="cp932") as f:
f.write(data_lines)

######################################
import shutil
from unittest import mock
import sys
import math

mat = [] # 結果を入れるリスト(行列)
cnt = 0
with open(ball_file, 'r', encoding='utf-8') as fin: # ファイルを開く
for line in fin.readlines(): # 行をすべて読み込んで1行ずつfor文で回す
row = [] # 行のデータを保存するリスト
num = float(line)

nn = 6 # 切り捨てしたい桁
num = math.floor(num * 10 ** nn) / (10 ** nn)

row.append(num) # 行に保存

mat.append(row) # 行をnumsに保存

n=0
line_cnt =-1
# for m in range(0,mat[n][1]):
with open(file_name_end,"w") as o:
with open(file_name, 'r', encoding='utf-8') as fin: # ファイルを開く
for line in fin.readlines(): # 行をすべて読み込んで1行ずつfor文で回
line_cnt +=1
if line_cnt == 70 and n < 49:
n+=1
line_cnt=-1
# print(n)
o.write("%s" % mat[n])
o.write(", ")
o.write("%s" % line)
# print(mat[m][0], sep=",", file=o)
# print(*line, file=o)


with open(file_name_end, encoding="cp932") as f:
data_lines = f.read()

# 文字列置換
data_lines = data_lines.replace("[", "")
data_lines = data_lines.replace("]", "")

# 同じファイル名で保存
with open(file_name_end, mode="w", encoding="cp932") as f:
f.write(data_lines)

back_name_end = file_name_end + ".bak"
shutil.copy(file_name_end, back_name_end)

print("end")
85 changes: 85 additions & 0 deletions controllers/get_position/fomat_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import shutil
from unittest import mock
import math
file_name = "test_file_right.txt"
back_name = file_name + ".bak"
shutil.copy(file_name, back_name)

with open(file_name, encoding="cp932") as f:
data_lines = f.read()

# 文字列置換
data_lines = data_lines.replace("[", "")
data_lines = data_lines.replace("]", "")

# print(type(data_lines))

# 同じファイル名で保存
with open(file_name, mode="w", encoding="cp932") as f:
f.write(data_lines)

import sys

mat = [] # 結果を入れるリスト(行列)
ans = [0,0,0]
cnt = -1 # どこのキーポイントか計測する用
with open(file_name, 'r', encoding='utf-8') as fin: # ファイルを開く
for line in fin.readlines(): # 行をすべて読み込んで1行ずつfor文で回
cnt += 1
if cnt == 12:
cnt = -1

row = [] # 行のデータを保存するリスト
toks = line.split(',') # 行をカンマで分割する
for tok in toks: # 分割したトークン列を回す
try:
num = float(tok) # 整数に変換
nn = 6 # 切り捨てしたい桁
num = math.floor(num * 10 ** nn) / (10 ** nn)
except ValueError:
print(e, file=sys.stderr) # エラーが出たら画面に出力して
continue # スキップ

row.append(num) # 行に保存

# row[0] = 4.5 - row[0]

if cnt == 1:
memo = row

if cnt == 2:
memo0 = row
ans[0] = memo[0] + memo0[0]
ans[1] = memo[1] + memo0[1]
ans[2] = memo[2] + memo0[2]
ans[0] /= 2
ans[1] /= 2
ans[2] /= 2
nn = 6
ans[0] = math.floor(ans[0] * 10 ** nn) / (10 ** nn)
ans[1] = math.floor(ans[1] * 10 ** nn) / (10 ** nn)
ans[2] = math.floor(ans[2] * 10 ** nn) / (10 ** nn)
row = ans
mat.append(row)
mat.append(memo0)
continue

mat.append(row) # 行をnumsに保存

with open('test_file_right2.txt', 'a') as f:
for d in mat:
f.write("%s\n" % d)

with open('test_file_right2.txt', encoding="cp932") as f:
data_lines = f.read()

# 文字列置換
data_lines = data_lines.replace("[", "")
data_lines = data_lines.replace("]", "")

# print(type(data_lines))

# 同じファイル名で保存
with open('test_file_right2.txt', mode="w", encoding="cp932") as f:
f.write(data_lines)
# print(mat) # 結果を出力
34 changes: 34 additions & 0 deletions controllers/get_position/fomat_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import shutil
from unittest import mock
file_name = "test_file_right2.txt"
import sys

mat = [] # 結果を入れるリスト(行列)
ans = [0,0,0]
cnt = -1 # どこのキーポイントか計測する用
with open(file_name, 'r', encoding='utf-8') as fin: # ファイルを開く
for line in fin.readlines(): # 行をすべて読み込んで1行ずつfor文で回
cnt += 1
if cnt == 13:
cnt = -1

else:
line = line.replace("\n", ", ")

mat.append(line) # 行をnumsに保存

with open('test_file_right3.txt', 'a') as f:
for d in mat:
f.write("%s" % d)

with open('test_file_right3.txt', encoding="cp932") as f:
data_lines = f.read()

# 文字列置換
data_lines = data_lines.replace("[", "")
data_lines = data_lines.replace("]", "")

# 同じファイル名で保存
with open('test_file_right3.txt', mode="w", encoding="cp932") as f:
f.write(data_lines)

Loading