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
6e677221
Commit
6e677221
authored
6 years ago
by
Sara Falcone
Browse files
Options
Downloads
Patches
Plain Diff
still stuck in perimeter
parent
0f40efa4
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
+38
-30
38 additions, 30 deletions
run-solleroot.py
with
38 additions
and
30 deletions
run-solleroot.py
+
38
−
30
View file @
6e677221
...
@@ -86,18 +86,23 @@ class RootDevice(gatt.Device):
...
@@ -86,18 +86,23 @@ class RootDevice(gatt.Device):
if
new_data
[
0
]
==
DATA_TYPE_TOUCH
:
type
=
"
Touch Sensor
"
if
new_data
[
0
]
==
DATA_TYPE_TOUCH
:
type
=
"
Touch Sensor
"
if
new_data
[
0
]
==
DATA_TYPE_CLIFF
:
type
=
"
Cliff Sensor
"
if
new_data
[
0
]
==
DATA_TYPE_CLIFF
:
type
=
"
Cliff Sensor
"
print
(
"
{}: {}
"
.
format
(
type
,
new_data
))
print
(
"
{}: {}
"
.
format
(
type
,
new_data
))
# save COLOR INFO to object for future use
## #attempt to back out of cliff even
self
.
last_packet
=
new_data
## if new_data[0] == DATA_TYPE_CLIFF:
print
(
"
{}: {}
"
.
format
(
type
,
self
.
last_packet
))
## t_end = time.time() + 2
## while time.time() < t_end:
## self.drive_backwards()
## self.stop()
## print("end cliff event")
# Perimeter detect, then other color functions
# Perimeter detect, then other color functions
# check if you're at the perimeter every time there is new color data
# check if you're at the perimeter every time there is new color data
if
new_data
[
0
]
==
DATA_TYPE_COLOR_SENSOR
:
if
new_data
[
0
]
==
DATA_TYPE_COLOR_SENSOR
:
print
(
"
new data - calling perimeter
"
)
# save COLOR INFO to object for future use
self
.
last_packet
=
new_data
did_adjust
=
self
.
adjust_for_perimeter_if_needed
(
new_data
)
did_adjust
=
self
.
adjust_for_perimeter_if_needed
(
new_data
)
if
did_adjust
:
##
if did_adjust:
return
##
return
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
)
...
@@ -110,32 +115,35 @@ class RootDevice(gatt.Device):
...
@@ -110,32 +115,35 @@ class RootDevice(gatt.Device):
print
(
"
IN ADJUST PERIMETER
"
)
print
(
"
IN ADJUST PERIMETER
"
)
print
(
"
{}: {}
"
.
format
(
type
,
message
))
print
(
"
{}: {}
"
.
format
(
type
,
message
))
n
=
0
adjusted
=
False
# THERE ARE DRIVE LEFT AND DRIVE RIGHT COMMANDS!
# THERE ARE DRIVE LEFT AND DRIVE RIGHT COMMANDS!
if
all
(
message
)
in
color_black
:
if
all
(
message
)
in
color_red
:
drive_backwards
()
print
(
"
in all colors are red
"
)
adjusted
=
True
t_end
=
time
.
time
()
+
3
return
adjusted
while
time
.
time
()
<
t_end
:
for
i
in
range
(
3
,
7
):
drive_backwards
()
if
message
[
i
]
in
color_black
:
self
.
stop
()
time
.
sleep
(
1
)
n
=
0
for
i
in
range
(
3
,
8
):
if
message
[
i
]
in
color_red
:
n
+=
1
n
+=
1
if
n
>
3
:
if
n
>
3
:
self
.
turn_rate
(
-
30
)
t_end
=
time
.
time
()
+
3
self
.
drive_forward
()
while
time
.
time
()
<
t_end
:
adjusted
=
True
self
.
steer
(
60
,
20
)
return
adjusted
self
.
stop
()
time
.
sleep
(
1
)
n
=
0
n
=
0
for
i
in
range
(
1
4
,
18
):
for
i
in
range
(
1
3
,
18
):
if
message
[
i
]
in
color_
black
:
if
message
[
i
]
in
color_
red
:
n
+=
1
n
+=
1
if
n
>
3
:
if
n
>
3
:
self
.
turn_rate
(
30
)
t_end
=
time
.
time
()
+
3
self
.
drive_forward
()
while
time
.
time
()
<
t_end
:
adjusted
=
True
self
.
steer
(
20
,
60
)
return
adjusted
self
.
stop
()
return
adjusted
time
.
sleep
(
1
)
def
pattern_dashes
(
self
,
message
):
def
pattern_dashes
(
self
,
message
):
# pen down, pen up, so many times
# pen down, pen up, so many times
...
...
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