Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
EMG analysis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ym13n22
EMG analysis
Commits
3401f780
Commit
3401f780
authored
10 months ago
by
ym13n22
Browse files
Options
Downloads
Patches
Plain Diff
set label,but many problems
parent
323b2c09
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
integration/integrate.py
+19
-20
19 additions, 20 deletions
integration/integrate.py
with
19 additions
and
20 deletions
integration/integrate.py
+
19
−
20
View file @
3401f780
...
@@ -2,7 +2,7 @@ import tkinter as tk
...
@@ -2,7 +2,7 @@ import tkinter as tk
from
tkinter
import
ttk
from
tkinter
import
ttk
from
matplotlib.pyplot
import
Figure
from
matplotlib.pyplot
import
Figure
from
vpython
import
*
from
vpython
import
*
from
time
import
sleep
,
time
from
time
import
time
import
serial
import
serial
from
math
import
atan2
,
asin
,
cos
,
sin
from
math
import
atan2
,
asin
,
cos
,
sin
...
@@ -55,10 +55,9 @@ class Interface:
...
@@ -55,10 +55,9 @@ class Interface:
label1
=
ttk
.
Label
(
frame2
,
text
=
"
If IMU is connected to the laptop please click the Connect button
"
,
label1
=
ttk
.
Label
(
frame2
,
text
=
"
If IMU is connected to the laptop please click the Connect button
"
,
wraplength
=
width
/
2
)
wraplength
=
width
/
2
)
label1
.
place
(
relx
=
0.5
,
rely
=
0.9
,
anchor
=
'
center
'
)
label1
.
place
(
relx
=
0.5
,
rely
=
0.9
,
anchor
=
'
center
'
)
label2
=
ttk
.
Label
(
frame2
,
text
=
"
Port: None
"
)
self
.
label2
=
ttk
.
Label
(
frame2
,
text
=
"
Port: None
"
)
label2
.
place
(
relx
=
0.35
,
rely
=
0.8
,
anchor
=
'
center
'
)
self
.
label2
.
place
(
relx
=
0.35
,
rely
=
0.8
,
anchor
=
'
center
'
)
frame2
.
update_idletasks
()
frame2
.
update_idletasks
()
#self._initialise_IUM()
# Second row, two sections
# Second row, two sections
frame3
=
ttk
.
Frame
(
popup
,
borderwidth
=
1
,
relief
=
"
solid
"
,
width
=
width
/
3
,
height
=
height
/
2
)
frame3
=
ttk
.
Frame
(
popup
,
borderwidth
=
1
,
relief
=
"
solid
"
,
width
=
width
/
3
,
height
=
height
/
2
)
...
@@ -90,23 +89,22 @@ class Interface:
...
@@ -90,23 +89,22 @@ class Interface:
def
IMU_Connect
(
self
):
def
IMU_Connect
(
self
):
try
:
try
:
self
.
_iMU_isConnected
=
True
self
.
arduino
=
serial
.
Serial
(
'
COM6
'
,
115200
,
timeout
=
1
)
self
.
arduino
=
serial
.
Serial
(
'
COM6
'
,
115200
,
timeout
=
1
)
column_limit
=
9
column_limit
=
9
label2
=
ttk
.
Label
(
frame2
,
text
=
"
Port: COM6
"
)
self
.
label2
=
ttk
.
Label
(
frame2
,
text
=
"
Port: COM6
"
)
label2
.
place
(
relx
=
0.35
,
rely
=
0.8
,
anchor
=
'
center
'
)
self
.
label2
.
place
(
relx
=
0.35
,
rely
=
0.8
,
anchor
=
'
center
'
)
print
(
"
Connected to IMU
"
)
print
(
"
Connected to IMU
"
)
except
serial
.
SerialException
:
except
serial
.
SerialException
:
print
(
"
IMU is not connected
"
)
print
(
"
IMU is not connected
"
)
return
return
sleep
(
1
)
sleep
(
1
)
# Conversions
scene
.
range
=
5
# 修改场景的范围为10
toRad
=
2
*
np
.
pi
/
360
scene
.
forward
=
vector
(
-
1
,
-
1
,
-
1
)
# 保持视角不变
toDeg
=
1
/
toRad
scene
.
width
=
300
# 修改场景的宽度为800
scene
.
height
=
300
# 修改场景的高度为800
scene
.
range
=
5
scene
.
center
=
vector
(
0
,
0
,
0
)
# 将场景中心位置调整为 (0, 0, 0)
scene
.
forward
=
vector
(
-
1
,
-
1
,
-
1
)
scene
.
width
=
600
scene
.
width
=
600
scene
.
height
=
600
scene
.
height
=
600
...
@@ -122,7 +120,7 @@ class Interface:
...
@@ -122,7 +120,7 @@ class Interface:
last_print_time
=
time
()
last_print_time
=
time
()
try
:
try
:
while
True
:
while
(
self
.
_iMU_isConnected
==
True
)
:
while
self
.
arduino
.
inWaiting
()
==
0
:
while
self
.
arduino
.
inWaiting
()
==
0
:
pass
pass
...
@@ -174,6 +172,7 @@ class Interface:
...
@@ -174,6 +172,7 @@ class Interface:
print
(
"
Disconnected from IMU
"
)
print
(
"
Disconnected from IMU
"
)
def
IMU_disconnect
(
self
):
def
IMU_disconnect
(
self
):
self
.
_iMU_isConnected
=
False
if
self
.
arduino
and
self
.
arduino
.
is_open
:
if
self
.
arduino
and
self
.
arduino
.
is_open
:
self
.
arduino
.
close
()
self
.
arduino
.
close
()
print
(
"
IMU disconnected
"
)
print
(
"
IMU disconnected
"
)
...
@@ -183,9 +182,9 @@ class Interface:
...
@@ -183,9 +182,9 @@ class Interface:
def
EMG_Connect
(
self
):
def
EMG_Connect
(
self
):
try
:
try
:
#
self.
arduino = serial.Serial('COM5', 115200, timeout=1)
self
.
_EMG_isConnected
=
True
label2
=
ttk
.
Label
(
frame3
,
text
=
"
Port: COM5
"
)
self
.
label2
=
ttk
.
Label
(
frame3
,
text
=
"
Port: COM5
"
)
label2
.
place
(
relx
=
0.35
,
rely
=
0.8
,
anchor
=
'
e
'
)
self
.
label2
.
place
(
relx
=
0.35
,
rely
=
0.8
,
anchor
=
'
e
'
)
label_EMG_title
=
ttk
.
Label
(
frame3
,
text
=
"
Auto Calibralian
"
,
font
=
(
"
Helvetica
"
,
16
))
label_EMG_title
=
ttk
.
Label
(
frame3
,
text
=
"
Auto Calibralian
"
,
font
=
(
"
Helvetica
"
,
16
))
label_EMG_title
.
place
(
relx
=
0.5
,
rely
=
0.1
,
anchor
=
'
center
'
)
label_EMG_title
.
place
(
relx
=
0.5
,
rely
=
0.1
,
anchor
=
'
center
'
)
label_EMG_Gesture
=
ttk
.
Label
(
frame3
,
text
=
"
Gesture :
"
,
font
=
(
"
Helvetica
"
,
13
))
label_EMG_Gesture
=
ttk
.
Label
(
frame3
,
text
=
"
Gesture :
"
,
font
=
(
"
Helvetica
"
,
13
))
...
@@ -199,20 +198,20 @@ class Interface:
...
@@ -199,20 +198,20 @@ class Interface:
return
return
def
EMG_disconnect
(
self
):
def
EMG_disconnect
(
self
):
if
self
.
_serial_data
.
configure
(
port
=
'
COM5
'
,
baudrate
=
9600
,
timeout
=
1
):
self
.
_EMG_isConnected
=
False
if
self
.
_serial_data
.
connected
==
True
:
self
.
_serial_data
.
disconnect
()
self
.
_serial_data
.
disconnect
()
print
(
"
EMG disconnected
"
)
print
(
"
EMG disconnected
"
)
def
start_data_collection
(
self
):
def
start_data_collection
(
self
):
print
(
"
Starting EMG data collection...
"
)
print
(
"
Starting EMG data collection...
"
)
try
:
try
:
while
True
:
while
(
self
.
_EMG_isConnected
==
True
)
:
emg_data
=
self
.
_serial_data
.
read
()
emg_data
=
self
.
_serial_data
.
read
()
if
emg_data
is
not
None
:
if
emg_data
is
not
None
:
print
(
f
"
EMG Value 1:
{
emg_data
[
0
]
}
, EMG Value 2:
{
emg_data
[
1
]
}
"
)
print
(
f
"
EMG Value 1:
{
emg_data
[
0
]
}
, EMG Value 2:
{
emg_data
[
1
]
}
"
)
else
:
else
:
print
(
"
Failed to read EMG data
"
)
print
(
"
Failed to read EMG data
"
)
time
.
sleep
(
0.1
)
# 控制读取频率
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
print
(
"
Stopping EMG data collection.
"
)
print
(
"
Stopping EMG data collection.
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment