Compare commits
17 Commits
acc5bffb71
...
crawler-so
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fbb53b6bd | |||
| f6bb087799 | |||
| 21330c945d | |||
| b5ba5f6f9e | |||
| 32bd0f5b55 | |||
| 13eb27b9c3 | |||
| f34cb81c7a | |||
| 209e15d41f | |||
| de214dfc6b | |||
| 8f7e12ec90 | |||
| 6f1e5af90f | |||
| 2ee6bbef90 | |||
| 941b5ac4e8 | |||
| 227815ac32 | |||
| 83a33cc202 | |||
| aa575f67a3 | |||
| 67daffd667 |
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,37 +1,63 @@
|
|||||||
/* Sweep
|
/* Crawler Slave
|
||||||
by BARRAGAN <http://barraganstudio.com>
|
*
|
||||||
This example code is in the public domain.
|
* This code runs on the crawler i2c network
|
||||||
|
* and provides a cleaner, less CPU intensive control over PWM devices.
|
||||||
modified 8 Nov 2013
|
*/
|
||||||
by Scott Fitzgerald
|
|
||||||
http://www.arduino.cc/en/Tutorial/Sweep
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Servo.h>
|
#include <Servo.h>
|
||||||
|
|
||||||
Servo myservo; // create servo object to control a servo
|
// This servo is used to wipe and clean the camera lens
|
||||||
// twelve servo objects can be created on most boards
|
Servo windowWiperServo;
|
||||||
|
|
||||||
int pos = 0; // variable to store the servo position
|
// Variables populated over i2c from master
|
||||||
|
int id;
|
||||||
|
int val;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
myservo.attach(9); // attaches the servo on pin 9 to the servo object
|
// For debugging
|
||||||
|
//Serial.begin(115200);
|
||||||
|
|
||||||
|
// Attach the wiper servo to pin 9
|
||||||
|
windowWiperServo.attach(9);
|
||||||
|
|
||||||
Wire.begin(0x8);
|
// This is the address the pi will speak to us at
|
||||||
|
Wire.begin(0x4);
|
||||||
|
|
||||||
// Call receiveEvent when data received
|
// Call receiveEvent when data received
|
||||||
Wire.onReceive(receiveEvent);
|
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() {
|
void loop() {
|
||||||
delay(10);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
void receiveEvent(int howMany) {
|
// This method runs when we receive a message
|
||||||
while (Wire.available()) { // loop through all but the last
|
void receiveEvent(int n) {
|
||||||
int pos = Wire.read(); // receive byte as a int
|
Wire.read(); // Remove smbus trash
|
||||||
myservo.write(pos);
|
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
|
||||||
|
|||||||
@@ -5,18 +5,30 @@ from gps import *
|
|||||||
from smbus import SMBus
|
from smbus import SMBus
|
||||||
import time
|
import time
|
||||||
|
|
||||||
addr = 0x8 # bus address
|
addr = 0x4 # bus address
|
||||||
bus = SMBus(1) # indicates /dev/ic2-1
|
bus = SMBus(1) # indicates /dev/ic2-1
|
||||||
|
|
||||||
numb = 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:
|
try:
|
||||||
for _x in range (0, 2):
|
for _x in range (0, 2):
|
||||||
for i in range(70, 130):
|
for i in range(78, 130):
|
||||||
bus.write_byte(addr, i)
|
writeData("WIPE-" + str(i))
|
||||||
time.sleep(0.02)
|
time.sleep(0.02)
|
||||||
for i in range(130, 70, -1):
|
for i in range(130, 78, -1):
|
||||||
bus.write_byte(addr, i)
|
writeData("WIPE-" + str(i))
|
||||||
time.sleep(0.02)
|
time.sleep(0.02)
|
||||||
except OSError:
|
except OSError:
|
||||||
print("Could not speak to ardujmemo")
|
print("Could not speak to ardujmemo")
|
||||||
|
|||||||
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