Changes between Version 8 and Version 9 of Tutorial5AdvancedRemoteControlUsage
- Timestamp:
- Nov 22, 2017, 3:48:09 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Tutorial5AdvancedRemoteControlUsage
v8 v9 1 = Tutorial 5: Advanced remote control usage =1 = Tutorial 5: Advanced remote control usage = 2 2 3 3 As we've seen in [wiki:Tutorial1FirstRobot tutorial 1], we created a {{{Gamepad}}} class in order to control our robot. This class inherits from {{{RemoteControl}}}, and implements a few virtual methods. As an example, we will use my setup for my big 4 DoF hexapod, '''Cronos''': … … 50 50 }}} 51 51 52 The first method, {{{_createFrontend()}}} must return a valid frontend (we just saw in [wiki:Tutorial4AddInputFrontend Supportprevious 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.52 The first method, {{{_createFrontend()}}} must return a valid frontend (we just saw in [wiki:Tutorial4AddInputFrontend 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. 53 53 54 54 In the second method, {{{_buildComponents()}}}, interesting things take place: this is where {{{Component}}}s ({{{Button}}}, {{{Analog}}}...) of our remote control are created. … … 58 58 Then we add the components, using the {{{_addComponent()}}} method helper. This method takes the component class, the command to execute, the frontend key, a optional modifier, and a mapper. 59 59 60 Blah 60 61 62 {{{Mapper}}}s are simple objects helping to adapt params from {{{RemoteControl}}} {{{Component}}}s output to {{{Robot}}}/{{{GaitSequencer}}} methods input. 61 63 64 For example, to control the robot walk, we can create a {{{Joystick}}} component with 3 axes: X, Y, RZ. 62 65 63 64 '''Mappers''' are simple objects helping to adapt params from '''!RemoteControl''' '''Components''' output to '''Robot'''/'''!GaitSequencer''' methods input. 65 66 For example, to control the robot walk, we can create a '''Joystick''' component with 3 axes: X, Y, RZ. 67 68 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]]. 66 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 [wiki:Tutorial1FirstRobot tutorial 1]. 69 67 70 68 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. 71 69 72 Of course, you can define your own '''Mappers'''.70 Of course, wa can define our own {{{Mappers}}}. 73 71 74 72
