Changes between Version 6 and Version 7 of Tutorials
- Timestamp:
- Mar 7, 2016, 3:45:52 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Tutorials
v6 v7 24 24 # -*- coding: utf-8 -*- 25 25 26 from py4bot import api as api4bot26 from py4bot.api import * 27 27 }}} 28 28 … … 37 37 38 38 39 class Hexapod( api4bot.Robot):39 class Hexapod(Robot): 40 40 def _createLegs(self): 41 41 legs = {} 42 42 legIk = {} 43 43 for legIndex in settings.LEGS_INDEX: 44 legs[legIndex] = api4bot.Leg3Dof(legIndex, {'coxa': Coxa(), 'femur': Femur(), 'tibia': Tibia()})45 legIk[legIndex] = api4bot.Leg3DofIk(settings.LEGS_GEOMETRY[legIndex])44 legs[legIndex] = Leg3Dof(legIndex, {'coxa': Coxa(), 'femur': Femur(), 'tibia': Tibia()}) 45 legIk[legIndex] = Leg3DofIk(settings.LEGS_GEOMETRY[legIndex]) 46 46 47 47 return legs, legIk 48 48 49 49 def _createActuatorPool(self): 50 driver = api4bot.VPython3Dof(settings.LEGS_INDEX, settings.LEGS_GEOMETRY, settings.LEGS_ORIGIN, settings.LEGS_SERVOS_MAPPING)51 pool = api4bot.ActuatorPool(driver)50 driver = VPython3Dof(settings.LEGS_INDEX, settings.LEGS_GEOMETRY, settings.LEGS_ORIGIN, settings.LEGS_SERVOS_MAPPING) 51 pool = ActuatorPool(driver) 52 52 53 53 for leg in self._legs.values(): … … 80 80 # -*- coding: utf-8 -*- 81 81 82 from py4bot import api as api4bot82 from py4bot import config 83 83 84 84 … … 105 105 'RR': {'x': 35., 'y': -80., 'gamma0' : 330.}, 106 106 } 107 api4bot.config.initOrigin(LEGS_INDEX, LEGS_ORIGIN)107 config.initOrigin(LEGS_INDEX, LEGS_ORIGIN) 108 108 109 109 # Legs (feet) neutral position (femur horizontal, tibia vertical) … … 134 134 } 135 135 } 136 api4bot.config.initNeutral(LEGS_INDEX, LEGS_NEUTRAL)136 config.initNeutral(LEGS_INDEX, LEGS_NEUTRAL) 137 137 138 138 # Legs / servos mapping … … 156 156 #!python 157 157 158 class Gamepad( api4bot.RemoteControl):158 class Gamepad(RemoteControl): 159 159 def _createFrontend(self): 160 160 return FrontendFactory().create("thrustmaster", path=THRUSTMASTER_PATH) 161 161 162 162 def _buildComponents(self): 163 self._addButton(command= api4bot.GaitSequencer().walkStop, key="button_000")164 self._addButton(command= api4bot.GaitSequencer().walkStep, key="button_003")165 166 self._addButton(command= api4bot.GaitSequencer().selectPrevGait, key="button_009", trigger="hold")167 self._addButton(command= api4bot.GaitSequencer().selectNextGait, key="button_008", trigger="hold")168 169 self._addJoystick(command= api4bot.GaitSequencer().walk, keys=("analog_02", "analog_03", "analog_00"), mapper=api4bot.MapperWalk())170 171 self._addButton(command=self.robot.incBodyPosition, key="button_004", mapper= api4bot.MapperSetValue(dz=+5))172 self._addButton(command=self.robot.incBodyPosition, key="button_005", mapper= api4bot.MapperSetValue(dz=-5))173 174 self._addAnalog(command=self.robot.setBodyExtraPosition, key="analog_01", modifier="button_006", mapper= api4bot.MapperSet('z'))163 self._addButton(command=GaitSequencer().walkStop, key="button_000") 164 self._addButton(command=GaitSequencer().walkStep, key="button_003") 165 166 self._addButton(command=GaitSequencer().selectPrevGait, key="button_009", trigger="hold") 167 self._addButton(command=GaitSequencer().selectNextGait, key="button_008", trigger="hold") 168 169 self._addJoystick(command=GaitSequencer().walk, keys=("analog_02", "analog_03", "analog_00"), mapper=MapperWalk()) 170 171 self._addButton(command=self.robot.incBodyPosition, key="button_004", mapper=MapperSetValue(dz=+5)) 172 self._addButton(command=self.robot.incBodyPosition, key="button_005", mapper=MapperSetValue(dz=-5)) 173 174 self._addAnalog(command=self.robot.setBodyExtraPosition, key="analog_01", modifier="button_006", mapper=MapperSet('z')) 175 175 }}} 176 176 … … 194 194 legsIndexGroups = settings.GAIT_LEGS_GROUPS[gaitName] 195 195 gaitParams = settings.GAIT_PARAMS[gaitName] 196 gait = api4bot.GaitFactory().create(gaitName, legsIndexGroups, gaitParams)197 api4bot.GaitManager().add(gait)196 gait = GaitFactory().create(gaitName, legsIndexGroups, gaitParams) 197 GaitManager().add(gait) 198 198 }}} 199 199
