| 153 | | Now, let's create our robot. In '''{{{hexapod.py}}}''', add: |
| | 151 | 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. |
| | 152 | |
| | 153 | Back in '''{{{hexapod.py}}}''': |
| | 154 | |
| | 155 | {{{ |
| | 156 | #!python |
| | 157 | |
| | 158 | class Gamepad(api4bot.RemoteControl): |
| | 159 | def _createFrontend(self): |
| | 160 | return FrontendFactory().create("thrustmaster", path=THRUSTMASTER_PATH) |
| | 161 | |
| | 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')) |
| | 175 | }}} |
| | 176 | |
| | 177 | Now, let's create our robot. Still in '''{{{hexapod.py}}}''', add: |