Skip to content

Commit

Permalink
working motor (velocity) PIDS
Browse files Browse the repository at this point in the history
  • Loading branch information
Iris-TheRainbow committed Jun 20, 2024
1 parent 4aef530 commit 90d0b07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions REVHubInterface/REVMotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions REVHubInterface/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 90d0b07

Please sign in to comment.