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