Compare commits
55 Commits
2ee6bbef90
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c945e43b5 | |||
| dc3bc85607 | |||
| 0d06a71fca | |||
| 5f9ea8867c | |||
| b42055bd4b | |||
| 7ea7f13e9b | |||
| 9bb1cf2055 | |||
| 151853b1d3 | |||
| 6106c46bd8 | |||
| 5062ada35a | |||
| c2d9fb20d7 | |||
| cadc2b0c6a | |||
| a234275422 | |||
| c67bcdc484 | |||
| 61d77870a0 | |||
| ea5978f4e4 | |||
| 942809c95a | |||
| 598e84603f | |||
| c2695e1971 | |||
| af4c8f978b | |||
| 046c1f7846 | |||
| 6fbb53b6bd | |||
| f6bb087799 | |||
| 21330c945d | |||
| b5ba5f6f9e | |||
| 32bd0f5b55 | |||
| 13eb27b9c3 | |||
| f34cb81c7a | |||
| 209e15d41f | |||
| de214dfc6b | |||
| 8f7e12ec90 | |||
| 03564ed485 | |||
| 19acde6d43 | |||
| d2f85f6aad | |||
| 6f1e5af90f | |||
| 779127ff73 | |||
| 9e58b2b1af | |||
| b902f8a500 | |||
| f38f1ab8ba | |||
| e092a570d1 | |||
| 3c0ecdd98c | |||
| 041bde458c | |||
| db52dbff47 | |||
| 9f0fb82831 | |||
| 049b1a7c5c | |||
| d12c7b64ed | |||
| f1696dd006 | |||
| 6fd0c249a0 | |||
| 66dfa763d2 | |||
| 218626d316 | |||
| f9a47e8891 | |||
| e414f63425 | |||
| 513fe74228 | |||
| 1e98970dc3 | |||
| d13b74ed47 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,7 @@
|
||||
# Python
|
||||
__pycache__
|
||||
Pipfile
|
||||
Pipfile.lock
|
||||
|
||||
# CAD
|
||||
*.stl
|
||||
@@ -9,3 +11,4 @@ __pycache__
|
||||
*.png
|
||||
*.jpg
|
||||
*.wav
|
||||
*.pdf
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
19
README.md
Normal file
19
README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
|
||||
# Notes
|
||||
|
||||
[Uart Stuff](https://www.reddit.com/r/raspberry_pi/comments/833qux/binary_file_tranfer_via_uart/)
|
||||
23
companion_software/BasicBot.py
Normal file
23
companion_software/BasicBot.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from discord_webhook import DiscordWebhook
|
||||
from picamera import PiCamera
|
||||
from time import sleep
|
||||
|
||||
|
||||
def get_uptime():
|
||||
with open('/proc/uptime', 'r') as f:
|
||||
uptime_seconds = float(f.readline().split()[0])
|
||||
|
||||
return uptime_seconds
|
||||
|
||||
webhookURL = "https://discord.com/api/webhooks/856609966404534272/TR9tnLq2sIGZoOeADNswmGRNlzBcqM5aKihfU6snVTP9WhSSoVVvi7nT6i-ZfZS7Hcqm"
|
||||
|
||||
webhook = DiscordWebhook(url=webhookURL, content="Uptime: " + str( round( ((get_uptime() / 60) / 60 ), 2 )) + " hours")
|
||||
|
||||
camera = PiCamera()
|
||||
sleep(3) # let iso settle out
|
||||
camera.capture('still.jpg')
|
||||
|
||||
with open("still.jpg", "rb") as f:
|
||||
webhook.add_file(file=f.read(), filename='still.jpg')
|
||||
response = webhook.execute() # Hit send
|
||||
|
||||
BIN
crawler_cad/DigiCase/Digi Case Base.FCStd
Normal file
BIN
crawler_cad/DigiCase/Digi Case Base.FCStd
Normal file
Binary file not shown.
BIN
crawler_cad/DigiCase/Digi Case Lid.FCStd
Normal file
BIN
crawler_cad/DigiCase/Digi Case Lid.FCStd
Normal file
Binary file not shown.
5031
crawler_cad/External/Bed_moto.obj
vendored
Normal file
5031
crawler_cad/External/Bed_moto.obj
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
crawler_cad/External/bed_Moto.FCStd
vendored
Normal file
BIN
crawler_cad/External/bed_Moto.FCStd
vendored
Normal file
Binary file not shown.
BIN
crawler_cad/Frame.FCStd
Normal file
BIN
crawler_cad/Frame.FCStd
Normal file
Binary file not shown.
BIN
crawler_cad/MastCam/9gServo.FCStd
Normal file
BIN
crawler_cad/MastCam/9gServo.FCStd
Normal file
Binary file not shown.
BIN
crawler_cad/MastCam/MastCamFace.FCStd
Normal file
BIN
crawler_cad/MastCam/MastCamFace.FCStd
Normal file
Binary file not shown.
BIN
crawler_cad/MastCam/MastCamMount.FCStd
Normal file
BIN
crawler_cad/MastCam/MastCamMount.FCStd
Normal file
Binary file not shown.
BIN
crawler_cad/MastCam/MastCamRear.FCStd
Normal file
BIN
crawler_cad/MastCam/MastCamRear.FCStd
Normal file
Binary file not shown.
BIN
crawler_cad/MastCam/Window Wiper.FCStd
Normal file
BIN
crawler_cad/MastCam/Window Wiper.FCStd
Normal file
Binary file not shown.
BIN
crawler_cad/lewis-crawler.FCStd
Normal file
BIN
crawler_cad/lewis-crawler.FCStd
Normal file
Binary file not shown.
38
crawler_software/arduino/crawler_slave/Makefile
Normal file
38
crawler_software/arduino/crawler_slave/Makefile
Normal file
@@ -0,0 +1,38 @@
|
||||
# A makefile for building the robot's slave software
|
||||
# Uses arduino-cli
|
||||
#
|
||||
# Kitsune Scientific 2021
|
||||
|
||||
# What board to build for and its core
|
||||
CORE ?= arduino:avr
|
||||
FQBN ?= arduino:avr:nano:cpu=atmega328old
|
||||
|
||||
# What port to build on
|
||||
ifndef SERIAL_DEV
|
||||
ifneq (,$(wildcard /dev/ttyUSB0))
|
||||
SERIAL_DEV = /dev/ttyUSB0
|
||||
else ifneq (,$(wildcard /dev/ttyACM0))
|
||||
SERIAL_DEV = /dev/ttyACM0
|
||||
else
|
||||
SERIAL_DEV = unknown
|
||||
endif
|
||||
endif
|
||||
|
||||
all: requirements build upload
|
||||
|
||||
build: requirements crawler_slave.ino
|
||||
arduino-cli core install $(CORE)
|
||||
|
||||
arduino-cli compile -b $(FQBN) crawler_slave
|
||||
|
||||
upload: requirements crawler_slave.ino
|
||||
arduino-cli upload -b $(FQBN) crawler_slave -p $(SERIAL_DEV)
|
||||
|
||||
requirements:
|
||||
@if [ -e requirements.txt ]; \
|
||||
then while read -r i ; do echo ; \
|
||||
echo "---> Installing " '"'$$i'"' ; \
|
||||
arduino-cli lib install "$$i" ; \
|
||||
done < requirements.txt ; \
|
||||
else echo "---> MISSING requirements.txt file"; \
|
||||
fi
|
||||
@@ -10,27 +10,28 @@
|
||||
// This servo is used to wipe and clean the camera lens
|
||||
Servo windowWiperServo;
|
||||
|
||||
// This is a variable capable of storing up to 4 items
|
||||
char instruction[32] = "";
|
||||
|
||||
// Values for the id, and raw value of an instruction
|
||||
char * id;
|
||||
char * raw_value;
|
||||
// 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 only useful for debugging
|
||||
//Serial.begin(9600);
|
||||
|
||||
// This is the address the pi will speak to us at
|
||||
Wire.begin(0x4);
|
||||
|
||||
// Call receiveEvent when data received
|
||||
Wire.onReceive(receiveEvent);
|
||||
|
||||
//Serial.println("Finished Setup.");
|
||||
// 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.
|
||||
@@ -40,27 +41,25 @@ void loop() {
|
||||
|
||||
// This method runs when we receive a message
|
||||
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
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
instruction[i] = Wire.read();
|
||||
instruction[i + 1] = '\0'; //add null after ea. char
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
//RPi first byte is cmd byte so shift everything to the left 1 pos so temp contains our string
|
||||
for (int i = 0; i < n; ++i)
|
||||
instruction[i] = instruction[i + 1];
|
||||
|
||||
id = strtok (instruction, "-");
|
||||
raw_value = strtok (NULL, "-");
|
||||
|
||||
int value = atoi(raw_value);
|
||||
|
||||
//Serial.println(id);
|
||||
//Serial.println(value);
|
||||
|
||||
// Switch statements dont work on char *
|
||||
if (strcmp(id,"WIPE") == 0) // if id, and WIPE cancel out
|
||||
{
|
||||
windowWiperServo.write(value);
|
||||
// Prevents a bug where if bytes are left in buffer, arduino crashes.
|
||||
while (Wire.available()) {
|
||||
Wire.read();
|
||||
}
|
||||
}
|
||||
|
||||
1
crawler_software/arduino/crawler_slave/requirements.txt
Normal file
1
crawler_software/arduino/crawler_slave/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
Servo
|
||||
18
crawler_software/raspberry_pi/Makefile
Normal file
18
crawler_software/raspberry_pi/Makefile
Normal file
@@ -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
|
||||
@@ -1,2 +1,2 @@
|
||||
PySSTV
|
||||
picamera
|
||||
picamera
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from PIL import Image
|
||||
import base64
|
||||
|
||||
im = Image.open('still.jpg')
|
||||
|
||||
# using Image.ADAPTIVE to avoid dithering
|
||||
for i in range(8, 0, -1):
|
||||
out = im.convert('P', palette=Image.ADAPTIVE, colors=i)
|
||||
|
||||
out.save(f'out_{i}_bits.png')
|
||||
|
||||
with open(f'out_{i}_bits.png', 'rb') as image_file:
|
||||
encoded_string = base64.a85encode(image_file.read())
|
||||
|
||||
with open(f'out_{i}_bits.txt', 'w') as f:
|
||||
f.write(encoded_string.decode('UTF-8'))
|
||||
@@ -0,0 +1 @@
|
||||
M,6r;%14!\!!!!.8Ou6I!!!)I!!!&X#Qk&,!4s2MScA`m!)Q?g7AGd(zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz!.5pZZiC(+%V8a6Akbu".KBGK#QOi)zdSl>0!!-\'6pXdsSF+-I!<<*"_P$QtD$r"izzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz!!!"D(e?.W!V_LqE<#t=!(fUS7'8jaJc
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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")
|
||||
|
||||
25
crawler_software/raspberry_pi/tests/otp/otp_test.py
Normal file
25
crawler_software/raspberry_pi/tests/otp/otp_test.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from random import randrange
|
||||
import time, pyotp, datetime
|
||||
|
||||
hotp = pyotp.HOTP(pyotp.random_base32())
|
||||
|
||||
success = 0
|
||||
num_tries = 20
|
||||
|
||||
for i in range(0,num_tries):
|
||||
epoch = int(time.time())
|
||||
code = hotp.at(epoch)
|
||||
print('------------------------')
|
||||
print(f'Made a code {code} at {epoch}, sending a simualted instruction')
|
||||
|
||||
waittime = randrange(5)
|
||||
print(f'Instuction will take {waittime} seconds to receive or be recieved')
|
||||
time.sleep(waittime)
|
||||
|
||||
if hotp.verify(code, epoch):
|
||||
print(f'code:{code} verified')
|
||||
success += 1
|
||||
else:
|
||||
print(f'code:{code} expired')
|
||||
|
||||
print(f'Succeded {success} out of {num_tries} tries')
|
||||
20
crawler_software/raspberry_pi/tests/stack_overflow.py
Normal file
20
crawler_software/raspberry_pi/tests/stack_overflow.py
Normal file
@@ -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")
|
||||
Reference in New Issue
Block a user