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
5f650672
Commit
5f650672
authored
6 years ago
by
Sara Falcone
Browse files
Options
Downloads
Patches
Plain Diff
working in edge follwing - BUGS
parent
2f692688
No related branches found
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
run-solleroot.py
+40
-52
40 additions, 52 deletions
run-solleroot.py
time-test.py
+19
-3
19 additions, 3 deletions
time-test.py
with
59 additions
and
55 deletions
run-solleroot.py
+
40
−
52
View file @
5f650672
# python3
# python3
import
gatt
import
gatt
import
threading
import
threading
import
time
##
import time
# BLE UUID's
# BLE UUID's
root_identifier_uuid
=
'
48c5d828-ac2a-442d-97a3-0c9822b04979
'
root_identifier_uuid
=
'
48c5d828-ac2a-442d-97a3-0c9822b04979
'
...
@@ -17,10 +17,14 @@ DATA_TYPE_TOUCH = 17
...
@@ -17,10 +17,14 @@ DATA_TYPE_TOUCH = 17
DATA_TYPE_CLIFF
=
20
DATA_TYPE_CLIFF
=
20
# color classifications
# color classifications
color_black
=
[
17
,
68
,
65
,
20
,
49
,
67
,
52
]
color_black
=
[
17
,
68
,
65
,
20
,
49
,
67
,
52
,
16
,
1
]
color_red
=
[
34
,
2
,
32
]
color_red
=
[
34
,
2
,
32
,
33
,
18
]
color_green
=
[
51
,
48
,
3
]
color_green
=
[
51
,
48
,
3
]
color_blue
=
[
4
,
64
,
68
]
color_blue
=
[
4
,
64
,
68
]
# uncategorized
# color_white = [0,
# 33, 18
class
BluetoothDeviceManager
(
gatt
.
DeviceManager
):
class
BluetoothDeviceManager
(
gatt
.
DeviceManager
):
robot
=
None
# root robot device
robot
=
None
# root robot device
...
@@ -110,17 +114,12 @@ class RootDevice(gatt.Device):
...
@@ -110,17 +114,12 @@ class RootDevice(gatt.Device):
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
)
## elif type == "Color Sensor" and self.patterning_lines_enabled:
## print("new data - calling patterning")
## self.dash_count(self.dash_count)
## self.pattern_dashes(new_data)
def
adjust_for_perimeter_if_needed
(
self
,
message
):
def
adjust_for_perimeter_if_needed
(
self
,
message
):
# Check to see if you're at perimeter!
# Check to see if you're at perimeter!
# If you are, turn and update your state
# If you are, turn and update your state
print
(
"
IN ADJUST PERIMETER
"
)
##
print("IN ADJUST PERIMETER")
print
(
"
{}: {}
"
.
format
(
type
,
message
))
##
print("{}: {}".format(type, message))
n
=
0
n
=
0
for
i
in
range
(
3
,
18
):
for
i
in
range
(
3
,
18
):
...
@@ -131,7 +130,7 @@ class RootDevice(gatt.Device):
...
@@ -131,7 +130,7 @@ class RootDevice(gatt.Device):
self
.
drive_forward
()
self
.
drive_forward
()
return
return
if
not
self
.
currently_adjusting_for_perimeter
:
if
not
self
.
currently_adjusting_for_perimeter
:
self
.
pen_up
()
##
self.pen_up()
self
.
currently_adjusting_for_perimeter
=
True
self
.
currently_adjusting_for_perimeter
=
True
if
n
>
13
:
#number of sensors read the color
if
n
>
13
:
#number of sensors read the color
...
@@ -156,12 +155,9 @@ class RootDevice(gatt.Device):
...
@@ -156,12 +155,9 @@ class RootDevice(gatt.Device):
return
return
def
do_dash_movement
(
self
):
def
do_dash_movement
(
self
):
print
(
'
doin it
'
)
threading
.
Timer
(
1.0
,
self
.
do_dash_movement
).
start
()
threading
.
Timer
(
1.0
,
self
.
do_dash_movement
).
start
()
# if self.total_dash_count >= MAX_TOTAL_DASHES:
# if self.total_dash_count >= MAX_TOTAL_DASHES:
# return
# return
if
self
.
currently_adjusting_for_perimeter
:
return
if
(
self
.
dash_count
%
2
==
0
):
if
(
self
.
dash_count
%
2
==
0
):
print
(
"
pen-down, driving
"
)
print
(
"
pen-down, driving
"
)
self
.
pen_down
()
self
.
pen_down
()
...
@@ -174,44 +170,36 @@ class RootDevice(gatt.Device):
...
@@ -174,44 +170,36 @@ class RootDevice(gatt.Device):
def
follow_edge
(
self
,
message
):
def
follow_edge
(
self
,
message
):
print
(
"
IN FOLLOW EDGE
"
)
print
(
"
IN FOLLOW EDGE
"
)
if
message
[
3
]
!=
0
or
message
[
4
]
!=
0
:
#drive_root("l")
n
=
0
self
.
turn_rate
(
-
45
)
for
i
in
range
(
9
,
12
)
#manager.robot.drive_left_slow()
if
message
[
i
]
in
color_black
:
#drive_root("z")
n
+=
1
turn_state
=
1
if
n
>
1
elif
message
[
5
]
!=
0
or
message
[
6
]
!=
0
:
self
.
drive_forward
:
#drive_root("l")
return
self
.
turn_rate
(
-
30
)
#manager.robot.drive_left_slow_slow()
#drive_root("x")
turn_state
=
1
#drive_root("f")
#print("test1")
elif
message
[
7
]
!=
0
or
message
[
8
]
!=
0
:
#drive_root("f") # calling the member function versus out into global space
self
.
drive_forward
()
elif
message
[
9
]
!=
0
or
message
[
10
]
!=
0
:
self
.
turn_rate
(
30
)
elif
message
[
12
]
!=
0
or
message
[
11
]
!=
0
:
left_n
=
0
self
.
turn_rate
(
45
)
for
i
in
range
(
3
,
8
):
elif
message
[
14
]
!=
0
or
message
[
13
]
!=
0
:
if
message
[
i
]
in
color_black
:
#drive_root("r")
left_n
+=
1
self
.
turn_rate
(
60
)
right_n
=
0
#manager.robot.drive_right_slow_slow()
for
i
in
range
(
13
,
18
):
#drive_root("c")
if
message
[
i
]
in
color_black
:
turn_state
=
2
right_n
+=
1
#drive_root("f")
if
left_n
>
21
and
right_n
>
1
:
#print("test2")
self
.
drive_forward
()
elif
message
[
16
]
!=
0
or
message
[
15
]
!=
0
:
return
#drive_root("r")
if
left_n
>
1
:
self
.
turn_rate
(
60
)
self
.
steer
(
70
,
10
)
#manager.robot.drive_right_slow()
print
(
"
steering left
"
)
#drive_root("v")
return
turn_state
=
2
if
right_n
>
1
:
else
:
self
.
steer
(
10
,
70
)
self
.
drive_forward
()
print
(
"
steering right
"
)
return
self
.
drive_forward
()
def
drive_forward
(
self
):
def
drive_forward
(
self
):
self
.
tx_characteristic
.
write_value
([
0x01
,
0x04
,
0x00
,
0x00
,
0x00
,
0x00
,
0x64
,
0x00
,
0x00
,
0x00
,
0x64
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xD1
])
self
.
tx_characteristic
.
write_value
([
0x01
,
0x04
,
0x00
,
0x00
,
0x00
,
0x00
,
0x64
,
0x00
,
0x00
,
0x00
,
0x64
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xD1
])
...
@@ -296,7 +284,7 @@ def drive_root(command):
...
@@ -296,7 +284,7 @@ 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
(
manager
.
robot
.
last_packet
)
manager
.
robot
.
drive_forward
(
)
if
command
==
"
pattern lines
"
:
if
command
==
"
pattern lines
"
:
print
(
"
pattern lines
"
)
print
(
"
pattern lines
"
)
manager
.
robot
.
drive_forward
()
manager
.
robot
.
drive_forward
()
...
...
This diff is collapsed.
Click to expand it.
time-test.py
+
19
−
3
View file @
5f650672
import
time
import
time
import
threading
sara_is_pedantic
=
0
def
printit
():
threading
.
Timer
(
2.0
,
printit
).
start
()
print
(
"
Hello, World! {}
"
.
format
(
sara_is_pedantic
))
global
sara_is_pedantic
sara_is_pedantic
+=
1
if
sara_is_pedantic
==
4
:
print
(
"
OUR WORK HERE SHOULD BE DONE?
"
)
return
def
printit_2
():
threading
.
Timer
(
5.0
,
printit_2
).
start
()
print
(
"
Hello, World! 5
"
)
def
delay
(
func
,
time
):
def
delay
(
func
,
time
):
t_end
=
time
.
time
()
+
time
t_end
=
time
.
time
()
+
time
while
time
.
time
()
<
t_end
:
while
time
.
time
()
<
t_end
:
...
@@ -13,9 +29,9 @@ def func(self):
...
@@ -13,9 +29,9 @@ def func(self):
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
print
(
"
in main
"
)
print
(
"
in main
"
)
length
=
3
length
=
3
delay
(
func
,
length
)
## delay(func, length)
printit
()
## printit_2()
# testing passing a function into a function
# so dalay function can be used to stop drive robot commands
\ No newline at end of file
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