Skip to content

Commit

Permalink
Send skewness, tilt and roll (#12)
Browse files Browse the repository at this point in the history
* Use Python 3.11

* Upgrade Bleak

* Send skew, tilt and roll
  • Loading branch information
pauloesteban committed Jul 24, 2023
1 parent b270d28 commit 3f3c309
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
40 changes: 13 additions & 27 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ name: Python application

on:
push:
# branches:
# - develop
tags:
- 'v*'
# pull_request:
Expand All @@ -31,53 +29,41 @@ jobs:
needs: create_release
strategy:
matrix:
os: [macos-latest, windows-latest]
os: [macos-latest, ]
include:
- os: macos-latest
release_suffix: mac.tar.xz
- os: windows-latest
release_suffix: windows.tar.gz
# - os: windows-latest
# release_suffix: windows.tar.gz
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: pip install -U wheel numpy pyquaternion "bleak<0.16,>=0.12.1" python-osc "pyinstaller<5.4"
run: |
pip install -U wheel pip setuptools
pip install -r requirements.txt
pip install -U "pyinstaller<5.14,>=5.5"
- name: Build executable
run: pyinstaller --clean metabow_bridge.spec
# tar -czvf metabow_bridge_${{ matrix.release_suffix }} -C ${{ runner.workspace }}/sensor-tile-osc/dist/ .
run: pyinstaller --clean metabow_bridge.spec --noconfirm

- name: Mac archive and compress
if: matrix.os == 'macos-latest'
run: tar -cJf metabow_bridge_${{ matrix.release_suffix }} -C ${{ runner.workspace }}/sensor-tile-osc/dist/ bridge.app

- name: Windows archive and compress
if: matrix.os == 'windows-latest'
run: tar -czf metabow_bridge_${{ matrix.release_suffix }} -C ${{ runner.workspace }}/sensor-tile-osc/dist/ .
# - name: Windows archive and compress
# if: matrix.os == 'windows-latest'
# run: tar -czf metabow_bridge_${{ matrix.release_suffix }} -C ${{ runner.workspace }}/sensor-tile-osc/dist/ .

- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.create_release.outputs.tag-name }}
files: metabow_bridge_${{ matrix.release_suffix }}

# - uses: actions/upload-artifact@v2
# with:
# name: metabow_bridge_${{ matrix.os }}
# path: metabow_bridge_${{ matrix.os }}.tar.gz

# - name: Upload to GH release
# uses: xresloader/upload-to-github-release@master
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# file: "*.tar.gz"
# tags: false
# verbose: true
32 changes: 25 additions & 7 deletions metabow_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ def __init__(self, loop): # Delete type hint when building on Windows
'accl_sensor_frame_x',
'accl_sensor_frame_y',
'accl_sensor_frame_z',
'accl_derivative_x',
'accl_derivative_y',
'accl_derivative_z',
'accl_vel_x',
'accl_vel_y',
'accl_vel_z',
'accl_skewness',
'accl_tilt',
'accl_roll'
]


Expand Down Expand Up @@ -247,20 +256,29 @@ def notification_handler(self, device_number: int | str, sender: int, data: byte
address_raw = f"/{device_number}/raw"
address_quaternion = f"/{device_number}/quaternion"
address_sensor_frame = f"/{device_number}/motion_acceleration/sensor_frame"
address_sensor_derivative = f"/{device_number}/motion_acceleration/sensor_derivative"
address_sensor_velocity = f"/{device_number}/motion_acceleration/sensor_velocity"
join_array = bytearray_to_fusion_data(data)
self.model.tick(join_array[1:4], join_array[4:7], join_array[7:10])
quaternion = self.model.quaternion.elements.tolist()
movement_accl = self.model.movement_acceleration.tolist()
accl_derivative = self.model.acceleration_derivative.tolist()
movement_vel = self.model.movement_velocity.tolist()
self.udp_client.send_message(address_raw, join_array)
self.udp_client.send_message(address_quaternion, quaternion)
self.udp_client.send_message(address_sensor_frame, movement_accl)
self.udp_client.send_message(address_sensor_derivative, accl_derivative)
self.udp_client.send_message(address_sensor_velocity, movement_vel)
row = [device_number, timestamp, *join_array[1:], *quaternion, *movement_accl, *accl_derivative, *movement_vel]
address_sensor_derivative = f"/{device_number}/motion_acceleration/sensor_derivative"
accl_derivative = self.model.acceleration_derivative.tolist()
self.udp_client.send_message(address_sensor_derivative, accl_derivative)
address_sensor_velocity = f"/{device_number}/motion_acceleration/sensor_velocity"
movement_vel = self.model.movement_velocity.tolist()
self.udp_client.send_message(address_sensor_velocity, movement_vel)
address_sensor_skewness = f"/{device_number}/motion_acceleration/skewness"
skewness = self.model.skewness
self.udp_client.send_message(address_sensor_skewness, skewness)
address_sensor_tilt = f"/{device_number}/motion_acceleration/tilt"
tilt = self.model.tilt
self.udp_client.send_message(address_sensor_tilt, tilt)
address_sensor_roll = f"/{device_number}/motion_acceleration/roll"
roll = self.model.roll
self.udp_client.send_message(address_sensor_roll, roll)
row = [device_number, timestamp, *join_array[1:], *quaternion, *movement_accl, *accl_derivative, *movement_vel, skewness, tilt, roll]

with open(self.log_name, 'a', encoding='UTF8') as f:
writer = csv.writer(f)
Expand Down
2 changes: 1 addition & 1 deletion metabow_bridge.spec
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ app = BUNDLE(
name='bridge.app',
icon=None,
bundle_identifier='com.metabow.bridge',
version='1.0.0',
version='1.2.0',
info_plist={
'NSBluetoothAlwaysUsageDescription': 'This app uses Bluetooth.'
}
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
numpy<1.26,>=1.23.2
pyquaternion<1.0.0
python-osc<1.9.0
bleak<0.21,>=0.15.1

0 comments on commit 3f3c309

Please sign in to comment.