80 Commits

Author SHA1 Message Date
5c945e43b5 Add some notes 2021-12-14 01:35:30 -05:00
dc3bc85607 I forgot where these came from 2021-08-19 10:00:13 -04:00
0d06a71fca Merge branch 'develop' of https://kitsunehosting.net/gitea/Kenwood/lewis-crawler into develop 2021-07-16 12:29:26 -04:00
5f9ea8867c Update frame model 2021-07-16 12:29:18 -04:00
b42055bd4b increase otp time duration 2021-07-15 11:38:21 -04:00
7ea7f13e9b regen bits 2021-07-15 11:29:50 -04:00
9bb1cf2055 Conduct OTP tests 2021-07-15 11:29:44 -04:00
151853b1d3 Tested a85 encoding 2021-07-15 10:47:57 -04:00
6106c46bd8 Merge branch 'develop' of https://kitsunehosting.net/gitea/Kenwood/lewis-crawler into develop 2021-07-15 10:36:04 -04:00
5062ada35a Do some image compression tests~ 2021-07-15 10:35:33 -04:00
c2d9fb20d7 Detach servo resource when done 2021-07-14 20:49:47 -04:00
cadc2b0c6a Add updating notes 2021-07-14 20:11:46 -04:00
a234275422 Create makefile for moving and setting up service file 2021-07-14 20:11:02 -04:00
c67bcdc484 Complete arduino makefile 2021-07-14 20:04:20 -04:00
61d77870a0 Fix merge 2021-07-14 19:45:58 -04:00
ea5978f4e4 Merge branch 'crawler-cad' 2021-07-14 19:40:27 -04:00
942809c95a Send final updates to fab 2021-07-14 19:40:19 -04:00
598e84603f Update requirements and makefile to build crawler companion software 2021-07-14 12:20:35 -04:00
c2695e1971 Fix bad merge ver 2021-07-04 23:08:13 -04:00
af4c8f978b Merge branch 'crawler-software' 2021-07-04 23:06:20 -04:00
046c1f7846 Merge cad into master 2021-07-04 23:06:16 -04:00
6fbb53b6bd Fix a bug where arduino would crash on incorrectly sized i2c payload 2021-07-04 22:10:05 -04:00
f6bb087799 Merge branch 'crawler-software' of https://kitsunehosting.net/gitea/Kenwood/lewis-crawler into crawler-software 2021-07-04 21:38:39 -04:00
21330c945d Finalize (mostly) new and improved slavecode 2021-07-04 21:37:58 -04:00
b5ba5f6f9e Add stack overflow working pycode! 2021-07-05 02:37:18 +01:00
32bd0f5b55 Add sanity check 2021-07-04 20:36:13 -04:00
13eb27b9c3 Remove unnecicary loop 2021-07-04 20:34:15 -04:00
f34cb81c7a Update new sorting/recv mechanism 2021-07-04 20:32:04 -04:00
209e15d41f Merge branch 'crawler-software' of https://kitsunehosting.net/gitea/Kenwood/lewis-crawler into crawler-software 2021-07-05 01:03:53 +01:00
de214dfc6b Edit servo extent 2021-07-05 01:03:33 +01:00
8f7e12ec90 Create readme.md with basic install docs. 2021-07-04 18:39:08 -04:00
03564ed485 Shrink hat-holes 2021-07-04 15:31:06 -04:00
19acde6d43 Add 'hat flanges' to midsection 2021-07-04 15:28:54 -04:00
d2f85f6aad Fix rename 2021-07-04 15:25:18 -04:00
6f1e5af90f Cleanup requirements.txt 2021-07-04 12:22:21 -04:00
2ee6bbef90 Modify crawler service file. 2021-07-04 12:18:43 -04:00
941b5ac4e8 Create crawler service file. 2021-07-04 12:16:41 -04:00
779127ff73 Rename CAD 2021-07-04 12:07:31 -04:00
9e58b2b1af The CAD as of now is up to date, and everything is printed. 2021-07-04 12:03:19 -04:00
227815ac32 Everything moves a lot smoother without serial: todo jump speed? 2021-07-04 00:07:36 -04:00
83a33cc202 Finalize better reading of full string over i2c and splitting 2021-07-03 23:57:17 -04:00
aa575f67a3 Create/modify read string code 2021-07-03 22:54:50 -04:00
b902f8a500 Fix wrong gps depth. 2021-07-03 16:06:47 -04:00
f38f1ab8ba Finalize rear cam mount 2021-07-02 12:16:11 -04:00
e092a570d1 Cleanupcam mount 2021-07-01 22:06:57 -04:00
3c0ecdd98c Create makefile though still with bugs 2021-06-30 12:13:33 -04:00
041bde458c Merge in crawler software into develop, re-structruing some of the git layout. 2021-06-30 11:59:41 -04:00
67daffd667 Cleanup slave software again. 2021-06-29 22:57:51 -04:00
acc5bffb71 Merge branch 'crawler-software' of https://kitsunehosting.net/gitea/Kenwood/lewis-crawler into crawler-software 2021-06-29 22:47:00 -04:00
c0b5d40653 Cleanup slave software 2021-06-29 22:46:25 -04:00
db52dbff47 Update mastcam 2021-06-29 22:45:03 -04:00
6a74fcb472 Added crawler discord bot 2021-06-30 03:19:09 +01:00
e8dd3c3fe9 Copy in functioning tests from pi 2021-06-30 00:56:08 +01:00
9f0fb82831 Create half of the rear mast post, and make drawing object for frame. 2021-06-29 19:35:21 -04:00
049b1a7c5c Add second flange to midsection of mastcam 2021-06-28 12:30:57 -04:00
d12c7b64ed Create proto for window wiper blade 2021-06-28 12:25:04 -04:00
8fede6107b Move .ino into the correct folder 2021-06-28 01:30:35 -04:00
75cb115330 Modify code +- limits for pwm sweep 2021-06-28 01:29:59 -04:00
c2439c8fa1 Copy in example servo code, pwm is way better! 2021-06-28 01:23:43 -04:00
7cc49a0406 Copy in slave example code from droneworkshop 2021-06-27 22:57:07 -04:00
f1696dd006 Update case and lid 2021-06-27 22:56:41 -04:00
6fd0c249a0 Create lid for digi components 2021-06-25 23:42:01 -04:00
66dfa763d2 Create base for digi components 2021-06-25 23:14:09 -04:00
3bde28770c Add default artifacts 2021-06-21 21:19:16 -04:00
4dcb454067 Organize everything 2021-06-21 21:16:39 -04:00
218626d316 Merge branch 'companion-software' 2021-06-21 21:06:24 -04:00
f9a47e8891 Add basic bot, this should get changed 2021-06-21 21:02:11 -04:00
c0ec0d141e Move all onboard software to dedicated dir 2021-06-21 20:59:14 -04:00
e414f63425 Update end of day: 2021-06-21 20:57:36 -04:00
513fe74228 Add servo to assy 2021-06-21 14:23:31 -04:00
1e98970dc3 Assemble face and rear in assy 2021-06-21 13:52:20 -04:00
d13b74ed47 Create rear of mastcam: 2021-06-21 13:52:01 -04:00
8dcbaded2d Add servo example, servo action is jerky but functional 2021-06-21 13:21:32 -04:00
fe1c4cf389 Create basic configs 2021-06-21 12:49:13 -04:00
3ce68231eb Rename crawler software 2021-06-21 12:46:33 -04:00
c33d4c0350 Add updates to gitignore to reduce number of artifacts 2021-06-21 00:45:30 -04:00
81c442f656 Add updates to sstv to allow for simulation 2021-06-21 00:45:14 -04:00
f9c7676c92 Add LCS Mastcam 2021-06-20 23:21:09 -04:00
d6e481866a Add LCS Servo Horn 2021-06-20 23:04:00 -04:00
87ec24a074 Create lewis-crawler assy, 2021-06-20 22:55:44 -04:00
44 changed files with 5441 additions and 6 deletions

