Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SolLeRoot
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
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
Sara Falcone
SolLeRoot
Commits
e2f2d1a4
Commit
e2f2d1a4
authored
6 years ago
by
Sara Falcone
Browse files
Options
Downloads
Patches
Plain Diff
patterning lines, something is still wrong calling method from drive_root
parent
3a2db5ae
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
run-solleroot.py
+37
-28
37 additions, 28 deletions
run-solleroot.py
with
37 additions
and
28 deletions
run-solleroot.py
+
37
−
28
View file @
e2f2d1a4
...
...
@@ -104,12 +104,13 @@ class RootDevice(gatt.Device):
# save COLOR INFO to object for future use
self
.
last_packet
=
new_data
self
.
adjust_for_perimeter_if_needed
(
new_data
)
## if type == "Color Sensor" and self.edge_following_enabled:
## print("new data - calling edge following")
## self.follow_edge(new_data)
## if type == "Color Sensor" and self.patterning_lines_enabled:
## self.pattern_dashes(new_data, self.dash_count)
if
type
==
"
Color Sensor
"
and
self
.
edge_following_enabled
:
print
(
"
new data - calling edge following
"
)
self
.
follow_edge
(
new_data
)
if
type
==
"
Color Sensor
"
and
self
.
patterning_lines_enabled
:
print
(
"
new data - calling patterning
"
)
self
.
dash_count
(
self
.
dash_count
)
self
.
pattern_dashes
(
new_data
,
self
.
dash_count
)
def
adjust_for_perimeter_if_needed
(
self
,
message
):
...
...
@@ -122,17 +123,15 @@ class RootDevice(gatt.Device):
for
i
in
range
(
3
,
18
):
if
message
[
i
]
in
color_red
:
n
+=
1
print
(
"
all - red
"
,
n
)
if
n
>
13
:
#number of sensors read the color
print
(
"
in all colors are red
"
)
self
.
drive_backwards
()
self
.
currently_adjusting_for_perimeter
=
True
print
(
"
in all colors are red - driving backwards
"
)
return
n
=
0
for
i
in
range
(
3
,
8
):
if
message
[
i
]
in
color_red
:
n
+=
1
print
(
"
all - left
"
,
n
)
if
n
>
3
:
self
.
steer
(
90
,
10
)
self
.
currently_adjusting_for_perimeter
=
True
...
...
@@ -142,9 +141,7 @@ class RootDevice(gatt.Device):
for
i
in
range
(
13
,
18
):
if
message
[
i
]
in
color_red
:
n
+=
1
print
(
"
all - right
"
,
n
)
if
n
>
3
:
print
(
"
in n > 3
"
)
self
.
steer
(
10
,
90
)
self
.
currently_adjusting_for_perimeter
=
True
print
(
"
steering right
"
)
...
...
@@ -152,33 +149,39 @@ class RootDevice(gatt.Device):
print
(
"
OUT OF LOOP
"
)
if
self
.
currently_adjusting_for_perimeter
:
self
.
currently_adjusting_for_perimeter
=
False
## self.stop()
self
.
drive_forward
()
return
# thread for counting time pen down/up
def
dash_count
(
self
,
count
):
print
(
"
IN DASH COUNT
"
)
threading
.
Timer
(
2.0
,
pattern_dashes
).
start
()
self
.
dash_count
+=
self
.
dash_count
print
(
"
incremented dash_count
"
)
def
pattern_dashes
(
self
,
message
,
count
):
print
(
"
IN PATTERN DASHES
"
)
# pen down, pen up, so many times
print
(
"
count:
"
,
count
)
num_dashes_wanted
=
4
if
count
<
num_dashes_wanted
:
self
.
pen_down
()
t_end
=
time
.
time
()
+
2
while
time
.
time
()
<
t_end
:
if
(
self
.
dash_count
%
2
==
0
):
print
(
"
pen-down, driving
"
)
self
.
pen_down
()
self
.
drive_forward
()
self
.
stop
()
print
(
"
pen-down, driving
"
)
self
.
pen_up
()
t_end
=
time
.
time
()
+
2
while
time
.
time
()
<
t_end
:
return
else
:
print
(
"
pen up, drive forward
"
)
self
.
pen_up
()
self
.
drive_forward
()
self
.
stop
()
print
(
"
pen up, drive forward
"
)
self
.
stop
()
else
:
return
if
self
.
patterning_lines_enabled
:
print
(
"
!!!!!!!!!!!!!!!!! turning patterning lines to FALSE
"
)
self
.
patterning_lines_enabled
=
False
self
.
dash_count
+=
self
.
dash_count
self
.
drive_forward
()
return
def
follow_edge
(
self
,
message
):
...
...
@@ -308,8 +311,14 @@ def drive_root(command):
manager
.
robot
.
follow_edge
(
last_packet
)
if
command
==
"
pattern lines
"
:
print
(
"
pattern lines
"
)
manager
.
robot
.
last_packet
=
0
dash_count
=
manager
.
robot
.
last_packet
## SOMETHING IS WRONG HERE CALLING THESE ATTRIBUTES
## manager.robot.last_packet = 0
## dash_count = self.dash_count(self.dash_count)
last_packet
=
manager
.
robot
.
last_packet
dash_count
=
manager
.
robot
.
dash_count
manager
.
robot
.
patterning_lines_enabled
=
True
manager
.
robot
.
pattern_dashes
(
last_packet
,
dash_count
)
...
...
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