Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Open-Cube FW
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
Open Cube
Open-Cube FW
Commits
cd8b394f
Verified
Commit
cd8b394f
authored
4 months ago
by
Jakub Vaněk
Browse files
Options
Downloads
Patches
Plain Diff
Use EV3 ultrasonic single-shot measurement algorithm from EV3 Lab software
parent
38a5cf59
Loading
Loading
No related merge requests found
Pipeline
#109879
passed
4 months ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/ev3/sonic.py
+5
-3
5 additions, 3 deletions
lib/ev3/sonic.py
with
5 additions
and
3 deletions
lib/ev3/sonic.py
+
5
−
3
View file @
cd8b394f
...
...
@@ -25,12 +25,14 @@ class UltrasonicSensor(EV3UartSensor):
def
distance
(
self
,
silent
=
False
)
->
int
:
"""
Measure the distance to the nearest obstacle in front of the sensor.
:param silent: If true, the ultrasonic sensor will not emit more
sound waves after the measurement finishes.
:return: Distance in millimeters or a magic value of 2550 if the measurement fails.
"""
cont_
value
=
self
.
read_raw_mode
(
UltrasonicSensor
.
MODE_CONTINUOUS_CM
)[
0
]
value
=
self
.
read_raw_mode
(
UltrasonicSensor
.
MODE_CONTINUOUS_CM
)[
0
]
if
silent
:
self
.
start_set
_mode
(
UltrasonicSensor
.
MODE_SINGLE_CM
)
return
cont_
value
value
=
self
.
read_raw
_mode
(
UltrasonicSensor
.
MODE_SINGLE_CM
)
[
0
]
return
value
def
presence
(
self
)
->
bool
:
"""
...
...
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