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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
toerb
flow3r firmware
Commits
bb041056
Commit
bb041056
authored
Aug 8, 2023
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
imu: put imu state into an object
parent
1f19c23f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/apps/demo_imu/__init__.py
+2
-2
2 additions, 2 deletions
python_payload/apps/demo_imu/__init__.py
python_payload/st3m/input.py
+25
-24
25 additions, 24 deletions
python_payload/st3m/input.py
with
27 additions
and
26 deletions
python_payload/apps/demo_imu/__init__.py
+
2
−
2
View file @
bb041056
...
@@ -25,8 +25,8 @@ class IMUDemo(Application):
...
@@ -25,8 +25,8 @@ class IMUDemo(Application):
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
super
().
think
(
ins
,
delta_ms
)
super
().
think
(
ins
,
delta_ms
)
self
.
v_y
+=
ins
.
acc
[
0
]
*
delta_ms
/
1000.0
*
10
self
.
v_y
+=
ins
.
imu
.
acc
[
0
]
*
delta_ms
/
1000.0
*
10
self
.
v_x
+=
ins
.
acc
[
1
]
*
delta_ms
/
1000.0
*
10
self
.
v_x
+=
ins
.
imu
.
acc
[
1
]
*
delta_ms
/
1000.0
*
10
x
=
self
.
p_x
+
self
.
v_x
*
delta_ms
/
1000.0
x
=
self
.
p_x
+
self
.
v_x
*
delta_ms
/
1000.0
y
=
self
.
p_y
+
self
.
v_y
*
delta_ms
/
1000.0
y
=
self
.
p_y
+
self
.
v_y
*
delta_ms
/
1000.0
...
...
This diff is collapsed.
Click to expand it.
python_payload/st3m/input.py
+
25
−
24
View file @
bb041056
...
@@ -8,6 +8,26 @@ from st3m.power import Power
...
@@ -8,6 +8,26 @@ from st3m.power import Power
power
=
Power
()
power
=
Power
()
class
IMUState
:
"""
State of the Inertial Measurement Unit
Acceleration in m/s**2, roation rate in deg/s, pressure in Pascal
"""
__slots__
=
(
"
acc
"
,
"
gyro
"
,
"
pressure
"
)
def
__init__
(
self
,
acc
:
Tuple
[
float
,
float
,
float
],
gyro
:
Tuple
[
float
,
float
,
float
],
pressure
:
float
,
)
->
None
:
self
.
acc
=
acc
self
.
gyro
=
gyro
self
.
pressure
=
pressure
class
InputState
:
class
InputState
:
"""
"""
Current state of inputs from badge user. Passed via think() to every
Current state of inputs from badge user. Passed via think() to every
...
@@ -21,9 +41,7 @@ class InputState:
...
@@ -21,9 +41,7 @@ class InputState:
captouch
:
captouch
.
CaptouchState
,
captouch
:
captouch
.
CaptouchState
,
left_button
:
int
,
left_button
:
int
,
right_button
:
int
,
right_button
:
int
,
acc
:
Tuple
[
float
,
float
,
float
],
imu
:
IMUState
,
gyro
:
Tuple
[
float
,
float
,
float
],
pressure
:
float
,
temperature
:
float
,
temperature
:
float
,
battery_voltage
:
float
,
battery_voltage
:
float
,
)
->
None
:
)
->
None
:
...
@@ -31,9 +49,7 @@ class InputState:
...
@@ -31,9 +49,7 @@ class InputState:
self
.
captouch
=
captouch
self
.
captouch
=
captouch
self
.
left_button
=
left_button
self
.
left_button
=
left_button
self
.
right_button
=
right_button
self
.
right_button
=
right_button
self
.
acc
=
acc
self
.
imu
=
imu
self
.
gyro
=
gyro
self
.
pressure
=
pressure
self
.
temperature
=
temperature
self
.
temperature
=
temperature
self
.
battery_voltage
=
battery_voltage
self
.
battery_voltage
=
battery_voltage
...
@@ -52,14 +68,14 @@ class InputState:
...
@@ -52,14 +68,14 @@ class InputState:
acc
=
imu
.
acc_read
()
acc
=
imu
.
acc_read
()
gyro
=
imu
.
gyro_read
()
gyro
=
imu
.
gyro_read
()
pressure
,
temperature
=
imu
.
pressure_read
()
pressure
,
temperature
=
imu
.
pressure_read
()
imu_state
=
IMUState
(
acc
,
gyro
,
pressure
)
battery_voltage
=
power
.
battery_voltage
battery_voltage
=
power
.
battery_voltage
return
InputState
(
return
InputState
(
cts
,
cts
,
left_button
,
left_button
,
right_button
,
right_button
,
acc
,
imu_state
,
gyro
,
pressure
,
temperature
,
temperature
,
battery_voltage
,
battery_voltage
,
)
)
...
@@ -484,21 +500,6 @@ class TriSwitchState:
...
@@ -484,21 +500,6 @@ class TriSwitchState:
self
.
right
.
_ignore_pressed
()
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
:
class
InputController
:
"""
"""
A stateful input controller. It accepts InputState updates from the Reactor
A stateful input controller. It accepts InputState updates from the Reactor
...
...
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