From 90d0b075636996a807dd01bdf43215b8238137f6 Mon Sep 17 00:00:00 2001 From: iris Date: Thu, 20 Jun 2024 02:17:31 -0500 Subject: [PATCH] working motor (velocity) PIDS --- REVHubInterface/REVMotor.py | 2 ++ REVHubInterface/__main__.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/REVHubInterface/REVMotor.py b/REVHubInterface/REVMotor.py index 3e1bb78..399a652 100644 --- a/REVHubInterface/REVMotor.py +++ b/REVHubInterface/REVMotor.py @@ -61,6 +61,7 @@ def resetMotorEncoder(commObj, destination, motorChannel): def setMotorConstantPower(commObj, destination, motorChannel, powerLevel): + print('setpower') setMotorConstantPowerMsg = REVMsg.SetMotorConstantPower() setMotorConstantPowerMsg.payload.motorChannel = motorChannel setMotorConstantPowerMsg.payload.powerLevel = powerLevel @@ -89,6 +90,7 @@ def getMotorTargetVelocity(commObj, destination, motorChannel): def setMotorTargetPosition(commObj, destination, motorChannel, position, atTargetTolerance): + print(getMotorTargetPosition(commObj, destination, motorChannel)[0]) setMotorTargetPositionMsg = REVMsg.SetMotorTargetPosition() setMotorTargetPositionMsg.payload.motorChannel = motorChannel setMotorTargetPositionMsg.payload.position = position diff --git a/REVHubInterface/__main__.py b/REVHubInterface/__main__.py index 7c65ddc..910e730 100644 --- a/REVHubInterface/__main__.py +++ b/REVHubInterface/__main__.py @@ -652,7 +652,7 @@ def __init__(self, root): self.DC_Motor.grid_columnconfigure(0, weight=1) self.DC_Motor.grid_rowconfigure(0, weight=1) - self.Tab_frame.add(self.motorPID, text='Motor PID') + self.Tab_frame.add(self.motorPID, text='Motor Velocity PID') self.motorPID.grid_columnconfigure(0, weight=1) self.motorPID.grid_rowconfigure(0, weight=1) @@ -726,9 +726,10 @@ def javaMotorEntry(self, motorNumber, moduleNumber, *args): def javaTargetEntry(self, motorNumber, moduleNumber, *args): target = int(self.pid_packs[moduleNumber * 4 + motorNumber].Java_entry.get()) - self.REVModules[moduleNumber].motors[motorNumber].setTargetPosition(target, 20) - self.REVModules[moduleNumber].motors[motorNumber].setMode(2, 1) - self.REVModules[moduleNumber].motors[motorNumber].setPower(float(32000)) + self.REVModules[moduleNumber].motors[motorNumber].setTargetVelocity(target) + self.REVModules[moduleNumber].motors[motorNumber].setMode(1, 1) + self.REVModules[moduleNumber].motors[motorNumber].setTargetVelocity(target) + self.repetitiveFunctions = [(lambda: self.send_all_KA())] self.repetitiveFunctions.append((lambda: self.updateMotorLabels(motorNumber, moduleNumber))) return True