Différences entre versions de « Hack-micropython-ServoRobot-servorobot »
(Page créée avec « {{Hack-micropython-ServoRobot-NAV}} {{Hack-micropython-ServoRobot-TRAILER}} ») |
|||
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}} |
Version du 12 septembre 2016 à 14:16
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) """
Créé par Meurisse D. pour MCHobby.be - Created by Meurisse D. for MCHobby.be
Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : « Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.
L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.