Skip to content

Commit

Permalink
Merge pull request #45 from mxochicale/44-pyproject-precommit
Browse files Browse the repository at this point in the history
44 - adding pyproject precommit
  • Loading branch information
mxochicale authored Apr 1, 2024
2 parents 1743918 + 0a91a3e commit 9490ed8
Show file tree
Hide file tree
Showing 34 changed files with 1,601 additions and 627 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pre-commit

#on:
# pull_request:
# push:
# branches:
# - main
# - 44-pyproject-precommit

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@
## others
*.ipynb_checkpoints
**/__pycache__
*.egg-info
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: 'data/.*|docs/.*'
exclude_types: [markdown]
- id: end-of-file-fixer
exclude: 'data/.*|docs/.*'
exclude_types: [markdown]
- id: check-yaml
- id: check-added-large-files
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"--rcfile=tests/.pylintrc" #Link to config file > `pylint --generate-rcfile > tests/.pylintrc`
]
exclude: 'data/.*|docs/.*|notebooks/.*|dependencies/.*|src/sentient/utils/.*|src/sentient/sensor_fusion/.*'
- id: black
name: black
entry: black
language: system
types: [python]
- id: isort
name: isort
entry: isort
language: system
types: [python]
- id: codespell
name: codespell
description: Checks for common misspellings in text files.
entry: codespell
language: python
types: [ text ]
exclude: 'data/.*|docs/.*|notebooks/.*|dependencies/.*'
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![GitHub Discussions](https://img.shields.io/github/discussions/mxochicale/sentient)](https://github.com/mxochicale/sentient/discussions)

The aim of this repository is to develop S.E.N.T.I.E.N.T. libray (Sensor Enhanced Network Technology Integrating Evolving Neural Tools).
The aim of this repository is to develop S.E.N.T.I.E.N.T. library (Sensor Enhanced Network Technology Integrating Evolving Neural Tools).
`sentient` library includes multi-sensor data methods using SOTA (State-Of-The-Art) AI models for skills assessment in surgery, sports, and robotics.
Hence, this repository contains sentient's related material with dependencies, sample-data, scripts, unit tests, docs and references.

Expand All @@ -16,16 +16,44 @@ You can run [notebooks](sentient/data_analysis) for data analysis.
See AI-enabled [models](sentient/models) (work in progress).
If interested in cada collection, please see [sensor fusion](sentient/sensor_fusion) and [video_devices](sentient/video_devices).

## Installation
```
conda create -n "sentientVE" python=3.10 pip
conda activate sentientVE
pip install --editable . # Install the package in editable mode
pip install .[test]
pip install .[learning]
#pip uninstall sentient
#conda deactivate
#conda remove -n sentientVE --all
```
## Pre-commmit
```
conda activate sentientVE
pre-commit run -a
```

### Testing sensor data
Just test default local camera id 0.
```
mamba activate sentientVE
mamba activate sentientbasicVE
export PYTHONPATH=$HOME/repositories/sentient
cd $HOME/repositories/sentient
conda activate sentientVE
#export PYTHONPATH=$HOME/repositories/sentient
#export PYTHONPATH="${PYTHONPATH}:$HOME/repositories/sentient"
python -m pytest -v -s tests/
python -m pytest -v -s tests/test_video_capture.py::test_simple_list_of_available_video_devices
python -m pytest -v -s tests/test_video_capture.py::test_capture_video
```

## Notebooks
```
conda activate sentientVE
cd $HOME/repositories/sentient/notebooks
#export PYTHONPATH="${PYTHONPATH}:$HOME/repositories/sentient"
jupyter notebook --browser=firefox
```

## Clone repository
* Generate your SSH keys as suggested [here](https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) (or [here](https://github.com/mxochicale/tools/blob/main/github/SSH.md))
* Clone the repository by typing (or copying) the following line in a terminal at your selected path in your machine:
Expand Down
34 changes: 0 additions & 34 deletions dependencies/no-gpu-ve.yml

This file was deleted.

1 change: 0 additions & 1 deletion dependencies/openzen/cpp_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ set_target_properties(${CMAKE_PROJECT_NAME}17 PROPERTIES CXX_STANDARD 17)

target_link_libraries(${CMAKE_PROJECT_NAME}14 OpenZen::OpenZen)
target_link_libraries(${CMAKE_PROJECT_NAME}17 OpenZen::OpenZen)

3 changes: 1 addition & 2 deletions dependencies/openzen/cpp_examples/example-cpp14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int main(int argc, char* argv[])
<< "\t y = " << event.second.data.imuData.r[1]
<< "\t z = " << event.second.data.imuData.r[2] << std::endl;

std::cout << "> Quaternions \t\t\t q0 = " << event.second.data.imuData.q[0]
std::cout << "> Quaternions \t\t\t q0 = " << event.second.data.imuData.q[0]
<< "\t q1 = " << event.second.data.imuData.q[1]
<< "\t q2 = " << event.second.data.imuData.q[2]
<< "\t q3 = " << event.second.data.imuData.q[3] << std::endl;
Expand Down Expand Up @@ -144,4 +144,3 @@ int main(int argc, char* argv[])
std::cout << "OpenZen client closed successfully" << std::endl;
return 0;
}

5 changes: 2 additions & 3 deletions dependencies/openzen/cpp_examples/example-cpp17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, char* argv[])
std::cout << "> Acceleration [g] \t\t x = " << event->data.imuData.a[0]
<< "\t y = " << event->data.imuData.a[1]
<< "\t z = " << event->data.imuData.a[2] << std::endl;

// depending on sensor, gyro data is outputted to g1, g2 or both
// read more on https://lpresearch.bitbucket.io/openzen/latest/getting_started.html#id1
std::cout << "> Gyro 1 [deg/seg] \t\t x = " << event->data.imuData.g1[0]
Expand All @@ -89,7 +89,7 @@ int main(int argc, char* argv[])
<< "\t y = " << event->data.imuData.r[1]
<< "\t z = " << event->data.imuData.r[2] << std::endl;

std::cout << "> Quaternions [nounit] \t\t q0 = " << event->data.imuData.q[0]
std::cout << "> Quaternions [nounit] \t\t q0 = " << event->data.imuData.q[0]
<< "\t q1 = " << event->data.imuData.q[1]
<< "\t q2 = " << event->data.imuData.q[2]
<< "\t q3 = " << event->data.imuData.q[3] << std::endl;
Expand Down Expand Up @@ -139,4 +139,3 @@ int main(int argc, char* argv[])
std::cout << "Sensor connection closed" << std::endl;
return 0;
}

