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
2f692688
Commit
2f692688
authored
6 years ago
by
Sara Falcone
Browse files
Options
Downloads
Patches
Plain Diff
hella added DASHES! wit PERIMETER!
parent
e2f2d1a4
No related branches found
Branches containing commit
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
+33
-54
33 additions, 54 deletions
run-solleroot.py
with
33 additions
and
54 deletions
run-solleroot.py
+
33
−
54
View file @
2f692688
...
@@ -104,13 +104,16 @@ class RootDevice(gatt.Device):
...
@@ -104,13 +104,16 @@ class RootDevice(gatt.Device):
# save COLOR INFO to object for future use
# save COLOR INFO to object for future use
self
.
last_packet
=
new_data
self
.
last_packet
=
new_data
self
.
adjust_for_perimeter_if_needed
(
new_data
)
self
.
adjust_for_perimeter_if_needed
(
new_data
)
return
# If you're busy adjusting for perimeter,
# any senor data is used in that function and
# then no longer valid
if
type
==
"
Color Sensor
"
and
self
.
edge_following_enabled
:
if
type
==
"
Color Sensor
"
and
self
.
edge_following_enabled
:
print
(
"
new data - calling edge following
"
)
print
(
"
new data - calling edge following
"
)
self
.
follow_edge
(
new_data
)
self
.
follow_edge
(
new_data
)
if
type
==
"
Color Sensor
"
and
self
.
patterning_lines_enabled
:
##
el
if type == "Color Sensor" and self.patterning_lines_enabled:
print
(
"
new data - calling patterning
"
)
##
print("new data - calling patterning")
self
.
dash_count
(
self
.
dash_count
)
##
self.dash_count(self.dash_count)
self
.
pattern_dashes
(
new_data
,
self
.
dash_count
)
##
self.pattern_dashes(new_data)
def
adjust_for_perimeter_if_needed
(
self
,
message
):
def
adjust_for_perimeter_if_needed
(
self
,
message
):
...
@@ -123,9 +126,16 @@ class RootDevice(gatt.Device):
...
@@ -123,9 +126,16 @@ class RootDevice(gatt.Device):
for
i
in
range
(
3
,
18
):
for
i
in
range
(
3
,
18
):
if
message
[
i
]
in
color_red
:
if
message
[
i
]
in
color_red
:
n
+=
1
n
+=
1
if
n
<=
3
:
self
.
currently_adjusting_for_perimeter
=
False
self
.
drive_forward
()
return
if
not
self
.
currently_adjusting_for_perimeter
:
self
.
pen_up
()
self
.
currently_adjusting_for_perimeter
=
True
if
n
>
13
:
#number of sensors read the color
if
n
>
13
:
#number of sensors read the color
self
.
drive_backwards
()
self
.
drive_backwards
()
self
.
currently_adjusting_for_perimeter
=
True
print
(
"
in all colors are red - driving backwards
"
)
print
(
"
in all colors are red - driving backwards
"
)
return
return
n
=
0
n
=
0
...
@@ -134,7 +144,6 @@ class RootDevice(gatt.Device):
...
@@ -134,7 +144,6 @@ class RootDevice(gatt.Device):
n
+=
1
n
+=
1
if
n
>
3
:
if
n
>
3
:
self
.
steer
(
90
,
10
)
self
.
steer
(
90
,
10
)
self
.
currently_adjusting_for_perimeter
=
True
print
(
"
steering left
"
)
print
(
"
steering left
"
)
return
return
n
=
0
n
=
0
...
@@ -143,45 +152,24 @@ class RootDevice(gatt.Device):
...
@@ -143,45 +152,24 @@ class RootDevice(gatt.Device):
n
+=
1
n
+=
1
if
n
>
3
:
if
n
>
3
:
self
.
steer
(
10
,
90
)
self
.
steer
(
10
,
90
)
self
.
currently_adjusting_for_perimeter
=
True
print
(
"
steering right
"
)
print
(
"
steering right
"
)
return
return
print
(
"
OUT OF LOOP
"
)
if
self
.
currently_adjusting_for_perimeter
:
self
.
currently_adjusting_for_perimeter
=
False
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
:
if
(
self
.
dash_count
%
2
==
0
):
print
(
"
pen-down, driving
"
)
self
.
pen_down
()
self
.
drive_forward
()
return
else
:
print
(
"
pen up, drive forward
"
)
self
.
pen_up
()
self
.
drive_forward
()
return
if
self
.
patterning_lines_enabled
:
def
do_dash_movement
(
self
):
print
(
"
!!!!!!!!!!!!!!!!! turning patterning lines to FALSE
"
)
print
(
'
doin it
'
)
self
.
patterning_lines_enabled
=
False
threading
.
Timer
(
1.0
,
self
.
do_dash_movement
).
start
()
self
.
drive_forward
()
# if self.total_dash_count >= MAX_TOTAL_DASHES:
# return
if
self
.
currently_adjusting_for_perimeter
:
return
return
if
(
self
.
dash_count
%
2
==
0
):
print
(
"
pen-down, driving
"
)
self
.
pen_down
()
# self.total_dash_count += 1
else
:
print
(
"
pen up, drive forward
"
)
self
.
pen_up
()
self
.
dash_count
+=
1
def
follow_edge
(
self
,
message
):
def
follow_edge
(
self
,
message
):
...
@@ -268,7 +256,7 @@ class RootDevice(gatt.Device):
...
@@ -268,7 +256,7 @@ class RootDevice(gatt.Device):
def
drive_root
(
command
):
def
drive_root
(
command
):
angle
=
0
angle
=
0
last_packet
=
manager
.
robot
.
last_packet
##
last_packet = manager.robot.last_packet
if
command
==
"
f
"
:
if
command
==
"
f
"
:
print
(
"
Drive forward
"
)
print
(
"
Drive forward
"
)
...
@@ -308,20 +296,11 @@ def drive_root(command):
...
@@ -308,20 +296,11 @@ def drive_root(command):
if
command
==
"
edge
"
:
if
command
==
"
edge
"
:
print
(
"
edge
"
)
print
(
"
edge
"
)
manager
.
robot
.
edge_following_enabled
=
True
manager
.
robot
.
edge_following_enabled
=
True
manager
.
robot
.
follow_edge
(
last_packet
)
manager
.
robot
.
follow_edge
(
manager
.
robot
.
last_packet
)
if
command
==
"
pattern lines
"
:
if
command
==
"
pattern lines
"
:
print
(
"
pattern lines
"
)
print
(
"
pattern lines
"
)
manager
.
robot
.
drive_forward
()
## SOMETHING IS WRONG HERE CALLING THESE ATTRIBUTES
manager
.
robot
.
do_dash_movement
()
## 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
)
# start here if run as program / not imported as module
# start here if run as program / not imported as module
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
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