Changes between Version 53 and Version 54 of Tutorials


Ignore:
Timestamp:
Apr 11, 2016, 7:54:54 AM (10 years ago)
Author:
fma
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Tutorials

    v53 v54  
    2727}}}
    2828
    29 Now, let's create the robot! A multi-legs robot is mainly build from a body, and several legs. In most cases, the defaut body provided by Py4bot is OK, but in any case, we need to create legs.
    30 
    31 The second thing we also need to create is an ''actuator pool'', which contains all legs joints, in order to move them syncrhonized. In our example, joints are standard servos. In this example, we use the '''Veyron''' board, from '''DFRobot''':
     29Now, let's create the robot! A multi-legs robot is mainly build from a body, and several legs.
     30
     31We also need to create an ''actuator pool'', which contains all legs joints actuators, in order to move them syncrhonized. In our example, actuators are standard servos. In this example, we use the '''Veyron''' board, from '''DFRobot''', to drive our servos:
    3232
    3333{{{
     
    3838
    3939class Hexapod(Robot):
     40    def _createBody(self):
     41        return Body(settings.LEGS_ORIGIN)
     42
    4043    def _createLegs(self):
    4144        legs = {}
    4245        legIk = {}
    4346        for legIndex in settings.LEGS_INDEX:
    44             legs[legIndex] = Leg3Dof(legIndex, {'coxa': Coxa(), 'femur': Femur(), 'tibia': Tibia()})
     47            legs[legIndex] = Leg3Dof(legIndex, {'coxa': Coxa(), 'femur': Femur(), 'tibia': Tibia()}, settings.FEET_NEUTRAL[legIndex])
    4548            legIk[legIndex] = Leg3DofIk(settings.LEGS_GEOMETRY[legIndex])
    4649
     
    6972}}}
    7073
    71 As you can see, we just implemented 2 virtual methods, {{{_createLegs()}}} and {{{_createActuatorPool()}}}.
     74As you can see, we just implemented 3 virtual methods, {{{_createBody()}}}, {{{_createLegs()}}} and {{{_createActuatorPool()}}};
    7275
    7376Also note that we used some values from the '''{{{settings.py}}}''' module. This module is just a simple way to centralise the configuration of our hexapod. We will describe this module later.
     
    178181    'RR': {'x':  35., 'y': -80., 'gamma0' : 330.},
    179182}
    180 config.initOrigin(LEGS_INDEX, LEGS_ORIGIN)
    181183}}}
    182184
    183185{{{LEGS_ORIGIN}}} dict contains the positions and orientation of the origin of the legs: {{{(x, y)}}} defines the center of rotation of '''coxa''' joint, and {{{gamma0}}} is the angle of the legs at neutral position.
    184186
    185 Note that we need to call the {{{initOrigin()}}} function of the '''{{{config.py}}}''' module, in order to initialize internal configuration (some matrix are defined, in order to avoid further maths).
    186 
    187 {{{
    188 #!python
    189 
    190 LEGS_FEET_NEUTRAL = {
     187{{{
     188#!python
     189
     190FEET_NEUTRAL = {
    191191    'RM': LEGS_GEOMETRY['RM']['coxa'] + LEGS_GEOMETRY['RM']['femur'],
    192192    'RF': LEGS_GEOMETRY['RF']['coxa'] + LEGS_GEOMETRY['RF']['femur'],
     
    196196    'RR': LEGS_GEOMETRY['RR']['coxa'] + LEGS_GEOMETRY['RR']['femur'],
    197197}
    198 config.initFeetNeutral(LEGS_INDEX, LEGS_FEET_NEUTRAL)
    199 }}}
    200 
    201 {{{LEGS_FEET_NEUTRAL}}} dict contains the feet neutral positions af all legs. This is just the distance from the legs origins, in the ground plane.
    202 
    203 Here too, we need to call the {{{initFeetNeutral()}}} function of the '''{{{config.py}}}''' module, in order to initialize internal configuration.
     198}}}
     199
     200{{{FEET_NEUTRAL}}} dict contains the feet neutral positions af all legs. This is just the distance from the legs origins, in the ground plane, along leg X axis.
    204201
    205202{{{
     
    222219
    223220SERVOS_CALIBRATION = {
    224     0: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # coxa leg RF
    225     1: {'offset': -90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg RF
    226     2: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # tibia leg RF
    227 
    228     4: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # coxa leg RM
    229     5: {'offset': -90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg RM
    230     6: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # tibia leg RM
    231 
    232     8: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # coxa leg RR
    233     9: {'offset': -90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg RR
    234     10: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # tibia leg RR
    235 
    236     15: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # coxa leg LR
    237     14: {'offset': -90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg LR
    238     13: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # tibia leg LR
    239 
    240     19: {'offset':   0., 'pulse90': 1505, 'ratio': 1000/90.},  # coxa leg LM
    241     18: {'offset': -90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg LM
    242     17: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # tibia leg LM
    243 
    244     23: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # coxa leg LF
    245     22: {'offset': -90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg LF
    246     21: {'offset':   0., 'pulse90': 1500, 'ratio': 1000/90.},  # tibia leg LF
     221    0: {'offset': _90., 'pulse90': 1500, 'ratio': -1000/90.},  # coxa leg RF
     222    1: {'offset':  90., 'pulse90': 1500, 'ratio': -1000/90.},  # femur leg RF
     223    2: {'offset':   0., 'pulse90': 1500, 'ratio':  1000/90.},  # tibia leg RF
     224
     225    4: {'offset': -90., 'pulse90': 1500, 'ratio': -1000/90.},  # coxa leg RM
     226    5: {'offset':  90., 'pulse90': 1500, 'ratio': -1000/90.},  # femur leg RM
     227    6: {'offset':   0., 'pulse90': 1500, 'ratio':  1000/90.},  # tibia leg RM
     228
     229    8: {'offset': -90., 'pulse90': 1500, 'ratio': -1000/90.},  # coxa leg RR
     230    9: {'offset':  90., 'pulse90': 1500, 'ratio': -1000/90.},  # femur leg RR
     231    10: {'offset':  0., 'pulse90': 1500, 'ratio': 1000/90.},  # tibia leg RR
     232
     233    15: {'offset': -90., 'pulse90': 1500, 'ratio': -1000/90.},  # coxa leg LR
     234    14: {'offset':  90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg LR
     235    13: {'offset':   0., 'pulse90': 1500, 'ratio': -1000/90.},  # tibia leg LR
     236
     237    19: {'offset': -90., 'pulse90': 1505, 'ratio': -1000/90.},  # coxa leg LM
     238    18: {'offset':  90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg LM
     239    17: {'offset':   0., 'pulse90': 1500, 'ratio': -1000/90.},  # tibia leg LM
     240
     241    23: {'offset': -90., 'pulse90': 1500, 'ratio': -1000/90.},  # coxa leg LF
     242    22: {'offset':  90., 'pulse90': 1500, 'ratio': 1000/90.},  # femur leg LF
     243    21: {'offset':   0., 'pulse90': 1500, 'ratio': -1000/90.},  # tibia leg LF
    247244}
    248245}}}
     
    286283{{{GAIT_PARAMS}}} contains some additional gaits params:
    287284
    288 * {{{length}}} is the distance each leg will move for an entire cycle when the robot translate;
    289 * {{{angle}}} is the angle each leg will turn for an entire cycle when the robot rotate;
     285* {{{length}}} is the distance each leg will move for an entire cycle when the robot translate at full speed;
     286* {{{angle}}} is the angle each leg will turn for an entire cycle when the robot rotate at full speed;
    290287* {{{minLength}}} is the minimum translating length, even when speed is very low;
    291288* {{{minAngle}}} same as above for angle;