feat: added y axis motor
This commit is contained in:
parent
aa43319490
commit
c81ba6ddc7
@ -17,9 +17,9 @@ class MotorMover implements IMotorMover {
|
||||
|
||||
public moveClockwise = () => {
|
||||
if (this.movementState === 'CLOCKWISE') return
|
||||
|
||||
this.moveProcess?.kill()
|
||||
this.moveProcess = null
|
||||
else {
|
||||
if (!this.moveProcess?.killed) this.moveProcess?.kill()
|
||||
}
|
||||
|
||||
const motorProcessArguments = [
|
||||
'src/Robotics/moveStepper.py',
|
||||
@ -38,9 +38,9 @@ class MotorMover implements IMotorMover {
|
||||
|
||||
public moveCounterClockwise = () => {
|
||||
if (this.movementState === 'COUNTERCLOCKWISE') return
|
||||
|
||||
this.moveProcess?.kill()
|
||||
this.moveProcess = null
|
||||
else {
|
||||
if (!this.moveProcess?.killed) this.moveProcess?.kill()
|
||||
}
|
||||
|
||||
const motorProcessArguments = [
|
||||
'src/Robotics/moveStepper.py',
|
||||
@ -52,14 +52,19 @@ class MotorMover implements IMotorMover {
|
||||
this.pauseIntervalTime.toString()
|
||||
]
|
||||
|
||||
console.log('start counterclockwise')
|
||||
this.moveProcess = childProcesses.spawn('python', motorProcessArguments)
|
||||
this.movementState = 'COUNTERCLOCKWISE'
|
||||
}
|
||||
|
||||
public stopMovement = () => {
|
||||
this.moveProcess?.kill()
|
||||
if (this.movementState === 'IDLE') return
|
||||
else {
|
||||
if (!this.moveProcess?.killed) this.moveProcess?.kill()
|
||||
console.log('start idle')
|
||||
this.movementState = 'IDLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default MotorMover
|
@ -18,6 +18,11 @@ const main = () => {
|
||||
pauseIntervalTime: 0.05
|
||||
})
|
||||
|
||||
const yAxisMotorMover: IMotorMover = makeMotorMover({
|
||||
motor: { pinOne: 13, pinTwo: 15, pinThree: 19, pinFour: 21 },
|
||||
pauseIntervalTime: 0.05
|
||||
})
|
||||
|
||||
eventManager.listen('onReceiveOffsets', (offsets: any[]) => {
|
||||
if (offsets[0]?.x > 50) {
|
||||
xAxisMotorMover.moveCounterClockwise()
|
||||
@ -26,7 +31,15 @@ const main = () => {
|
||||
} else {
|
||||
xAxisMotorMover.stopMovement()
|
||||
}
|
||||
console.log(`moving ${xAxisMotorMover.movementState}`)
|
||||
|
||||
if (offsets[0]?.y > 50) {
|
||||
yAxisMotorMover.moveClockwise()
|
||||
} else if (offsets[0]?.y < - 50) {
|
||||
yAxisMotorMover.moveCounterClockwise()
|
||||
} else {
|
||||
yAxisMotorMover.stopMovement()
|
||||
}
|
||||
// console.log(`moving ${xAxisMotorMover.movementState}`)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user