Compare commits
27 Commits
779127ff73
...
crawler-so
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fbb53b6bd | |||
| f6bb087799 | |||
| 21330c945d | |||
| b5ba5f6f9e | |||
| 32bd0f5b55 | |||
| 13eb27b9c3 | |||
| f34cb81c7a | |||
| 209e15d41f | |||
| de214dfc6b | |||
| 8f7e12ec90 | |||
| 6f1e5af90f | |||
| 2ee6bbef90 | |||
| 941b5ac4e8 | |||
| 227815ac32 | |||
| 83a33cc202 | |||
| aa575f67a3 | |||
| 67daffd667 | |||
| acc5bffb71 | |||
| c0b5d40653 | |||
| 6a74fcb472 | |||
| e8dd3c3fe9 | |||
| 8fede6107b | |||
| 75cb115330 | |||
| c2439c8fa1 | |||
| 7cc49a0406 | |||
| 3bde28770c | |||
| 4dcb454067 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,4 +9,3 @@ __pycache__
|
|||||||
*.png
|
*.png
|
||||||
*.jpg
|
*.jpg
|
||||||
*.wav
|
*.wav
|
||||||
*.pdf
|
|
||||||
|
|||||||
BIN
CAD/MastCam/9gServo.FCStd
Normal file
BIN
CAD/MastCam/9gServo.FCStd
Normal file
Binary file not shown.
BIN
CAD/MastCam/MastCamFace.FCStd
Normal file
BIN
CAD/MastCam/MastCamFace.FCStd
Normal file
Binary file not shown.
BIN
CAD/lewis-crawler.FCStd
Normal file
BIN
CAD/lewis-crawler.FCStd
Normal file
Binary file not shown.
7
README.md
Normal file
7
README.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# To install on robot
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone <url>
|
||||||
|
cd lewis-crawler/crawler_software/raspberry_pi
|
||||||
|
make install?
|
||||||
|
```
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
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.
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.
@@ -1,70 +0,0 @@
|
|||||||
### DISCLAIMER
|
|
||||||
### This is an example Makefile and it MUST be configured to suit your needs.
|
|
||||||
### For detailed explanations about all the available options,
|
|
||||||
### please refer to https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md
|
|
||||||
|
|
||||||
### PROJECT_DIR
|
|
||||||
### This is the path to where you have created/cloned your project
|
|
||||||
PROJECT_DIR = $(shell dirname $(shell pwd))
|
|
||||||
|
|
||||||
### ARDMK_DIR
|
|
||||||
### Path to the Arduino-Makefile directory.
|
|
||||||
ARDMK_DIR = $(PROJECT_DIR)/Arduino-Makefile
|
|
||||||
|
|
||||||
### ARDUINO_DIR
|
|
||||||
### Path to the Arduino application and resources directory.
|
|
||||||
ARDUINO_DIR = /usr/share/arduino
|
|
||||||
|
|
||||||
### USER_LIB_PATH
|
|
||||||
### Path to where the your project's libraries are stored.
|
|
||||||
USER_LIB_PATH := $(realpath $(PROJECT_DIR)/lib)
|
|
||||||
|
|
||||||
### BOARD_TAG & BOARD_SUB
|
|
||||||
### For Arduino IDE 1.0.x
|
|
||||||
### Only BOARD_TAG is needed. It must be set to the board you are currently using. (i.e uno, mega2560, etc.)
|
|
||||||
# BOARD_TAG = mega2560
|
|
||||||
### For Arduino IDE 1.6.x
|
|
||||||
### Both BOARD_TAG and BOARD_SUB are needed. They must be set to the board you are currently using. (i.e BOARD_TAG = uno, mega, etc. & BOARD_SUB = atmega2560, etc.)
|
|
||||||
### Note: for the Arduino Uno, only BOARD_TAG is mandatory and BOARD_SUB can be equal to anything
|
|
||||||
BOARD_TAG = mega
|
|
||||||
BOARD_SUB = atmega2560
|
|
||||||
|
|
||||||
### MONITOR_PORT
|
|
||||||
### The port your board is connected to. Using an '*' tries all the ports and finds the right one. Choose one of the two.
|
|
||||||
MONITOR_PORT = /dev/ttyUSB*
|
|
||||||
# MONITOR_PORT = /dev/ttyACM*
|
|
||||||
|
|
||||||
### MONITOR_BAUDRATE
|
|
||||||
### It must be set to Serial baudrate value you are using.
|
|
||||||
MONITOR_BAUDRATE = 115200
|
|
||||||
|
|
||||||
### AVR_TOOLS_DIR
|
|
||||||
### Path to the AVR tools directory such as avr-gcc, avr-g++, etc.
|
|
||||||
AVR_TOOLS_DIR = /usr
|
|
||||||
|
|
||||||
### AVRDUDE
|
|
||||||
### Path to avrdude directory.
|
|
||||||
AVRDUDE = /usr/bin/avrdude
|
|
||||||
|
|
||||||
### CFLAGS_STD
|
|
||||||
CFLAGS_STD = -std=gnu11
|
|
||||||
|
|
||||||
### CXXFLAGS_STD
|
|
||||||
### You can choose wich ever you like
|
|
||||||
# CXXFLAGS_STD = -std=gnu++11
|
|
||||||
CXXFLAGS_STD = -std=gnu++17
|
|
||||||
|
|
||||||
|
|
||||||
### CPPFLAGS
|
|
||||||
### Flags you might want to set for debugging purpose. Comment to stop.
|
|
||||||
CXXFLAGS += -pedantic -Wall -Wextra
|
|
||||||
LDFLAGS += -fdiagnostics-color
|
|
||||||
|
|
||||||
### OBJDIR
|
|
||||||
### Don't touch this!
|
|
||||||
### This is were you put the binaries you just compile using 'make'
|
|
||||||
CURRENT_DIR = $(shell basename $(CURDIR))
|
|
||||||
OBJDIR = $(PROJECT_DIR)/build/$(CURRENT_DIR)/$(BOARD_TAG)
|
|
||||||
|
|
||||||
### path to Arduino.mk, inside the ARDMK_DIR, don't touch.
|
|
||||||
include $(ARDMK_DIR)/Arduino.mk
|
|
||||||
63
crawler_software/arduino/crawler_slave/crawler_slave.ino
Normal file
63
crawler_software/arduino/crawler_slave/crawler_slave.ino
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/* 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);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevents a bug where if bytes are left in buffer, arduino crashes.
|
||||||
|
while (Wire.available()) {
|
||||||
|
Wire.read();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
crawler_software/raspberry_pi/crawler.service
Normal file
11
crawler_software/raspberry_pi/crawler.service
Normal 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
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
PySSTV
|
PySSTV
|
||||||
picamera
|
picamera
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
73
crawler_software/raspberry_pi/tests/discordbot.py
Normal file
73
crawler_software/raspberry_pi/tests/discordbot.py
Normal 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
|
||||||
|
|
||||||
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")
|
||||||
35
crawler_software/raspberry_pi/tests/test_i2c.py
Normal file
35
crawler_software/raspberry_pi/tests/test_i2c.py
Normal 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
|
||||||
12
crawler_software/raspberry_pi/tests/test_tx.py
Normal file
12
crawler_software/raspberry_pi/tests/test_tx.py
Normal 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
|
||||||
|
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 |
Reference in New Issue
Block a user