54 changes: 30 additions & 24 deletions dependencies/openzen/hello-multi-sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
error = client.list_sensors_async()

#############################################################
print(f'Connecting to sensors')
print(f"Connecting to sensors")
error, sensor_s7e = client.obtain_sensor_by_name("Bluetooth", s0MACid)
if not error == openzen.ZenError.NoError:
print("Error connecting to sensor", s0MACid)
Expand All @@ -50,11 +50,11 @@
print("Error connecting to sensor", s2MACid)
sys.exit(1)
imu_s5b = sensor_s5b.get_any_component_of_type(openzen.component_type_imu)
print(f'Sensors connected')
print(f"Sensors connected")


# Set stream frequency
streamFreq = 100 # Hz
streamFreq = 100 # Hz

error = imu_s7e.set_int32_property(openzen.ZenImuProperty.SamplingRate, streamFreq)
error, freq = imu_s7e.get_int32_property(openzen.ZenImuProperty.SamplingRate)
Expand All @@ -71,7 +71,7 @@

##############################################################
print(f"-----------------------")
print(f'Sensor sync')
print(f"Sensor sync")
imu_s7e.execute_property(openzen.ZenImuProperty.StartSensorSync)
imu_s95.execute_property(openzen.ZenImuProperty.StartSensorSync)
imu_s5b.execute_property(openzen.ZenImuProperty.StartSensorSync)
Expand All @@ -89,44 +89,50 @@
imu_s7e.execute_property(openzen.ZenImuProperty.StopSensorSync)
imu_s95.execute_property(openzen.ZenImuProperty.StopSensorSync)
imu_s5b.execute_property(openzen.ZenImuProperty.StopSensorSync)
print(f'Sensor sync completed ')
print(f"Sensor sync completed ")

total_number_of_samples = streamFreq * 10 # Collect 10 seconds of data
total_number_of_samples = streamFreq * 10 # Collect 10 seconds of data
imu_s7e_data_count = 0
imu_s5b_data_count = 0
imu_s95_data_count = 0

while True:
zenEvent = client.wait_for_next_event()

print('\n -------------------- \n ')
print("\n -------------------- \n ")

print('imu_s7e > ')
if zenEvent.event_type == openzen.ZenEventType.ImuData and \
zenEvent.sensor == imu_s7e.sensor and \
zenEvent.component.handle == imu_s7e.component.handle:
print("imu_s7e > ")
if (
zenEvent.event_type == openzen.ZenEventType.ImuData
and zenEvent.sensor == imu_s7e.sensor
and zenEvent.component.handle == imu_s7e.component.handle
):
imu_data = zenEvent.data.imu_data

imu_s7e_data_count = imu_s7e_data_count + 1
print(f' imu_s7e {imu_s7e_data_count}, {imu_data.timestamp}, {imu_data.q}')

print('imu_s5b > ')
if zenEvent.event_type == openzen.ZenEventType.ImuData and \
zenEvent.sensor == imu_s5b.sensor and \
zenEvent.component.handle == imu_s5b.component.handle:
print(f" imu_s7e {imu_s7e_data_count}, {imu_data.timestamp}, {imu_data.q}")

print("imu_s5b > ")
if (
zenEvent.event_type == openzen.ZenEventType.ImuData
and zenEvent.sensor == imu_s5b.sensor
and zenEvent.component.handle == imu_s5b.component.handle
):
imu_data = zenEvent.data.imu_data

imu_s5b_data_count = imu_s5b_data_count + 1
print(f' imu_s5b {imu_s5b_data_count}, {imu_data.timestamp}, {imu_data.q}')

print('imu_s95 > ')
if zenEvent.event_type == openzen.ZenEventType.ImuData and \
zenEvent.sensor == imu_s95.sensor and \
zenEvent.component.handle == imu_s95.component.handle:
print(f" imu_s5b {imu_s5b_data_count}, {imu_data.timestamp}, {imu_data.q}")

print("imu_s95 > ")
if (
zenEvent.event_type == openzen.ZenEventType.ImuData
and zenEvent.sensor == imu_s95.sensor
and zenEvent.component.handle == imu_s95.component.handle
):
imu_data = zenEvent.data.imu_data

imu_s95_data_count = imu_s95_data_count + 1
print(f' imu_s95 {imu_s95_data_count}, {imu_data.timestamp}, {imu_data.q}')
print(f" imu_s95 {imu_s95_data_count}, {imu_data.timestamp}, {imu_data.q}")

# Check data count of 1 sensor as loop termination condition for easier comparison
if imu_s5b_data_count >= total_number_of_samples:
Expand Down
Loading

0 comments on commit 9490ed8

Please sign in to comment.