Thanks for the help first of all. Here is my code; I could not find any errors with this. Unless they have to be WPILIB objects.
What follows is my robot.py
import magicbot
from components.drivebase.robotdrive import RobotDrive
from ctre import WPI_TalonSRX
class CleanRobot(magicbot.MagicRobot):
robotdrive = RobotDrive
def createObjects(self):
self.robotdrive_motors = [
WPI_TalonSRX(0),
WPI_TalonSRX(1),
WPI_TalonSRX(2),
WPI_TalonSRX(3)
]
def teleopInit(self):
self.robotdrive.prepareToDrive()
''' Starts at the beginning of teleop (initialize) '''
def teleopPeriodic(self):
pass
''' Starts on each iteration of the control loop'''
What follows is a portion of my robotdrive.py (component):
import wpilib
from controller import logicalaxes
from controller.buildlayout import BuildLayout
from ctre import WPI_TalonSRX, ControlMode, NeutralMode, FeedbackDevice
class RobotDrive:
motors = [
WPI_TalonSRX,
WPI_TalonSRX,
WPI_TalonSRX,
WPI_TalonSRX
]
def __init__(self):
self.enabled = True
def prepareToDrive(self):
for motor in self.motors:
motor.setNeutralMode(NeutralMode.Brake)
motor.setSafetyEnabled(False)
motor.configSelectedFeedbackSensor(FeedbackDevice.QuadEncoder, 0, 0)
self.declareJoysticks()
def calculateTankSpeed(self, y, rotate, x=0):
return [y + rotate, -y + rotate]
def move(self):
speeds = self.calculateTankSpeed(
y=logicalaxes.driveY.get(),
rotate=logicalaxes.driveRotate.get()
)
for speed, motor in zip(speeds, self.activeMotors):
motor.set(2, speed)
def execute(self):
self.move()
Again, I omitted several parts such as joystick creation. I am getting my error in motor.set(2, 0.5) of robotdrive.py, and I have the controlmode at 2, percent output, and 50% selected, ignoring the calculated speed values. Do you see any notable issues? My code returns the following:
AttributeError: 'int' object has no attribute 'speed'
I think that the Talon I’m calling this on might not be a Talon.
I’d appreciate any feedback. Thanks!