Changes between Version 53 and Version 54 of Tutorials
- Timestamp:
- Apr 11, 2016, 7:54:54 AM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Tutorials
v53 v54 27 27 }}} 28 28 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''':29 Now, let's create the robot! A multi-legs robot is mainly build from a body, and several legs. 30 31 We 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: 32 32 33 33 {{{ … … 38 38 39 39 class Hexapod(Robot): 40 def _createBody(self): 41 return Body(settings.LEGS_ORIGIN) 42 40 43 def _createLegs(self): 41 44 legs = {} 42 45 legIk = {} 43 46 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]) 45 48 legIk[legIndex] = Leg3DofIk(settings.LEGS_GEOMETRY[legIndex]) 46 49 … … 69 72 }}} 70 73 71 As you can see, we just implemented 2 virtual methods, {{{_createLegs()}}} and {{{_createActuatorPool()}}}.74 As you can see, we just implemented 3 virtual methods, {{{_createBody()}}}, {{{_createLegs()}}} and {{{_createActuatorPool()}}}; 72 75 73 76 Also 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. … … 178 181 'RR': {'x': 35., 'y': -80., 'gamma0' : 330.}, 179 182 } 180 config.initOrigin(LEGS_INDEX, LEGS_ORIGIN)181 183 }}} 182 184 183 185 {{{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. 184 186 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 190 FEET_NEUTRAL = { 191 191 'RM': LEGS_GEOMETRY['RM']['coxa'] + LEGS_GEOMETRY['RM']['femur'], 192 192 'RF': LEGS_GEOMETRY['RF']['coxa'] + LEGS_GEOMETRY['RF']['femur'], … … 196 196 'RR': LEGS_GEOMETRY['RR']['coxa'] + LEGS_GEOMETRY['RR']['femur'], 197 197 } 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. 204 201 205 202 {{{ … … 222 219 223 220 SERVOS_CALIBRATION = { 224 0: {'offset': 0., 'pulse90': 1500, 'ratio':1000/90.}, # coxa leg RF225 1: {'offset': -90., 'pulse90': 1500, 'ratio':1000/90.}, # femur leg RF226 2: {'offset': 0., 'pulse90': 1500, 'ratio': 1000/90.}, # tibia leg RF227 228 4: {'offset': 0., 'pulse90': 1500, 'ratio':1000/90.}, # coxa leg RM229 5: {'offset': -90., 'pulse90': 1500, 'ratio':1000/90.}, # femur leg RM230 6: {'offset': 0., 'pulse90': 1500, 'ratio': 1000/90.}, # tibia leg RM231 232 8: {'offset': 0., 'pulse90': 1500, 'ratio':1000/90.}, # coxa leg RR233 9: {'offset': -90., 'pulse90': 1500, 'ratio':1000/90.}, # femur leg RR234 10: {'offset': 0., 'pulse90': 1500, 'ratio':1000/90.}, # tibia leg RR235 236 15: {'offset': 0., 'pulse90': 1500, 'ratio':1000/90.}, # coxa leg LR237 14: {'offset': -90., 'pulse90': 1500, 'ratio':1000/90.}, # femur leg LR238 13: {'offset': 0., 'pulse90': 1500, 'ratio': 1000/90.}, # tibia leg LR239 240 19: {'offset': 0., 'pulse90': 1505, 'ratio':1000/90.}, # coxa leg LM241 18: {'offset': -90., 'pulse90': 1500, 'ratio':1000/90.}, # femur leg LM242 17: {'offset': 0., 'pulse90': 1500, 'ratio': 1000/90.}, # tibia leg LM243 244 23: {'offset': 0., 'pulse90': 1500, 'ratio':1000/90.}, # coxa leg LF245 22: {'offset': -90., 'pulse90': 1500, 'ratio':1000/90.}, # femur leg LF246 21: {'offset': 0., 'pulse90': 1500, 'ratio': 1000/90.}, # tibia leg LF221 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 247 244 } 248 245 }}} … … 286 283 {{{GAIT_PARAMS}}} contains some additional gaits params: 287 284 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; 290 287 * {{{minLength}}} is the minimum translating length, even when speed is very low; 291 288 * {{{minAngle}}} same as above for angle;
