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.