We welcome contributions from everyone, whether you're fixing a bug, adding a new feature, or improving documentation. This document provides guidelines for contributing to the project and outlines the steps needed to add a new sensor to the interface.
If you encounter a bug or have a feature request, please open an issue in the GitHub issue tracker. When reporting a bug, provide as much detail as possible, including steps to reproduce the issue and any relevant logs or screenshots.
If you want to contribute code to the project, please follow these steps:
-
Fork the Repository: Click the "Fork" button at the top right of the repository page to create your own fork of the project.
-
Clone Your Fork: Clone the forked repository to your local machine using:
git clone https://github.com/<your-username>/opentouch-interface.git cd opentouch-interface
-
Create a New Branch: Create a new branch for your feature or bugfix:
git checkout -b feature-or-bugfix-name
-
Make Your Changes: Implement your changes in the appropriate files. Make sure to follow the existing code style (flake8) and test any new features.
-
Commit and Push: Commit your changes with a descriptive message and push them to your forked repository:
git add . git commit -m "Description of your changes" git push origin feature-or-bugfix-name
-
Create a Pull Request: Go to the original repository on GitHub and create a pull request from your forked branch. Provide a clear description of your changes and any relevant information.
These are the core steps necessary to add a new sensor to the interface. We encourage you to take inspiration from existing code mainly the digit sensor as it currently is the most feature rich sensor.
First, create a configuration class for your sensor that validates its settings.
- Navigate to the
sensors
directory. - Create a new Python file named after your sensor, e.g.,
my_sensor_config.py
. - Define a configuration class in this file based on pydantic. The following attributes are mandatory:
sensor_name: str sensor_type: str stream: Union[str, DataStream] sampling_frequency: int recording_frequency: int
Example: digit_config.py
Next, implement the sensor's functionality by creating a sensor class.
- Navigate to the
sensors
directory. - Create a new Python file for your sensor, e.g.,
my_sensor.py
. - Implement the sensor class that inherits from the base
TouchSensor
class. This class should define how your sensor interacts with the interface.
Example: digit.py
After creating the sensor class, ensure that the interface recognizes the new sensor.
- Navigate to the
navigator.py
directory. - Add your config class to the
def _validate_yaml(self)
method.
Finally, create a viewer for your sensor that can be used in the Streamlit dashboard.
- Navigate to the
image
directory. - Create a new Python file for your sensor's viewer, e.g.,
my_sensor_viewer.py
. - Implement the viewer class that inherits from the base
BaseImageViewer
Examples:
- Easy example with no settings:
gelsight_viewer.py
- More complex examples with settings to change at runtime:
digit_viewer.py
After adding your sensor, test its functionality thoroughly and update the documentation.
Add an example config file of your sensor to sensor
and explain it in the README.md
.
If you need help with your contribution, feel free to ask questions in the GitHub Discussions
Thank you for contributing to OpenTouch Interface!