7
.gitignore vendored
View File

@@ -1,7 +1,14 @@
# Python # Python
__pycache__ __pycache__
Pipfile
Pipfile.lock
# CAD # CAD
*.stl *.stl
*.FCStd1 *.FCStd1
# Artifacts
*.png
*.jpg
*.wav
*.pdf

Binary file not shown.

Binary file not shown.

19
README.md Normal file
View 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/)

View 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

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

BIN
crawler_cad/Frame.FCStd Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View 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

View File

@@ -0,0 +1,65 @@
/* Crawler Slave
*
* This code runs on the crawler i2c network
* and provides a cleaner, less CPU intensive control over PWM devices.
*/
#include <Wire.h>
#include <Servo.h>
// 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(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.
void loop() {
delay(50);
}
// 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
//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();
}
}

View File

@@ -0,0 +1 @@
Servo

View 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

View File

@@ -0,0 +1,5 @@
wiper_servo:
pin: 17
min_pulse: 0.000544
max_pulse: 0.0024

View File

@@ -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

View File

@@ -0,0 +1,2 @@
PySSTV
picamera

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,9 +1,15 @@
from shutil import copyfile from shutil import copyfile
from PIL import Image, ImageFont, ImageDraw from PIL import Image, ImageFont, ImageDraw
from pysstv import color from pysstv import color
from picamera import PiCamera
import logging as log import logging as log
try:
from picamera import PiCamera
except ModuleNotFoundError:
log.info("Running in simulator mode")
def take_photo(): def take_photo():
# This def is meant to take a photograph from the robot, # This def is meant to take a photograph from the robot,
# it should include all steps and error checking to raise the mast # it should include all steps and error checking to raise the mast
@@ -16,9 +22,12 @@ def take_photo():
# Software to take the photo should be here # Software to take the photo should be here
#copyfile('photos/camera_latest.jpg', 'working/working.jpg') #copyfile('photos/camera_latest.jpg', 'working/working.jpg')
log.debug('Initalizing camera.') log.debug('Initalizing camera.')
try:
camera = PiCamera() camera = PiCamera()
log.info('Saving photo.') log.info('Saving photo.')
camera.capture('working/working.jpg') camera.capture('working/working.jpg')
except NameError:
log.info("Running in simulator mode, not replacing test pattern")
def mark_photo(): def mark_photo():
log.info('Opening photo for viewing.') log.info('Opening photo for viewing.')

