Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Robobin
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plw1g21
Robobin
Commits
b7185762
Commit
b7185762
authored
7 months ago
by
Darren0822
Browse files
Options
Downloads
Patches
Plain Diff
Update realtime_location_with_serial_gui.py
parent
a45d2263
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Wireless_Communication/UWB/Beacons_tag_position/realtime_location_with_serial_gui.py
+5
-8
5 additions, 8 deletions
...Beacons_tag_position/realtime_location_with_serial_gui.py
with
5 additions
and
8 deletions
Wireless_Communication/UWB/Beacons_tag_position/realtime_location_with_serial_gui.py
+
5
−
8
View file @
b7185762
...
@@ -186,9 +186,6 @@ class AnchorTagGUI:
...
@@ -186,9 +186,6 @@ class AnchorTagGUI:
try
:
try
:
measured_distances
=
[
var
.
get
()
for
var
in
self
.
measured_distances
]
measured_distances
=
[
var
.
get
()
for
var
in
self
.
measured_distances
]
measured_distances
=
np
.
array
(
measured_distances
)
measured_distances
=
np
.
array
(
measured_distances
)
noise_level
=
0.0
measured_distances_noisy
=
measured_distances
+
np
.
random
.
uniform
(
-
noise_level
,
noise_level
,
size
=
len
(
measured_distances
))
print
(
f
"
Measured distances:
{
measured_distances_noisy
}
"
)
# Automatically generate a reasonable initial guess
# Automatically generate a reasonable initial guess
def
generate_initial_guess
(
measured_distances
):
def
generate_initial_guess
(
measured_distances
):
y_A
=
measured_distances
[
2
]
# Distance from A to D
y_A
=
measured_distances
[
2
]
# Distance from A to D
...
@@ -226,8 +223,8 @@ class AnchorTagGUI:
...
@@ -226,8 +223,8 @@ class AnchorTagGUI:
return
lower_bound
,
upper_bound
return
lower_bound
,
upper_bound
# Generate the initial guess and bounds
# Generate the initial guess and bounds
initial_guess
=
generate_initial_guess
(
measured_distances
_noisy
)
initial_guess
=
generate_initial_guess
(
measured_distances
)
lower_bounds
,
upper_bounds
=
generate_bounds
(
measured_distances
_noisy
)
lower_bounds
,
upper_bounds
=
generate_bounds
(
measured_distances
)
def
error_function
(
variables
,
measured
):
def
error_function
(
variables
,
measured
):
x_B
,
y_B
,
x_C
,
y_C
,
y_A
=
variables
x_B
,
y_B
,
x_C
,
y_C
,
y_A
=
variables
...
@@ -267,7 +264,7 @@ class AnchorTagGUI:
...
@@ -267,7 +264,7 @@ class AnchorTagGUI:
result_noisy
=
least_squares
(
result_noisy
=
least_squares
(
error_function
,
error_function
,
initial_guess
,
initial_guess
,
args
=
(
measured_distances
_noisy
,),
args
=
(
measured_distances
,),
bounds
=
(
lower_bounds
,
upper_bounds
),
bounds
=
(
lower_bounds
,
upper_bounds
),
loss
=
'
soft_l1
'
loss
=
'
soft_l1
'
)
)
...
@@ -436,7 +433,7 @@ class AnchorTagGUI:
...
@@ -436,7 +433,7 @@ class AnchorTagGUI:
self
.
canvas
.
create_oval
(
self
.
canvas
.
create_oval
(
x_tag_scaled
-
5
,
y_tag_scaled
-
5
,
x_tag_scaled
+
5
,
y_tag_scaled
+
5
,
fill
=
"
orange
"
,
tags
=
"
tag1
"
x_tag_scaled
-
5
,
y_tag_scaled
-
5
,
x_tag_scaled
+
5
,
y_tag_scaled
+
5
,
fill
=
"
orange
"
,
tags
=
"
tag1
"
)
)
label
=
f
"
Tag 1(
{
round
(
tag1_x
,
2
)
}
,
{
round
(
tag1_y
,
2
)
}
{
tag1_z
:
.
2
f
}
)
"
label
=
f
"
Tag 1(
{
round
(
tag1_x
,
2
)
}
,
{
round
(
tag1_y
,
2
)
}
,
{
round
(
tag1_z
,
2
)
}
)
"
self
.
canvas
.
create_text
(
self
.
canvas
.
create_text
(
x_tag_scaled
+
15
,
y_tag_scaled
+
15
,
text
=
label
,
fill
=
"
black
"
x_tag_scaled
+
15
,
y_tag_scaled
+
15
,
text
=
label
,
fill
=
"
black
"
)
)
...
@@ -449,7 +446,7 @@ class AnchorTagGUI:
...
@@ -449,7 +446,7 @@ class AnchorTagGUI:
self
.
canvas
.
create_oval
(
self
.
canvas
.
create_oval
(
x_tag2_scaled
-
5
,
y_tag2_scaled
-
5
,
x_tag2_scaled
+
5
,
y_tag2_scaled
+
5
,
fill
=
"
green
"
,
tags
=
"
tag2
"
x_tag2_scaled
-
5
,
y_tag2_scaled
-
5
,
x_tag2_scaled
+
5
,
y_tag2_scaled
+
5
,
fill
=
"
green
"
,
tags
=
"
tag2
"
)
)
label
=
f
"
Tag 2(
{
round
(
tag2_x
,
2
)
}
,
{
round
(
tag2_y
,
2
)
}
{
tag2_z
:
.
2
f
}
)
"
label
=
f
"
Tag 2(
{
round
(
tag2_x
,
2
)
}
,
{
round
(
tag2_y
,
2
)
}
,
{
round
(
tag2_z
,
2
)
}
)
"
self
.
canvas
.
create_text
(
self
.
canvas
.
create_text
(
x_tag2_scaled
+
15
,
y_tag2_scaled
+
15
,
text
=
label
,
fill
=
"
black
"
x_tag2_scaled
+
15
,
y_tag2_scaled
+
15
,
text
=
label
,
fill
=
"
black
"
)
)
...
...
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