Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
0bc7f95f
Commit
0bc7f95f
authored
1 year ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
imu: make available via standard input state
parent
c135c4d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!43
imu: read all sensors at once at 100 Hz
Pipeline
#6055
passed
1 year ago
Stage: check
Stage: build
Stage: deploy
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python_payload/mypystubs/imu.pyi
+6
-0
6 additions, 0 deletions
python_payload/mypystubs/imu.pyi
python_payload/st3m/input.py
+19
-0
19 additions, 0 deletions
python_payload/st3m/input.py
sim/run.py
+1
-0
1 addition, 0 deletions
sim/run.py
with
26 additions
and
0 deletions
python_payload/mypystubs/imu.pyi
+
6
−
0
View file @
0bc7f95f
...
...
@@ -6,6 +6,12 @@ def acc_read() -> Tuple[float, float, float]:
"""
...
def
gyro_read
()
->
Tuple
[
float
,
float
,
float
]:
"""
Returns current x, y, z rotation rate in degrees/s.
"""
...
def
pressure_read
()
->
Tuple
[
float
,
float
]:
"""
Returns current pressure in Pa and temperature in degree C.
...
...
This diff is collapsed.
Click to expand it.
python_payload/st3m/input.py
+
19
−
0
View file @
0bc7f95f
...
...
@@ -3,6 +3,7 @@ from st3m.ui.ctx import Ctx
import
hardware
import
captouch
import
imu
import
math
...
...
@@ -328,6 +329,21 @@ class TriSwitchState:
self
.
right
.
_ignore_pressed
()
class
IMUState
:
__slots__
=
(
"
acc
"
,
"
gyro
"
,
"
pressure
"
,
"
temperature
"
)
def
__init__
(
self
)
->
None
:
self
.
acc
=
(
0.0
,
0.0
,
0.0
)
self
.
gyro
=
(
0.0
,
0.0
,
0.0
)
self
.
pressure
=
0.0
self
.
temperature
=
0.0
def
_update
(
self
,
ts
:
int
,
hr
:
InputState
)
->
None
:
self
.
acc
=
imu
.
acc_read
()
self
.
gyro
=
imu
.
gyro_read
()
self
.
pressure
,
self
.
temperature
=
imu
.
pressure_read
()
class
InputController
:
"""
A stateful input controller. It accepts InputState updates from the Reactor
...
...
@@ -344,6 +360,7 @@ class InputController:
"
captouch
"
,
"
left_shoulder
"
,
"
right_shoulder
"
,
"
imu
"
,
"
_ts
"
,
)
...
...
@@ -351,6 +368,7 @@ class InputController:
self
.
captouch
=
CaptouchState
()
self
.
left_shoulder
=
TriSwitchState
(
TriSwitchHandedness
.
left
)
self
.
right_shoulder
=
TriSwitchState
(
TriSwitchHandedness
.
right
)
self
.
imu
=
IMUState
()
self
.
_ts
=
0
def
think
(
self
,
hr
:
InputState
,
delta_ms
:
int
)
->
None
:
...
...
@@ -358,6 +376,7 @@ class InputController:
self
.
captouch
.
_update
(
self
.
_ts
,
hr
)
self
.
left_shoulder
.
_update
(
self
.
_ts
,
hr
)
self
.
right_shoulder
.
_update
(
self
.
_ts
,
hr
)
self
.
imu
.
_update
(
self
.
_ts
,
hr
)
def
_ignore_pressed
(
self
)
->
None
:
"""
...
...
This diff is collapsed.
Click to expand it.
sim/run.py
+
1
−
0
View file @
0bc7f95f
import
importlib
import
importlib.abc
import
importlib.machinery
from
importlib.machinery
import
PathFinder
,
BuiltinImporter
import
importlib.util
...
...
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