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
0f40efa4
Commit
0f40efa4
authored
6 years ago
by
Sara Falcone
Browse files
Options
Downloads
Patches
Plain Diff
fixed pattern lines
parent
e175afe7
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
+36
-36
36 additions, 36 deletions
run-solleroot.py
with
36 additions
and
36 deletions
run-solleroot.py
+
36
−
36
View file @
0f40efa4
# python3
import
gatt
import
threading
import
time
#not working...
import
time
# BLE UUID's
root_identifier_uuid
=
'
48c5d828-ac2a-442d-97a3-0c9822b04979
'
...
...
@@ -31,7 +29,6 @@ class BluetoothDeviceManager(gatt.DeviceManager):
print
(
"
[%s] Discovered: %s
"
%
(
device
.
mac_address
,
device
.
alias
()))
self
.
stop_discovery
()
# Stop searching
self
.
robot
=
RootDevice
(
mac_address
=
device
.
mac_address
,
manager
=
self
)
print
(
'
I HAVE BEEN MADE
'
)
self
.
robot
.
print_message
()
self
.
robot
.
connect
()
...
...
@@ -88,11 +85,11 @@ class RootDevice(gatt.Device):
if
new_data
[
0
]
==
DATA_TYPE_LIGHT
:
type
=
"
Light Sensor
"
if
new_data
[
0
]
==
DATA_TYPE_TOUCH
:
type
=
"
Touch Sensor
"
if
new_data
[
0
]
==
DATA_TYPE_CLIFF
:
type
=
"
Cliff Sensor
"
#
print("{}: {}".format(type, new_data))
print
(
"
{}: {}
"
.
format
(
type
,
new_data
))
##
# save to object for future use
##
self.last_packet = new_data
##
print("{}: {}".format(type, self.last_packet))
# save
COLOR INFO
to object for future use
self
.
last_packet
=
new_data
print
(
"
{}: {}
"
.
format
(
type
,
self
.
last_packet
))
# Perimeter detect, then other color functions
# check if you're at the perimeter every time there is new color data
...
...
@@ -114,6 +111,9 @@ class RootDevice(gatt.Device):
print
(
"
{}: {}
"
.
format
(
type
,
message
))
n
=
0
adjusted
=
False
# THERE ARE DRIVE LEFT AND DRIVE RIGHT COMMANDS!
if
all
(
message
)
in
color_black
:
drive_backwards
()
adjusted
=
True
...
...
@@ -122,7 +122,7 @@ class RootDevice(gatt.Device):
if
message
[
i
]
in
color_black
:
n
+=
1
if
n
>
3
:
self
.
turn_rate
(
-
9
0
)
self
.
turn_rate
(
-
3
0
)
self
.
drive_forward
()
adjusted
=
True
return
adjusted
...
...
@@ -131,40 +131,37 @@ class RootDevice(gatt.Device):
if
message
[
i
]
in
color_black
:
n
+=
1
if
n
>
3
:
self
.
turn_rate
(
9
0
)
self
.
turn_rate
(
3
0
)
self
.
drive_forward
()
adjusted
=
True
return
adjusted
return
adjusted
def
pattern_dashes
(
self
,
message
):
# pen down, pen up, so many times
print
(
"
IN PATTERN DASHES
"
)
self
.
drive_forward
()
count
=
0
## #pen down, pen up, so many times...
## count = 0
## while count < 3: # number of lines robot will draw
## print(count)
## t0 = time.time() #FIX TIME
## t1 = time.time()
## delta_t = t1 - t0
## print(delta_t)
##
## self.pen_down()
## self.drive_forward()
## while delta_t < 5000: # ms pen down
## self.drive_forward()
## t1 = time.time()
## delta_t = t1 - t0
## t0 = time.time()
## print(count)
## self.pen_up()
## while delta_t < 3000: # ms pen up
## t1 = time.time()
## delta_t = t1 - t0
## count += 1
## self.pen_up()
## self.patterning_lines_enabled = False
while
count
<
3
:
# number of lines robot will draw
self
.
pen_down
()
t_end
=
time
.
time
()
+
5
while
time
.
time
()
<
t_end
:
self
.
drive_forward
()
self
.
stop
()
time
.
sleep
(
1
)
print
(
"
pen-down, driving
"
)
self
.
pen_up
()
t_end
=
time
.
time
()
+
5
while
time
.
time
()
<
t_end
:
self
.
drive_forward
()
self
.
stop
()
time
.
sleep
(
1
)
print
(
"
pen up, drive forward
"
)
count
+=
1
print
(
"
out of loop!
"
)
self
.
stop
()
self
.
patterning_lines_enabled
=
False
def
follow_edge
(
self
,
message
):
...
...
@@ -251,6 +248,8 @@ class RootDevice(gatt.Device):
def
drive_root
(
command
):
angle
=
0
last_packet
=
manager
.
robot
.
last_packet
if
command
==
"
f
"
:
print
(
"
Drive forward
"
)
manager
.
robot
.
drive_forward
()
...
...
@@ -289,10 +288,11 @@ def drive_root(command):
if
command
==
"
edge
"
:
print
(
"
edge
"
)
manager
.
robot
.
edge_following_enabled
=
True
#
manager.robot.
#send
last
packet
to function so the robot moves
manager
.
robot
.
follow_edge
(
last
_
packet
)
if
command
==
"
pattern lines
"
:
print
(
"
pattern lines
"
)
manager
.
robot
.
patterning_lines_enabled
=
True
manager
.
robot
.
pattern_dashes
(
last_packet
)
# start here if run as program / not imported as module
...
...
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