diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..fe5f6196e43dda1b4c51a0ec8a1870180e64dfe4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +# Changelog +All notable changes to this project will be documented in this file + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) + +## [Unreleased] + +### Added + +### Changed + +### Removed + +## Release v1.0 - 22-1-2022 + +### Added +- Debugging funcionality to understand the communictaion setup. Notably to easily see what the Arduino side has received from the python side +- Obtain latching and non-latching key press outputs + +### Changed +- Spelling mistakes fixed for "received" +- Addressed and patched the issue of the Arduino not sending messages in the first few seconds after connection/handshake is estabilished +- Fixed the issue of messages not being received properly on the python side +- Simplified the connection process on the Arduino side +- Simplified the communication process on the Arduino side +- A range of variable and function names to be more descriptive +- Organised private and public methods in the Arduino class + +### Removed +- Unnecessary functions and variables in the Arduino class +- Functions that were neither in the Arduino nor the Key class \ No newline at end of file diff --git a/README.md b/README.md index 867242d011ec9ccc24a082acc5c07ef4ef66c048..e1e617efabbb2520cdf86103d3a8bd4d7606fe6b 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,51 @@ -# Arduino_python_communication +# Arduino - Python communication wrapper -## Python libraries you need to pre-install -[pyserial](https://gitlab.epfl.ch/create-lab/lab-systems/arduino_python_communication) -[pynput](https://pypi.org/project/pynput/) +## Description +There are many times you want to connect between Arduino(s) and some Python script. This can be for exmple data collection reasons or coordinating between multiple devices (Robot arms (e.g.: UR5 arms), digital servos (e.g.: Dynamixels), webcams, etc ). + +However, for many, using a middleware communication system such as ROS can be a huge learning curve and an unnecessary overhead. + +The point for this wrapper is to provide a *simple* solution to estabilish a reliable two-way communication channel between mulitple arduinos and a central python script. + +The aim is to be able to simple messages back and forth without going through the often troublesome process of synchronising messages, opening serial communication channels, etc. There is limited functionality to keep everything straightforward and simple. +This project is very much in its early stages, so some bugs are expected. + +--- +## Core functionality +- Estabilish a stable communication channel between multiple Arduinos and a single Python script +- Send a single string form the Python side to the Arduino side (e.g.: can be used to tell the arduino "stop the motor", "start the motor", "reset the sensor", etc) +- Send mulitple messages with specified messages names from the Arduino side to the Python side (e.g.: can be used to transfer multiple sensor values, status messages, timestamps, etc) +- Simplified keypress command functionality to test your mechatronic setup + +--- ## How to use this tool -### Initial setup (python side) -On your python file, you need to import everything from the `comms_wrapper.py` file. This can be done by `from PATH TO FILE import *`, or in a more hacky way, copying the file to your directory of your python file and with the command `from comms_wrapper import *`. +### Download the release +Download the latest release from here. You can see rough changes from the previous versions in the CHANGELOG. + +In the release you will find three files: `comms_wrapper.py`, `pyCommsLib.cpp`, and `pyCommsLib.h`. These three files will be used as "Libraries" to provide the communication wrapper functionality. + -The way to use the functions are currently most easilly followed by looking at the example in `comms_wrapper_example.py`. +### Initial setup (Python side) +Copy and paste the `comms_wrapper.py` into the same directory as your Python script. In your Python script, import the contents of `comms_wrapper.py` by writing `from comms_wrapper import *`. -### Initial setup (arduino side) -Unfortunatley the way this is currently designed is to have `pyCommsLib.cpp` and `pyCommsLib.h` inside the *same folder* as your arduino .ino file. These two files can be found under `pyComms/`. -Once you have the two files, when you open your main .ino file through the arduino ide, you should see two new tabs with the .cpp and .h files. This mean you have included the files correctly. +### Initial setup (Arduino side) +Copy and paste the `pyCommsLib.cpp` and `pyCommsLib.h` into the same directory as your Arduino .ino file. If you do this correctly, you should see the two files as two tabs on the Arduino IDE. -On the main .ino file, you can simply write `#include "pyCommsLib.h"` at the top which will make the functions available. There are variables you will need to define and specific ways to call the send/recive functions but this is currently most easily followed by looking at the example in `pyComms/pyComms.ino`. \ No newline at end of file +### How to use the wrapper +Currently, the best way to understand how to use the wrapper is to look at the example code found in the `Exmples/` folder. The implementation for the Python and Arduino side is shown the corresponding `Exmples/Python/` and `Exmples/Arduino/` folders. + + +### API Description + +To be written. Currently, all the documentation is in the form of comments in the example files. + +--- + +## Python libraries you need to install +[pyserial](https://gitlab.epfl.ch/create-lab/lab-systems/arduino_python_communication) + +[pynput](https://pypi.org/project/pynput/) diff --git a/comms_wrapper_test_ground.py b/comms_wrapper_test_ground.py index 25d15dc242e23a3c2cfe4a58cbf28e7a76fde226..07464b0835f94b23b871aa1ca8eda9810c839587 100644 --- a/comms_wrapper_test_ground.py +++ b/comms_wrapper_test_ground.py @@ -1,4 +1,3 @@ -from re import A from comms_wrapper import * def main():