| 169 | | As you can see on the UML diagram, a {{{RemoteControl}}} object is build with {{{Components}}}; a {{{Component}}} can be a {{{Button}}}, a {{{Switch}}} an {{{Analog}}} axis, or a {{{Joystick}}}, which is several {{{Analog}}} axes bound together. |
| | 169 | As you can see on the UML diagram, a {{{RemoteControl}}} object uses {{{Components}}}; a {{{Component}}} can be a {{{Button}}}, a {{{Switch}}} an {{{Analog}}}, or a {{{Joystick}}}. |
| | 170 | |
| | 171 | {{{RemoteControl}}} has the following virtual methods which must be override in a custom remote control class: |
| | 172 | |
| | 173 | * {{{_createFrontend(self)}}} |
| | 174 | |
| | 175 | This method must return an input frontend. |
| | 176 | |
| | 177 | * {{{_buildComponents(self)}}} |
| | 178 | |
| | 179 | Here, we create the components of the remote control |
| | 180 | |
| | 181 | The following methods are used to setup the remote control: |
| | 182 | |
| | 183 | * {{{_addConfig(self, config)}}} |
| | 184 | * {{{_addComponent(self, cls, **kwargs)}}} |
| | 185 | |
| | 186 | (See below) |
| | 187 | |
| | 188 | Then, a number of objects/methods can be used as components commands: |
| | 189 | |
| | 190 | * selectPreviousConfig(self) |
| | 191 | * selectNextConfig(self) |
| | 192 | * {{{robot}}} |
| | 193 | |
| | 194 | The {{{robot}}} object is used to reach the robot methods from the components. |
| 202 | | There are many commands to control the robot, and not enough physical buttons/axis on a gamepad. So, a solution is to multiplex these buttons/axis. There are 2 ways to do that: ''configurations'' and ''modifiers''. ''configurations'' allow us to change the entire mapping; ''modifiers'' only changes a button meaning. |
| 203 | | |
| 204 | | To create several ''configurations'', we use the {{{_addConfig()}}} method. This method take a string as argument, the name of the config. |
| | 227 | There are many commands to control the robot, and not enough physical buttons/axis on a gamepad. So, a solution is to multiplex these buttons/axis. There are 2 ways to do that: ''configurations'' and ''modifiers''. ''Configurations'' allow us to change the entire mapping; ''modifiers'' only changes a button meaning. |
| | 228 | |
| | 229 | To create several ''configurations'', use the {{{_addConfig()}}} method. This method take a string as argument, the name of the config. |
| 210 | | For example, to control the robot walk, we can create a '''Joystick''' component with 3 axes: X, Y, RZ. |
| 211 | | |
| 212 | | But the '''!GaitSequencer''' {{{walk()}}} method expects '''speed''', '''direction''', '''length''' and '''angle''' params. Using the '''!MapperWalk''' mapper, you can compute all these params from X/Y/RZ axes, and send them to the '''walk()''' method. That's what we did in the [[Tutorials|tutorials]]. |
| 213 | | |
| 214 | | See [[https://framagit.org/fma38/Py4bot/blob/master/py4bot/inputs/mappers/mapper.py|py4bot/inputs/mappers/mapper.py]] to see how this mapper is defined. |
| 215 | | |
| 216 | | Of course, you can define your own '''Mappers'''. |
| | 235 | Custom '''Mappers''' can be defined. |