-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNS - Do the optical flow in python cos it gotta work (#126)
- Loading branch information
1 parent
2fd85ca
commit 6bb6e0d
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from pmw3901 import PMW3901 | ||
import paho.mqtt.client as mqtt | ||
import tomllib | ||
import json | ||
import time | ||
|
||
file = open('pod.toml', 'rb') | ||
config = tomllib.load(file) | ||
mqttc = mqtt.Client() | ||
mqttc.connect(config['mqtt']['host'], config['mqtt']['port']) | ||
|
||
|
||
sensor = PMW3901(spi_cs=0) | ||
mqttc = mqtt.Client() | ||
|
||
while True: | ||
(x, y) = sensor.get_motion() | ||
measurement = {'header': {'timestamp': time.time(), 'priority': 1 | ||
}, 'payload': {'x': x, 'y': y}} | ||
mqttc.publish('hyped/cart_2024/measurement/optical_flow', | ||
json.dumps(measurement)) | ||
time.sleep(0.05) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters