| 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 | | |
| | 355 | In this tutorial, we are just going to add a remote control in order to drive our previous simulated robot. |
| | 356 | |
| | 357 | 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. |
| | 358 | |
| | 359 | Add the following code between the {{{Hexapod}}} class, and the {{{main()}}} function: |
| 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 | | |
| 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 | | |
| 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. |
| | 519 | Thanks 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 | |
| | 521 | Have a look at [[source:py4bot/examples/cronos|py4bot/examples/cronos]], which contain the code for my 4DoF hexapod, and closely follow Py4bot devs. |