I was trying to use a function from my own class and it gave me this error:
Traceback (most recent call last):
File "/home/robot/MyBlocks/main.py", line 134, in <module>
File "/home/robot/MyBlocks/main.py", line 50, in drive_mm
TypeError: can't convert Generic_Myblocks to int
Exited with error code 1.
Here's my code for the drive function:
def drive_mm(angle, speed, mm, brake=True):
robot.reset()
while robot.distance() < mm:
robot.drive(speed, angle) <-- the error is this line
robot.stop()
if brake == True:
lm.hold()
rm.hold()
return
else:
lm.brake()
rm.brake()
And for the actual program:
# Creates a object using the custom class and runs the drive function off it
myblocks = Generic_Myblocks(ev3, robot, leftMotor, rightMotor, leftColor, rightColor, infrared)
myblocks.drive_mm(0, 1000, 100)
robotis undefined (in the posted code).drive_mm()appears to be a method of the class, in which case the first parameter it receives will be the instance of the class it was invoked via. That parameter is normally namedself- you are instead receiving it asangle, and trying to do math with it.