Module Motor :: Class Motor
[hide private]
[frames] | no frames]

Class Motor

source code

Class that represents a motor.

Instance Methods [hide private]
 
__init__(self, id)
Creates a motor instance with given id.
source code
 
forward(self)
Starts the forward rotation with preset speed.
source code
 
backward(self)
Starts the backward rotation with preset speed.
source code
 
stop(self)
Stops the motor.
source code
 
setSpeed(self, speed)
Sets the speed to the given value (arbitrary units).
source code
 
speedToDutyCycle(self, speed)
Linear relationship for mapping speed 0..100 to duty cycle
source code
 
_checkRobot(self) source code
Method Details [hide private]

__init__(self, id)
(Constructor)

source code 

Creates a motor instance with given id.

Parameters:
  • id - 0 for left motor, 1 for right motor

forward(self)

source code 

Starts the forward rotation with preset speed. The method returns immediately, while the rotation continues.

backward(self)

source code 

Starts the backward rotation with preset speed. The method returns immediately, while the rotation continues.

stop(self)

source code 

Stops the motor. (If motor is already stopped, returns immediately.)

setSpeed(self, speed)

source code 

Sets the speed to the given value (arbitrary units). The speed will be changed to the new value at the next movement call only. The speed is limited to 0..100.

Parameters:
  • speed - the new speed 0..100