Changes between Version 6 and Version 7 of Tutorials


Ignore:
Timestamp:
Mar 7, 2016, 3:45:52 PM (10 years ago)
Author:
fma
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Tutorials

    v6 v7  
    2424# -*- coding: utf-8 -*-
    2525
    26 from py4bot import api as api4bot
     26from py4bot.api import *
    2727}}}
    2828
     
    3737
    3838
    39 class Hexapod(api4bot.Robot):
     39class Hexapod(Robot):
    4040    def _createLegs(self):
    4141        legs = {}
    4242        legIk = {}
    4343        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])
    4646
    4747        return legs, legIk
    4848
    4949    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)
    5252
    5353        for leg in self._legs.values():
     
    8080# -*- coding: utf-8 -*-
    8181
    82 from py4bot import api as api4bot
     82from py4bot import config
    8383
    8484
     
    105105    'RR': {'x':  35., 'y': -80., 'gamma0' : 330.},
    106106}
    107 api4bot.config.initOrigin(LEGS_INDEX, LEGS_ORIGIN)
     107config.initOrigin(LEGS_INDEX, LEGS_ORIGIN)
    108108
    109109# Legs (feet) neutral position (femur horizontal, tibia vertical)
     
    134134    }
    135135}
    136 api4bot.config.initNeutral(LEGS_INDEX, LEGS_NEUTRAL)
     136config.initNeutral(LEGS_INDEX, LEGS_NEUTRAL)
    137137
    138138# Legs / servos mapping
     
    156156#!python
    157157
    158 class Gamepad(api4bot.RemoteControl):
     158class Gamepad(RemoteControl):
    159159    def _createFrontend(self):
    160160        return FrontendFactory().create("thrustmaster", path=THRUSTMASTER_PATH)
    161161
    162162    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'))
    175175}}}
    176176
     
    194194        legsIndexGroups = settings.GAIT_LEGS_GROUPS[gaitName]
    195195        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)
    198198}}}
    199199