View File

@@ -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'))

View File

@@ -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

View File

@@ -0,0 +1,73 @@
from discord_webhook import DiscordWebhook
from picamera import PiCamera
from time import sleep
from gps import *
from smbus import SMBus
import time
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(78, 130):
writeData("WIPE-" + str(i))
time.sleep(0.02)
for i in range(130, 78, -1):
writeData("WIPE-" + str(i))
time.sleep(0.02)
except OSError:
print("Could not speak to ardujmemo")
def get_uptime():
with open('/proc/uptime', 'r') as f:
uptime_seconds = float(f.readline().split()[0])
return uptime_seconds
def getPositionData(gps):
location = [None]
while(location[0] == None):
print("Trying again")
nx = gpsd.next()
# For a list of all supported classes and fields refer to:
# https://gpsd.gitlab.io/gpsd/gpsd_json.html
if nx['class'] == 'TPV':
latitude = getattr(nx,'lat', "Unknown")
longitude = getattr(nx,'lon', "Unknown")
#print "Your position: lon = " + str(longitude) + ", lat = " + str(latitude)
location = [latitude, longitude]
return location
gpsd = gps(mode=WATCH_ENABLE|WATCH_NEWSTYLE)
loc = getPositionData(gpsd)
webhookURL = "https://discord.com/api/webhooks/856609966404534272/TR9tnLq2sIGZoOeADNswmGRNlzBcqM5aKihfU6snVTP9WhSSoVVvi7nT6i-ZfZS7Hcqm"
print(loc[0])
print(loc[1])
webhook = DiscordWebhook(url=webhookURL, content="Uptime: " + str( round( ((get_uptime() / 60) / 60 ), 2 )) + " hours. Lat is " + str(loc[0]) + ", long is " + str(loc[1]))
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

View 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')

View File

@@ -0,0 +1,19 @@
import RPi.GPIO as GPIO
import time
servoPIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(servoPIN, GPIO.OUT)
p = GPIO.PWM(servoPIN, 50) # GPIO 17 for PWM with 50Hz
p.start(2.5) # Initialization
try:
while True:
p.ChangeDutyCycle(10)
time.sleep(2)
p.ChangeDutyCycle(2.5)
time.sleep(2)
except KeyboardInterrupt:
p.stop()
GPIO.cleanup()

View 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")

View File

@@ -0,0 +1,35 @@
# Raspberry Pi Master for Arduino Slave
# i2c_master_pi.py
# Connects to Arduino via I2C
# DroneBot Workshop 2019
# https://dronebotworkshop.com
from smbus import SMBus
import time
addr = 0x8 # bus address
bus = SMBus(1) # indicates /dev/ic2-1
numb = 1
print ("Enter num")
for _x in range (0, 4):
for i in range(76, 130):
bus.write_byte(addr, i)
time.sleep(0.02)
for i in range(130, 76, -1):
bus.write_byte(addr, i)
time.sleep(0.02)
#while numb == 1:
#
# ledstate = input(">>>> ")
#
# if ledstate == "1":
# bus.write_byte(addr, 0x1) # switch it on
# elif ledstate == "0":
# bus.write_byte(addr, 0x0) # switch it on
# else:
# numb = 0

View File

@@ -0,0 +1,12 @@
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the time module
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(12, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and set initial value to low (off)
while True: # Run forever
GPIO.output(12, GPIO.HIGH) # Turn on
sleep(1) # Sleep for 1 second
GPIO.output(12, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

View File

@@ -1,2 +0,0 @@
PySSTV
picamera