Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
asclinic-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Jiaao Liu
asclinic-system
Commits
82948ec9
Commit
82948ec9
authored
11 months ago
by
Jiaao Liu
Browse files
Options
Downloads
Patches
Plain Diff
fixed some bug on contours
parent
3800219b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
catkin_ws/src/asclinic_pkg/src/find_target2.py
+15
-11
15 additions, 11 deletions
catkin_ws/src/asclinic_pkg/src/find_target2.py
catkin_ws/src/asclinic_pkg/src/position_plotter.py
+2
-1
2 additions, 1 deletion
catkin_ws/src/asclinic_pkg/src/position_plotter.py
with
17 additions
and
12 deletions
catkin_ws/src/asclinic_pkg/src/find_target2.py
+
15
−
11
View file @
82948ec9
...
...
@@ -61,15 +61,16 @@ class TargetFinder:
self
.
servo_control
.
publish
(
msg
)
sleep
(
2
)
number
[
i
]
=
self
.
analysis
(
i
)
area_max
=
max
(
number
,
key
=
lambda
x
:
x
[
0
])
i
=
number
.
index
(
area_max
)
self
.
targets_xy
.
append
([
area_max
[
1
],
area_max
[
2
]])
msgn
=
ServoPulseWidth
(
channel
=
3
,
pulse_width_in_microseconds
=
self
.
angles
[
i
])
self
.
servo_control
.
publish
(
msgn
)
sleep
(
2
)
##Then take picture
self
.
save_picture_control
.
publish
(
UInt32
(
1
))
if
sum
(
map
(
lambda
x
:
x
[
0
],
number
))
!=
0
:
# Check if there is any non-zero area
area_max
=
max
(
number
,
key
=
lambda
x
:
x
[
0
])
i
=
number
.
index
(
area_max
)
self
.
targets_xy
.
append
([
area_max
[
1
],
area_max
[
2
]])
msgn
=
ServoPulseWidth
(
channel
=
3
,
pulse_width_in_microseconds
=
self
.
angles
[
i
])
self
.
servo_control
.
publish
(
msgn
)
sleep
(
2
)
# Then take picture
self
.
save_picture_control
.
publish
(
UInt32
(
1
))
#image_now = self.cv_image
#cv2.imshow("Image", image_now)
...
...
@@ -124,8 +125,11 @@ class TargetFinder:
else
:
contour_data
.
append
([
0
,
rx
,
ry
])
max_contour
=
max
(
contour_data
,
key
=
lambda
x
:
x
[
0
])
return
max_contour
if
contour_data
:
max_contour
=
max
(
contour_data
,
key
=
lambda
x
:
x
[
0
])
return
max_contour
return
[
0
,
0
,
0
]
def
calculate_coordinate
(
self
,
cx
,
cy
,
cphi
):
...
...
This diff is collapsed.
Click to expand it.
catkin_ws/src/asclinic_pkg/src/position_plotter.py
+
2
−
1
View file @
82948ec9
...
...
@@ -60,8 +60,9 @@ def main():
while
not
rospy
.
is_shutdown
():
ax
.
clear
()
ax
.
plot
(
x_data
,
y_data
,
'
b-
'
,
label
=
'
Path
'
)
ax
.
plot
(
ox
,
oy
,
'
ro
'
,
label
=
'
Obstacles
'
)
# Plot obstacles
ax
.
plot
(
x_data
,
y_data
,
'
b-
'
,
label
=
'
Path
'
)
ax
.
set_xlabel
(
'
X Position
'
)
ax
.
set_ylabel
(
'
Y Position
'
)
ax
.
set_title
(
'
Robot Position Plot
'
)
...
...
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