Merge branch 'develop' of https://kitsunehosting.net/gitea/Kenwood/lewis-crawler into develop
This commit is contained in:
commit
6106c46bd8
|
@ -9,3 +9,4 @@ __pycache__
|
|||
*.png
|
||||
*.jpg
|
||||
*.wav
|
||||
*.pdf
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
# To install on robot
|
||||
|
||||
```
|
||||
git clone https://kitsunehosting.net/gitea/Kenwood/lewis-crawler /srv/crawler
|
||||
cd /srv/crawler/crawler_software/raspberry_pi
|
||||
make install
|
||||
```
|
||||
|
||||
# Updating
|
||||
|
||||
```
|
||||
cd /srv/crawler
|
||||
git pull
|
||||
```
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -5,7 +5,7 @@
|
|||
|
||||
# What board to build for and its core
|
||||
CORE ?= arduino:avr
|
||||
FQBN ?= arduino:avr:nano
|
||||
FQBN ?= arduino:avr:nano:cpu=atmega328old
|
||||
|
||||
# What port to build on
|
||||
ifndef SERIAL_DEV
|
||||
|
@ -20,13 +20,13 @@ endif
|
|||
|
||||
all: requirements build upload
|
||||
|
||||
build: crawler_slave.ino
|
||||
build: requirements crawler_slave.ino
|
||||
arduino-cli core install $(CORE)
|
||||
|
||||
arduino-cli compile -b $(FQBN) crawler_slave
|
||||
|
||||
upload:
|
||||
echo "Would install to $(SERIAL_DEV)"
|
||||
upload: requirements crawler_slave.ino
|
||||
arduino-cli upload -b $(FQBN) crawler_slave -p $(SERIAL_DEV)
|
||||
|
||||
requirements:
|
||||
@if [ -e requirements.txt ]; \
|
||||
|
|
|
@ -10,16 +10,28 @@
|
|||
// This servo is used to wipe and clean the camera lens
|
||||
Servo windowWiperServo;
|
||||
|
||||
// Variables populated over i2c from master
|
||||
int id;
|
||||
int val;
|
||||
|
||||
void setup() {
|
||||
// For debugging
|
||||
//Serial.begin(115200);
|
||||
|
||||
// Attach the wiper servo to pin 9
|
||||
windowWiperServo.attach(9);
|
||||
|
||||
// This is the address the pi will speak to us at
|
||||
Wire.begin(0x8);
|
||||
Wire.begin(0x4);
|
||||
|
||||
// Call receiveEvent when data received
|
||||
Wire.onReceive(receiveEvent);
|
||||
|
||||
|
||||
// Setup LED
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
//Serial.println("Started");
|
||||
}
|
||||
|
||||
// Just loop to keep the running code alive, and wait for events to happen.
|
||||
|
@ -28,9 +40,26 @@ void loop() {
|
|||
}
|
||||
|
||||
// This method runs when we receive a message
|
||||
void receiveEvent(int howMany) {
|
||||
while (Wire.available()) { // loop through all but the last
|
||||
int pos = Wire.read(); // receive byte as a int
|
||||
windowWiperServo.write(pos);
|
||||
void receiveEvent(int n) {
|
||||
Wire.read(); // Remove smbus trash
|
||||
if (true) { // Dont do anything if this is not true
|
||||
id = Wire.read(); // ID of the servo/device to access
|
||||
val = Wire.read(); // Value to assign
|
||||
|
||||
//Serial.println(id);
|
||||
//Serial.println(val);
|
||||
|
||||
switch(id) {
|
||||
case 1:
|
||||
windowWiperServo.write(val); // Set a val
|
||||
delay(5); // pause for a moment
|
||||
windowWiperServo.detach(); // Detach (stop moving) the servo
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Prevents a bug where if bytes are left in buffer, arduino crashes.
|
||||
while (Wire.available()) {
|
||||
Wire.read();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# A makefile for installing the robot's python
|
||||
# software and setting it up.
|
||||
#
|
||||
# Requires sudo
|
||||
#
|
||||
# Kitsune Scientific 2021
|
||||
|
||||
all: install
|
||||
|
||||
upload: crawler.service
|
||||
sudo cp crawler.service /etc/systemd/system/crawler.service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
sudo systemctl enable crawler.service
|
||||
sudo systemctl start crawler.service
|
||||
|
||||
sudo systemctl status crawler
|
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Crawler service overseer, manages running main crawler software
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecStart=/usr/bin/python /srv/crawler/crawler.py
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,2 +1,2 @@
|
|||
PySSTV
|
||||
picamera
|
||||
picamera
|
||||
|
|
|
@ -5,18 +5,30 @@ from gps import *
|
|||
from smbus import SMBus
|
||||
import time
|
||||
|
||||
addr = 0x8 # bus address
|
||||
addr = 0x4 # bus address
|
||||
bus = SMBus(1) # indicates /dev/ic2-1
|
||||
|
||||
numb = 1
|
||||
|
||||
def writeData(value):
|
||||
byteValue = StringToBytes(value)
|
||||
bus.write_i2c_block_data(addr,0x00,byteValue) #first byte is 0=command byte.. just is.
|
||||
return -1
|
||||
|
||||
|
||||
def StringToBytes(val):
|
||||
retVal = []
|
||||
for c in val:
|
||||
retVal.append(ord(c))
|
||||
return retVal
|
||||
|
||||
try:
|
||||
for _x in range (0, 2):
|
||||
for i in range(70, 130):
|
||||
bus.write_byte(addr, i)
|
||||
for i in range(78, 130):
|
||||
writeData("WIPE-" + str(i))
|
||||
time.sleep(0.02)
|
||||
for i in range(130, 70, -1):
|
||||
bus.write_byte(addr, i)
|
||||
for i in range(130, 78, -1):
|
||||
writeData("WIPE-" + str(i))
|
||||
time.sleep(0.02)
|
||||
except OSError:
|
||||
print("Could not speak to ardujmemo")
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import smbus
|
||||
import time
|
||||
import struct
|
||||
|
||||
# for RPI version 1, use bus = smbus.SMBus(0)
|
||||
bus = smbus.SMBus(1)
|
||||
|
||||
# This is the address we setup in the Arduino Program
|
||||
address = 0x04
|
||||
|
||||
try:
|
||||
for _x in range (0, 2):
|
||||
for i in range(78, 130):
|
||||
bus.write_i2c_block_data(address, 0, [1, i])
|
||||
time.sleep(0.02)
|
||||
for i in range(130, 78, -1):
|
||||
bus.write_i2c_block_data(address, 0, [1, i])
|
||||
time.sleep(0.02)
|
||||
except OSError:
|
||||
print("Could not speak to ardujmemo")
|
Loading…
Reference in New Issue