Changes between Version 34 and Version 35 of Tutorials


Ignore:
Timestamp:
Mar 31, 2016, 8:30:20 AM (10 years ago)
Author:
fma
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Tutorials

    v34 v35  
    353353''Files for this tutorial are available in [source:/py4bot/examples/tutorial_2/]''
    354354
    355 In this tutorial, we are just going to add a remote control in order to drive our tutorial 1 simulated robot.
    356 
    357 Add the following code between the {{{Hexapod}} class, and the {{{main()}}} function:
    358 
     355In this tutorial, we are just going to add a remote control in order to drive our previous simulated robot.
     356
     357Let's use an old gamepad, a [http://www.thrustmaster.com/en_IN/products/firestorm-dual-analog-3 Thrustmaster Firestorm Dual Analog 3]. As I own such gamepad, I already added support in Py4bot.
     358
     359Add the following code between the {{{Hexapod}}} class, and the {{{main()}}} function:
    359360
    360361{{{
     
    366367
    367368    def _buildComponents(self):
     369        self._addComponent(Joystick, command=GaitSequencer().walk, keys=("analog_02", "analog_03", "analog_00"), mapper=MapperWalk())
    368370        self._addComponent(Button, command=GaitSequencer().walkStop, key="button_000")
    369371        self._addComponent(Button, command=GaitSequencer().walkStep, key="button_003")
    370 
    371         self._addComponent(Button, command=GaitSequencer().selectPrevGait, key="button_009", trigger="hold")
    372         self._addComponent(Button, command=GaitSequencer().selectNextGait, key="button_008", trigger="hold")
    373 
    374         self._addComponent(Joystick, command=GaitSequencer().walk, keys=("analog_02", "analog_03", "analog_00"), mapper=MapperWalk())
    375 
    376372        self._addComponent(Button, command=self.robot.incBodyPosition, key="button_004", mapper=MapperSetValue(dz=+5))
    377373        self._addComponent(Button, command=self.robot.incBodyPosition, key="button_005", mapper=MapperSetValue(dz=-5))
    378 
    379         self._addComponent(Analog, command=self.robot.setBodyExtraPosition, key="analog_01", modifier="button_006", mapper=MapperSet('z'))
    380374}}}
    381375
     
    386380
    387381def main():
    388     robot = Hexapod()
    389 
    390382    robot = Hexapod()
    391383
     
    509501}}}
    510502
     503Blah-blah
     504
    511505=== Settings ===
    512506
     
    521515See the [[FAQ#Howtocalibrateservosparameters|FAQ]] to fine tune servos calibration.
    522516
    523 
    524 We need to create our remote control, in order to drive our simulated robot. for this example, let's use an old gamepad, a [http://www.thrustmaster.com/en_IN/products/firestorm-dual-analog-3 Thrustmaster Firestorm Dual Analog 3]. As I own such gamepad, I already added support in Py4bot.
    525 
    526 Back in '''{{{hexapod.py}}}''':
    527 
    528 {{{
    529 #!python
    530 
    531 class Gamepad(RemoteControl):
    532     def _createFrontend(self):
    533         return FrontendFactory().create("thrustmaster", path="/dev/input/by-id/usb-Mega_World_Thrustmaster_dual_analog_3.2-event-joystick")
    534 
    535     def _buildComponents(self):
    536         self._addComponent(Button, command=GaitSequencer().walkStop, key="button_000")
    537         self._addComponent(Button, command=GaitSequencer().walkStep, key="button_003")
    538 
    539         self._addComponent(Button, command=GaitSequencer().selectPrevGait, key="button_009", trigger="hold")
    540         self._addComponent(Button, command=GaitSequencer().selectNextGait, key="button_008", trigger="hold")
    541 
    542         self._addComponent(Joystick, command=GaitSequencer().walk, keys=("analog_02", "analog_03", "analog_00"), mapper=MapperWalk())
    543 
    544         self._addComponent(Button, command=self.robot.incBodyPosition, key="button_004", mapper=MapperSetValue(dz=+5))
    545         self._addComponent(Button, command=self.robot.incBodyPosition, key="button_005", mapper=MapperSetValue(dz=-5))
    546 
    547         self._addComponent(Analog, command=self.robot.setBodyExtraPosition, key="analog_01", modifier="button_006", mapper=MapperSet('z'))
    548 }}}
    549 
    550 
    551517== Conclusion ==
    552518
    553 That's it for now with this tutorial. This is the first working dev. release; their are many additional things to do, and final implementation may change, according to feedback/suggestions I will get. But the core is there. Again, the goal of this framework is to provide a high level tool to build complete and powerfull applications to control you multi-legs robots.
    554 
    555 Have a look at [[source:py4bot/examples/cronos|py4bot/examples/cronos]], which contain the code for my 4DoF hexapod; it is a work in progress.
     519Thanks for reading these tutorials! This is the first working dev. release; there are many additional things to do, and final implementation may change, according to feedback/suggestions I will get. But the core is there. Again, the goal of this framework is to provide a high level tool to build complete and powerfull applications to control you multi-legs robots.
     520
     521Have a look at [[source:py4bot/examples/cronos|py4bot/examples/cronos]], which contain the code for my 4DoF hexapod, and closely follow Py4bot devs.