engine-software/comms
2022-08-10 09:06:44 -04:00
..
Arduino Update MasterCode.ino 2022-08-08 08:35:51 -04:00
Prev Comms v1 is done! 2022-08-07 14:39:16 -04:00
RPi Updated Mode 0 2022-08-10 09:04:04 -04:00
README.md minor fix 2022-08-08 08:39:06 -04:00

Comms

Code for wired communication from Slave Arduinos to Master Arduino, and then Master Arduino to Raspberry Pi.

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)

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

  1. Cd into this directory
cd engine-software/comms/

  1. Plug in Master and Slave Arduinos and identify which one is master, and which one(s) are slaves.

  2. Allow permission to flash code

chmod 777 /dev/ttyACM*
  1. Open Arduino IDE and upload blank/blank.ino to all Arduinos.

Do not open serial monitor on any Arduino

  1. Upload SlaveCode/SlaveCode.ino or SlaveFakeCode/SlaveFakeCode.ino to the Slave Arduinos in Arduino IDE

  2. Cd into RPi/

cd RPi/
  1. Install pyserial
pip3 install pyserial
  1. Upload MasterCode/MasterCode.ino to the Master Arduino in Arduino IDE

  2. Run the python code.

python3 RPICOM.py