I wanted to mention one feature of the 2.0 release that perhaps not many have yet run across: robot configurations can now live as resources in your robot controller application APK (in addition to files on the RC phone, where they have always lived).
Any .XML file found in (e.g.) TeamCode\res\xml\myConfig.xml whose root XML element is "Robot" and which has a "type" attribute with the value "FirstInspires-FTC" will appear as one of the available configurations in the "Configure Robot..." user interface. If the root "Robot" element also has a "name" attribute, then the value of that attribute is used as the name of the configuration; otherwise, the name of the XML resource file is used. Robot configurations found in resources cannot be edited and saved using the UI on the RC phone, but they can be edited and then saved under a different (file-based) configuration name.
Placing robot configurations in resources in this way ensures that the configurations appropriate to your opmodes are available wherever your opmode code happens to travel; you no longer need build the needed config from scratch each time. To create a resource-based configuration, you can copy an XML configuration from your phone and paste it verbatim into the appropriate Android Studio directory (if they've been edited under 2.0, the necessary "type" attribute will have automatically been added), and / or you can edit the XML file by hand directly.
This approach is made even more useful with the new 'fix' and 'swap' functionality in the configuration editor UI. If a USB controller is present in a configuration but missing in action (ie: not connected) when the configuration is edited, but there's another unused USB controller of the same time which is attached, then a 'Fix' button will appear that when pressed will substitute the latter for the former in the configuration. Got a dead motor controller? Swap it out for a new one, edit the configuration, press 'Fix', and you're done. 'Swap' works in an analogous manner to allow interchange of like-typed USB controllers: it's more general, and consequently has a another nested screen in its user-interface. You won't see both 'Fix' and 'Swap' appear simultaneously: think of the former as a special case of the latter.
Any .XML file found in (e.g.) TeamCode\res\xml\myConfig.xml whose root XML element is "Robot" and which has a "type" attribute with the value "FirstInspires-FTC" will appear as one of the available configurations in the "Configure Robot..." user interface. If the root "Robot" element also has a "name" attribute, then the value of that attribute is used as the name of the configuration; otherwise, the name of the XML resource file is used. Robot configurations found in resources cannot be edited and saved using the UI on the RC phone, but they can be edited and then saved under a different (file-based) configuration name.
Placing robot configurations in resources in this way ensures that the configurations appropriate to your opmodes are available wherever your opmode code happens to travel; you no longer need build the needed config from scratch each time. To create a resource-based configuration, you can copy an XML configuration from your phone and paste it verbatim into the appropriate Android Studio directory (if they've been edited under 2.0, the necessary "type" attribute will have automatically been added), and / or you can edit the XML file by hand directly.
This approach is made even more useful with the new 'fix' and 'swap' functionality in the configuration editor UI. If a USB controller is present in a configuration but missing in action (ie: not connected) when the configuration is edited, but there's another unused USB controller of the same time which is attached, then a 'Fix' button will appear that when pressed will substitute the latter for the former in the configuration. Got a dead motor controller? Swap it out for a new one, edit the configuration, press 'Fix', and you're done. 'Swap' works in an analogous manner to allow interchange of like-typed USB controllers: it's more general, and consequently has a another nested screen in its user-interface. You won't see both 'Fix' and 'Swap' appear simultaneously: think of the former as a special case of the latter.
Comment