Ligne 1 : |
Ligne 1 : |
| {{Hack-micropython-ServoRobot-NAV}} | | {{Hack-micropython-ServoRobot-NAV}} |
| + | |
| + | == class ServoJoint == |
| + | """ Define a joint/articulation (into a member) and associate it to a servo """ |
| + | |
| + | def inverted( self, value=True ): |
| + | """ Indicate if the Joint must be inverted. So position of +90 & -90 are echanged... and control inverted """ |
| + | |
| + | |
| + | def set( self, degree=0 ): |
| + | """ set the joint degree between +90° in front/forward AND -90° for backward """ |
| + | |
| + | == class Member2DF() == |
| + | """ Defining a member with 2 degree of free (2servo). So having a shouler and a wrist on a same controler """ |
| + | |
| + | def __init__( self, owner, shoulderindex, wristindex, ctrlindex=0 ): |
| + | """ see ServoJoint for parameters """ |
| + | |
| + | def reset( self ): |
| + | """ place all servos to 0° """ |
| + | |
| + | == class RobotBase == |
| + | """ Base for PCA9685's based Servo Robot """ |
| + | |
| + | def __init__( self, controlers, movementscls ): |
| + | """ :params controlers : list of PCA9685 servo controleur. [ (i2c_bus, address=0x40), ... ] |
| + | :params movementscls : list of Movement classes to register """ |
| + | |
| + | def movement( self, name ): |
| + | """ retreive or create a Movement class instance |
| + | |
| + | :params name: name of the movement (UPPERCASE!) """ |
| + | |
| + | def prepare( self, name, **kw ): |
| + | """ Call the prepare() on a Movement class instance """ |
| + | |
| + | def move( self, name, prepare=False, repeat=None, **kw ): |
| + | """ Call the step() on a Movement class instance |
| + | |
| + | :params prepare: call prepare() first |
| + | :params repeat: can be an integer or a callback function. |
| + | integer - call x times the do() |
| + | callable( robotobj, move_name, iteration_count ) - call do() while callable returns True """ |
| + | |
| + | == class Movement == |
| + | """ Base class that will allow you to code Movement """ |
| + | |
| + | def name(): |
| + | """ return the inner name of the movement. use CAPITAL. Define as class function """ |
| + | |
| + | def prepare( self, **kw ): |
| + | """ Override this method to place all the servo to prepare the movement """ |
| + | |
| + | def do( self, **kw ): |
| + | """ perform one iteration of the movement (or the complete movement) """ |
| | | |
| {{Hack-micropython-ServoRobot-TRAILER}} | | {{Hack-micropython-ServoRobot-TRAILER}} |