| Version 6 (modified by , 8 years ago) ( diff ) |
|---|
Tutorial 5: Advanced remote control usage
As we've seen in tutorial 1, we created a Gamepad class in order to control our robot. This class inherits from RemoteControl, and implements a few virtual methods:
class Gamepad(RemoteControl): def _createFrontend(self): return Thrustmaster(settings.THRUSTMASTER_PATH) def _buildComponents(self): self._addConfig("walk") self._addConfig("body") self._addComponent(Button, command=self.selectNextConfig, key="button_008", trigger="hold") self._addComponent(Button, command=self.selectPreviousConfig, key="button_009", trigger="hold") self._addComponent(Button, command=self.robot.incBodyPosition, key="button_004", mapper=MapperSetValue(dz=+5)) self._addComponent(Button, command=self.robot.incBodyPosition, key="button_005", mapper=MapperSetValue(dz=-5)) self._addComponent(Joystick, configs="walk", command=GaitSequencer().walk, keys=("analog_02", "analog_03", "analog_00"), mapper=MapperWalk()) self._addComponent(Analog, configs="body", command=self.robot.setBodyExtraPosition, key="analog_00", mapper=MapperSetMultiply('yaw', coef=-15)) self._addComponent(Analog, configs="body", command=self.robot.setBodyExtraPosition, key="analog_03", mapper=MapperSetMultiply('pitch', coef=-15)) self._addComponent(Analog, configs="body", command=self.robot.setBodyExtraPosition, key="analog_02", mapper=MapperSetMultiply('roll', coef=15))
The first method, _createFrontend() must return a valid frontend (we just saw in previous tutorial how to create such frontends). This methods takes as first argument the frontend path in /dev. An additional argument can be given to override the DEFAULT_AXIS_CALIBRATION table.
The second method, _buildComponents() is where interesting things take place. Here, we create the buttons/axis mapping to the robot controls.
Note:
See TracWiki
for help on using the wiki.
