Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
LSK_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
고다경
2020-06-19 02:26:10 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
25bc71f3e0690fddce972a3c4b4b3efcdf0bc119
25bc71f3
1 parent
86d77896
트레이너 속도 조절
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
212 additions
and
252 deletions
sourcecode/capstone/Assets/Scenes/humanoid.unity
sourcecode/capstone/Assets/Script/Move.cs
sourcecode/capstone/Assets/Scenes/humanoid.unity
View file @
25bc71f
...
...
@@ -2141,7 +2141,7 @@ MonoBehaviour:
SideHighKick_Instruction
:
{
fileID
:
1616699126
}
Lunge_Left_Instruction
:
{
fileID
:
1914474766
}
Lunge_Right_Instruction
:
{
fileID
:
1540314533
}
Right_Start
:
{
fileID
:
0
}
Right_Start
:
{
fileID
:
779933557
}
---
!u!4
&1461362268
Transform
:
m_ObjectHideFlags
:
0
...
...
sourcecode/capstone/Assets/Script/Move.cs
View file @
25bc71f
...
...
@@ -44,7 +44,7 @@ public class Move : MonoBehaviour
public
bool
trainer_check_outside
=
true
;
public
float
trainer_timer
=
0
;
public
bool
trainer_other_side
=
false
;
public
int
trainer_speed
=
5
;
public
int
trainer_speed
=
0
;
//lsy end
public
Text
AngleLeftKnee
;
...
...
@@ -149,7 +149,7 @@ public class Move : MonoBehaviour
{
Lunge_Right_Instruction
.
SetActive
(
false
);
trainer_speed
=
8
;
trainer_speed
=
7
;
trainer_count
=
0
;
lines
=
lines_right
;
trainer_other_side
=
true
;
...
...
@@ -242,7 +242,7 @@ public class Move : MonoBehaviour
//lsy end
exercise
=
ClickExercise
.
selected_exercise
;
//ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴.
exercise
=
"
Squat
"
;
exercise
=
"
Lunge
"
;
Debug
.
Log
(
exercise
);
//Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기
if
(
exercise
==
"Squat"
)
...
...
@@ -258,7 +258,6 @@ public class Move : MonoBehaviour
}
else
if
(
exercise
==
"Lunge"
)
{
trainer_speed
=
5
;
lines
=
File
.
ReadAllLines
(
@"Trainer_txt/runzi_right.txt"
);
lines_right
=
File
.
ReadAllLines
(
@"Trainer_txt/runzi_left.txt"
);
Debug
.
Log
(
"읽음"
);
...
...
@@ -364,47 +363,21 @@ public class Move : MonoBehaviour
count1
.
SetActive
(
false
);
ex_start
.
SetActive
(
true
);
HipBalance1
.
SetActive
(
false
);
PullHipBack2
.
SetActive
(
false
);
LegUp3
.
SetActive
(
false
);
SpineStraight4
.
SetActive
(
false
);
Great5
.
SetActive
(
false
);
KneeDown6
.
SetActive
(
false
);
}
else
if
(
timer
<
5
)
{
count3
.
SetActive
(
false
);
count2
.
SetActive
(
true
);
count1
.
SetActive
(
false
);
ex_start
.
SetActive
(
true
);
HipBalance1
.
SetActive
(
false
);
PullHipBack2
.
SetActive
(
false
);
LegUp3
.
SetActive
(
false
);
SpineStraight4
.
SetActive
(
false
);
Great5
.
SetActive
(
false
);
KneeDown6
.
SetActive
(
false
);
}
else
if
(
timer
<
6
)
{
count3
.
SetActive
(
false
);
count2
.
SetActive
(
false
);
count1
.
SetActive
(
true
);
ex_start
.
SetActive
(
true
);
HipBalance1
.
SetActive
(
false
);
PullHipBack2
.
SetActive
(
false
);
LegUp3
.
SetActive
(
false
);
SpineStraight4
.
SetActive
(
false
);
Great5
.
SetActive
(
false
);
KneeDown6
.
SetActive
(
false
);
}
else
{
count3
.
SetActive
(
false
);
count2
.
SetActive
(
false
);
count1
.
SetActive
(
false
);
ex_start
.
SetActive
(
false
);
...
...
@@ -417,19 +390,6 @@ public class Move : MonoBehaviour
}
//lsy end
IfSpineIsStraight
.
text
=
"허리를 곧게: Tracking"
;
HipBalance
.
text
=
"양쪽 힙 균형: Calculating"
;
AngleLeftKnee
.
text
=
""
;
AngleRightKnee
.
text
=
""
;
KneeToeLeft
.
text
=
""
;
KneeToeRight
.
text
=
""
;
LeftLegUp
.
text
=
"왼쪽 다리 들어올린 각도: Tracking"
;
RightLegUp
.
text
=
"오른쪽 다리 들어올린 각도: Tracking"
;
PullHipBack
.
text
=
""
;
Great
.
text
=
""
;
float
[]
data1
=
new
float
[
bodyCount
*
jointCount
*
3
];
int
[]
state
=
new
int
[
bodyCount
*
jointCount
];
int
[]
id
=
new
int
[
bodyCount
];
...
...
@@ -539,257 +499,257 @@ public class Move : MonoBehaviour
Kinect
.
Joint
sourceJoint
=
body
.
Joints
[
jt
];
Kinect
.
Joint
?
targetJoint
=
null
;
///////////////////////////
Angles
MyAngles
=
new
Angles
();
byte
[]
ReadAngles
=
MyAngles
.
GetVector
(
body
);
if
(
exercise
==
"Squat"
)
if
(
_BoneMap
.
ContainsKey
(
jt
)
)
{
if
(
ReadAngles
[
1
]
-
ReadAngles
[
2
]
<=
5
)
{
hipbal
=
""
;
//hipbal = "양쪽 균형이 잡혀있습니다.";
HipBalance1
.
SetActive
(
false
);
}
else
{
hipbal
=
"양쪽 힘이 동일하지 않습니다. \n균형을 잡으세요!"
;
HipBalance1
.
SetActive
(
true
);
}
targetJoint
=
body
.
Joints
[
_BoneMap
[
jt
]];
}
Transform
jointObj
=
bodyObject
.
transform
.
Find
(
jt
.
ToString
());
jointObj
.
localPosition
=
GetVector3FromJoint
(
sourceJoint
);
if
(
ReadAngles
[
5
]
>
95
||
ReadAngles
[
6
]
>
95
)
{
pullhipback
=
"엉덩이를 뒤로 더 빼세요!"
;
PullHipBack2
.
SetActive
(
true
);
}
else
{
PullHipBack2
.
SetActive
(
false
);
}
//Debug.Log(i);
if
(
ReadAngles
[
3
]
<
95
&&
ReadAngles
[
4
]
<
95
)
{
great
=
"GREAT!"
;
//Debug.Log(ReadAngles[3])
;
Great5
.
SetActive
(
true
)
;
}
else
{
great
=
""
;
Great5
.
SetActive
(
false
);
}
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
X
;
i
++
;
data1
[
i
]
=
sourceJoint
.
Position
.
Y
;
i
++
;
data1
[
i
]
=
sourceJoint
.
Position
.
Z
;
if
((
sourceJoint
.
Position
.
X
+
sourceJoint
.
Position
.
Y
+
sourceJoint
.
Position
.
Z
)
!=
0
)
{
state
[
i
-
2
]
=
1
;
}
skeleton_Trainnne
.
dasomset
(
data1
,
state
,
0
,
true
,
true
,
body
.
Joints
[
jt
],
jointObj
);
////////////운동 횟수 카운트//////////////////////
if
(
ReadAngles
[
3
]
<
95
&&
ReadAngles
[
4
]
<
95
&&
workout
&&
workout_flag
>=
95
&&
workout_flag2
>=
95
)
{
Trainee_Count
();
}
else
{
workout_flag
=
ReadAngles
[
3
];
workout_flag2
=
ReadAngles
[
4
];
workout
=
true
;
}
/*
LineRenderer lr = jointObj.GetComponent<LineRenderer>();
if (targetJoint.HasValue)
{
//Debug.Log(jointObj.localPosition);
//Debug.Log(GetVector3FromJoint(targetJoint.Value));
lr.SetPosition(0, jointObj.localPosition);
lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value));
lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState));
}
else
{
lr.enabled = false;
}
*/
}
///////////////////////////
Angles
MyAngles
=
new
Angles
();
byte
[]
ReadAngles
=
MyAngles
.
GetVector
(
body
);
if
(
exercise
==
"Squat"
)
{
if
(
ReadAngles
[
1
]
-
ReadAngles
[
2
]
<=
5
)
{
HipBalance1
.
SetActive
(
false
);
}
else
if
(
exercise
==
"SideHiKick"
)
else
{
if
((
ReadAngles
[
7
]
<
45
)
&&
(
ReadAngles
[
7
]
>
10
)
&&
(
sidehk_flag
<
ReadAngles
[
7
]))
{
LegUp3
.
SetActive
(
true
);
//다리를 더 높이 들어올리세요
Great5
.
SetActive
(
false
);
//"양쪽 힘이 동일하지 않습니다. \n균형을 잡으세요!";
HipBalance1
.
SetActive
(
true
);
}
}
else
{
LegUp3
.
SetActive
(
false
);
Great5
.
SetActive
(
false
);
if
(
ReadAngles
[
5
]
>
95
||
ReadAngles
[
6
]
>
95
)
{
//"엉덩이를 뒤로 더 빼세요!";
PullHipBack2
.
SetActive
(
true
);
}
else
{
PullHipBack2
.
SetActive
(
false
);
}
if
(
ReadAngles
[
3
]
<
95
&&
ReadAngles
[
4
]
<
95
)
{
Great5
.
SetActive
(
true
);
}
else
{
great
=
""
;
Great5
.
SetActive
(
false
);
}
////////////운동 횟수 카운트//////////////////////
if
(
ReadAngles
[
3
]
<
95
&&
ReadAngles
[
4
]
<
95
&&
workout
&&
workout_flag
>=
95
&&
workout_flag2
>=
95
)
{
Trainee_Count
();
}
else
{
workout_flag
=
ReadAngles
[
3
];
workout_flag2
=
ReadAngles
[
4
];
workout
=
true
;
}
}
else
if
(
exercise
==
"SideHiKick"
)
{
if
((
ReadAngles
[
7
]
<
45
)
&&
(
ReadAngles
[
7
]
>
10
)
&&
(
sidehk_flag
<
ReadAngles
[
7
]))
{
LegUp3
.
SetActive
(
true
);
//다리를 더 높이 들어올리세요
Great5
.
SetActive
(
false
);
}
else
{
LegUp3
.
SetActive
(
false
);
Great5
.
SetActive
(
false
);
//이전각도
sidehk_flag
=
ReadAngles
[
7
];
}
if
(
ReadAngles
[
7
]
>=
45
)
{
Great5
.
SetActive
(
true
);
//Great
}
else
{
Great5
.
SetActive
(
false
);
}
////////운동 횟수 카운트////////////////////
if
(
ReadAngles
[
7
]
>
45
&&
workout
&&
workout_flag
<=
45
)
{
Trainee_Count
();
}
else
{
workout_flag
=
ReadAngles
[
7
];
workout
=
true
;
}
//이전각도
sidehk_flag
=
ReadAngles
[
7
];
}
if
(
ReadAngles
[
7
]
>=
45
)
}
else
if
(
exercise
==
"Lunge"
)
{
if
(
workout_count
<
10
)
{
if
(
flag
==
0
)
{
Great5
.
SetActive
(
true
);
//Great
if
(
lunge_flag_l
<
120
&&
ReadAngles
[
3
]
>=
91
&&
lunge_flag_l
>
ReadAngles
[
3
])
{
great
=
""
;
//Great5.SetActive(false);
KneeDown6
.
SetActive
(
true
);
//무릎을 더 굽혀주세요.
flag
=
1
;
}
else
if
(
ReadAngles
[
3
]
<
91
)
{
great
=
"GREAT!"
;
Great5
.
SetActive
(
true
);
//KneeDown6.SetActive(false);
flag
=
1
;
}
}
else
{
Great5
.
SetActive
(
false
);
flag_timer
+=
Time
.
deltaTime
;
//Debug.Log(flag_timer);
if
(
flag_timer
>
5
)
{
flag
=
0
;
flag_timer
=
0
;
Debug
.
Log
(
"5초넘음"
);
Great5
.
SetActive
(
false
);
KneeDown6
.
SetActive
(
false
);
}
}
////////운동 횟수 카운트////////////////////
if
(
ReadAngles
[
7
]
>
45
&&
workout
&&
workout_flag
<=
45
)
//////////////운동 횟수 카운트//////////////////
//왼쪽
if
(
ReadAngles
[
3
]
<
95
&&
workout
&&
workout_flag
>=
95
)
{
Trainee_Count
();
}
else
{
workout_flag
=
ReadAngles
[
7
];
workout_flag
=
ReadAngles
[
3
];
workout
=
true
;
}
}
else
if
(
exercise
==
"Lunge"
)
else
{
if
(
workout_count
<
1
0
)
if
(
flag
==
0
)
{
if
(
flag
==
0
)
if
(
lunge_flag_r
<
120
&&
ReadAngles
[
4
]
>=
91
&&
lunge_flag_r
>
ReadAngles
[
4
]
)
{
if
(
lunge_flag_l
<
120
&&
ReadAngles
[
3
]
>=
91
&&
lunge_flag_l
>
ReadAngles
[
3
])
{
great
=
""
;
//Great5.SetActive(false);
KneeDown6
.
SetActive
(
true
);
//무릎을 더 굽혀주세요.
flag
=
1
;
}
else
if
(
ReadAngles
[
3
]
<
91
)
{
great
=
"GREAT!"
;
Great5
.
SetActive
(
true
);
//KneeDown6.SetActive(false);
flag
=
1
;
}
}
else
{
flag_timer
+=
Time
.
deltaTime
;
//Debug.Log(flag_timer);
if
(
flag_timer
>
50
)
{
flag
=
0
;
flag_timer
=
0
;
Debug
.
Log
(
"5초넘음"
);
Great5
.
SetActive
(
false
);
KneeDown6
.
SetActive
(
false
);
}
}
great
=
""
;
//Great5.SetActive(false);
KneeDown6
.
SetActive
(
true
);
//무릎을 더 굽혀주세요.
flag
=
1
;
//////////////운동 횟수 카운트//////////////////
//왼쪽
if
(
ReadAngles
[
3
]
<
95
&&
workout
&&
workout_flag
>=
95
)
{
Trainee_Count
();
}
else
{
workout_flag
=
ReadAngles
[
3
];
workout
=
true
;
}
}
else
{
if
(
flag
==
0
)
{
if
(
lunge_flag_r
<
120
&&
ReadAngles
[
4
]
>=
91
&&
lunge_flag_r
>
ReadAngles
[
4
])
{
great
=
""
;
//Great5.SetActive(false);
KneeDown6
.
SetActive
(
true
);
//무릎을 더 굽혀주세요.
flag
=
1
;
}
else
if
(
ReadAngles
[
4
]
<
91
)
{
great
=
"GREAT!"
;
Great5
.
SetActive
(
true
);
//KneeDown6.SetActive(false);
flag
=
1
;
}
}
else
else
if
(
ReadAngles
[
4
]
<
91
)
{
great
=
"GREAT!"
;
Great5
.
SetActive
(
true
);
//KneeDown6.SetActive(false);
flag_timer
+=
Time
.
deltaTime
;
//Debug.Log(flag_timer);
if
(
flag_timer
>
50
)
{
flag
=
0
;
flag_timer
=
0
;
Debug
.
Log
(
"5초넘음"
);
Great5
.
SetActive
(
false
);
KneeDown6
.
SetActive
(
false
);
}
flag
=
1
;
}
}
else
{
//////////////운동 횟수 카운트//////////////////
//
오른쪽
if
(
workout_count
>=
10
&&
ReadAngles
[
4
]
<
95
&&
workout
&&
workout_flag
>=
9
5
)
flag_timer
+=
Time
.
deltaTime
;
//
Debug.Log(flag_timer);
if
(
flag_timer
>
5
)
{
Trainee_Count
()
;
}
else
{
workout_flag
=
ReadAngles
[
4
]
;
workout
=
true
;
flag
=
0
;
flag_timer
=
0
;
Debug
.
Log
(
"5초넘음"
);
Great5
.
SetActive
(
false
)
;
KneeDown6
.
SetActive
(
false
)
;
}
}
lunge_flag_l
=
ReadAngles
[
3
];
lunge_flag_r
=
ReadAngles
[
4
];
}
//공통된 사항
if
(
ReadAngles
[
0
]
<
170
||
ReadAngles
[
0
]
>
190
)
{
spinestraight
=
"허리를 곧게 펴세요!"
;
SpineStraight4
.
SetActive
(
true
);
}
else
{
spinestraight
=
""
;
SpineStraight4
.
SetActive
(
false
);
}
///////////////////////////
if
(
_BoneMap
.
ContainsKey
(
jt
))
{
targetJoint
=
body
.
Joints
[
_BoneMap
[
jt
]];
//////////////운동 횟수 카운트//////////////////
//오른쪽
if
(
workout_count
>=
10
&&
ReadAngles
[
4
]
<
95
&&
workout
&&
workout_flag
>=
95
)
{
Trainee_Count
();
}
else
{
workout_flag
=
ReadAngles
[
4
];
workout
=
true
;
}
}
Transform
jointObj
=
bodyObject
.
transform
.
Find
(
jt
.
ToString
());
jointObj
.
localPosition
=
GetVector3FromJoint
(
sourceJoint
);
//Debug.Log(i);
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
X
;
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
Y
;
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
Z
;
if
((
sourceJoint
.
Position
.
X
+
sourceJoint
.
Position
.
Y
+
sourceJoint
.
Position
.
Z
)
!=
0
)
{
state
[
i
-
2
]
=
1
;
}
skeleton_Trainnne
.
dasomset
(
data1
,
state
,
0
,
true
,
true
,
body
.
Joints
[
jt
],
jointObj
);
lunge_flag_l
=
ReadAngles
[
3
];
lunge_flag_r
=
ReadAngles
[
4
];
}
/*
LineRenderer lr = jointObj.GetComponent<LineRenderer>();
if (targetJoint.HasValue)
{
//Debug.Log(jointObj.localPosition);
//Debug.Log(GetVector3FromJoint(targetJoint.Value));
lr.SetPosition(0, jointObj.localPosition);
lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value));
lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState));
}
else
{
lr.enabled = false;
}
*/
//공통된 사항
if
(
ReadAngles
[
0
]
<
170
||
ReadAngles
[
0
]
>
190
)
{
spinestraight
=
"허리를 곧게 펴세요!"
;
SpineStraight4
.
SetActive
(
true
);
}
else
{
spinestraight
=
""
;
SpineStraight4
.
SetActive
(
false
);
}
///////////////////////////
}
private
static
Color
GetColorForState
(
Kinect
.
TrackingState
state
)
...
...
Please
register
or
login
to post a comment