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

Class Gear

source code

object --+
         |
        Gear

Class that represents the combination of two motors on an axis to perform a car-like movement.

Instance Methods [hide private]
 
__init__(self)
Creates a gear instance.
source code
 
forward(self, duration=0)
Starts the forward rotation with preset speed.
source code
 
backward(self, duration=0)
Starts the backward rotation with preset speed.
source code
 
left(self, duration=0)
Starts turning left with right motor rotating forward and left motor rotating backward at preset speed.
source code
 
right(self, duration=0)
Starts turning right with left motor rotating forward and right motor rotating backward at preset speed.
source code
 
leftArc(self, radius, duration=0)
Starts turning to the left on an arc with given radius (in m) with preset speed.
source code
 
leftArcMilli(self, radius, duration=0)
Same as leftArc(radius, duration), but radius in mm @param radius in mm
source code
 
rightArc(self, radius, duration=0)
Starts turning to the right on an arc with given radius (in m) with preset speed.
source code
 
rightArcMilli(self, radius, duration=0)
Sama as rightArc(radius, duration), but radius in mm @param radius in mm
source code
 
stop(self)
Stops the gear.
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

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Creates a gear instance.

Overrides: object.__init__

forward(self, duration=0)

source code 

Starts the forward rotation with preset speed. If duration = 0, the method returns immediately, while the rotation continues. Otherwise the method blocks until the duration is expired. Then the gear stops.

Parameters:
  • duration (int) - if greater than 0, the method blocks for the given duration (in ms)

backward(self, duration=0)

source code 

Starts the backward rotation with preset speed. If duration = 0, the method returns immediately, while the rotation continues. Otherwise the method blocks until the duration is expired. Then the gear stops. @param duration if greater than 0, the method blocks for the given duration (in ms)

left(self, duration=0)

source code 

Starts turning left with right motor rotating forward and left motor rotating backward at preset speed. If duration = 0, the method returns immediately, while the rotation continues. Otherwise the method blocks until the duration is expired. Then the gear stops. @param duration if greater than 0, the method blocks for the given duration (in ms)

right(self, duration=0)

source code 

Starts turning right with left motor rotating forward and right motor rotating backward at preset speed. If duration = 0, the method returns immediately, while the rotation continues. Otherwise the method blocks until the duration is expired. Then the gear stops. @param duration if greater than 0, the method blocks for the given duration (in ms)

leftArc(self, radius, duration=0)

source code 

Starts turning to the left on an arc with given radius (in m) with preset speed. If duration = 0, the method returns immediately, while the rotation continues. Otherwise the method blocks until the duration is expired. Then the gear stops. If the radius is negative, turns left backwards.

Parameters:
  • duration

rightArc(self, radius, duration=0)

source code 

Starts turning to the right on an arc with given radius (in m) with preset speed. If duration = 0, the method returns immediately, while the rotation continues. Otherwise the method blocks until the duration is expired. Then the gear stops. If the radius is negative, turns right backwards.

Parameters:
  • duration

stop(self)

source code 

Stops the gear. (If gear 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