mirror of
https://github.com/PotentiaRobotics/engine-software.git
synced 2025-04-17 18:40:18 -04:00
71 lines
2.2 KiB
Markdown
71 lines
2.2 KiB
Markdown
# Comms
|
|
|
|
Code for **wired** communication from Slave Arduinos to Master Arduino, and then Master Arduino to Raspberry Pi.<br/>
|
|
|
|
### Code Description
|
|
|
|
- `RPi/` is working code for the Raspberry Pi
|
|
- `RPICOM.py` is the main python file that should be run on the Raspberry Pi.
|
|
- `offsets.txt` is the text file for the IMU offsets. This is not present in this repo but will be auto-generated by the `RPICOM.py` file. If the robot is interrupted and needs to be resumed, the IMUs will start at their default position; however, the offsets file allows the IMUs to use the position they last stopped at. Each line starts at 1.00 0.00 0.00 0.00 as these are the base quaternion values.
|
|
- `log.txt` is the log file of what the RPi recieved. This is not present in this repo but will be auto-generated by the `RPICOM.py` file.
|
|
- `Arduino/` is working code for the master and slave Arduinos.
|
|
- `MasterCode/MasterCode.ino` is the code for the Master Arduino
|
|
- `SlaveCode/SlaveCode.ino` is the code for the Slave Arduinos, which reads actual IMU data.
|
|
- `SlaveFakeCode/SlaveFakeCode.ino` is Slave Arduino code which generates fake IMU data, but in the real format to be sent to the Master Arduino.
|
|
- `blank/blank.ino` is blank code for the Arduinos needed to reset during setup.
|
|
- `Prev/` is previous code used for testing systems and debugging errors (not final code, and may be unstable)<br/>
|
|
|
|
|
|
### Setup and Run
|
|
|
|
**Make sure you install python beforehand**
|
|
|
|
1. Open terminal and clone the `engine-software` if not cloned already
|
|
|
|
```
|
|
git clone https://github.com/PotentiaRobotics/engine-software.git
|
|
|
|
```
|
|
|
|
2. `Cd` into this directory
|
|
|
|
```
|
|
cd engine-software/comms/
|
|
|
|
```
|
|
|
|
3. Plug in Master and Slave Arduinos and identify which one is master, and which one(s) are slaves.
|
|
|
|
4. Allow permission to flash code
|
|
|
|
```
|
|
chmod 777 /dev/ttyACM*
|
|
```
|
|
|
|
5. Open Arduino IDE and upload `blank/blank.ino` to all Arduinos.
|
|
|
|
**Do not open serial monitor on any Arduino**
|
|
|
|
|
|
6. Upload `SlaveCode/SlaveCode.ino` or `SlaveFakeCode/SlaveFakeCode.ino` to the Slave Arduinos in Arduino IDE
|
|
|
|
7. `Cd` into `RPi/`
|
|
|
|
```
|
|
cd RPi/
|
|
```
|
|
|
|
8. Install pyserial
|
|
|
|
```
|
|
pip3 install pyserial
|
|
```
|
|
|
|
9. Upload `MasterCode/MasterCode.ino` to the Master Arduino in Arduino IDE
|
|
|
|
10. Run the python code.
|
|
|
|
```
|
|
python3 RPICOM.py
|
|
```
|