forked from beaver-auv/robosub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardware_interface.py
More file actions
30 lines (23 loc) · 913 Bytes
/
hardware_interface.py
File metadata and controls
30 lines (23 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
from hardware.motor_serial import MotorSerial
from hardware.sensors import VectorNavIMU, DepthSensor
class SubHardware:
def __init__(self, *, arduino_port, vectornav_port, vectornav_baud=921600, depth_bus=1):
self.motor_serial = MotorSerial(arduino_port)
self.imu = VectorNavIMU(vectornav_port, vectornav_baud)
self.depth = DepthSensor(bus=depth_bus)
self.prev = {}
def set_motor(self, pin, magnitude):
if pin in self.prev and self.prev[pin] == magnitude:
return
if pin == 4:
for i in range(4):
self.motor_serial.send({4+i: magnitude/4})
self.prev[4+i] = magnitude
return
self.prev[pin] = magnitude
self.motor_serial.send({pin: magnitude})
def initialize_motor(self, pin):
return 0
def kill(self):
self.motor_serial.kill()