Announcement

Collapse
No announcement yet.

Improved(?) SDK Interface

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Improved(?) SDK Interface

    I have created a modified version of the SDK files which I think would be useful. It can be found here:
    https://github.com/illinois-ftc/demo_hphs_robot,
    with documentation here: http://illinois-ftc.github.io/demo_hphs_robot/

    The notable changes from the existing SDK are the following:
    • FtcOpModeRegister.java should never need to be edited-instead, the ActiveOpMode annotation is used to mark a class for display in the menu, with a title, like so:
      Code:
      @ActiveOpMode("TeleOp17")
      public class DemoAuto ...
    • Motor/servo/sensor initialization code is not duplicated across op modes-instead a single RobotHardware class is created, with public properties and an initalizeHardware method to set the properties. Class declaration looks the following:
      Code:
      public class DemoAuto extends RobotLinearOpMode<DemoRobot> ...
      //or
      public class DemoTeleop extends RobotOpMode<DemoRobot> ...
    • Servo/sensor initialization is consistent between linear and loop op modes:
      Code:
      public void initializeRobot() {
       ...
      }


    Please let me know what you think of these modifications, and any changes/improvements you would like to see. I also plan to create a tool which is able to automatically generate the subclass of RobotHardware based on a robot XML file.

  • #2
    Nice job, though some questions:
    Does the FtcOpModeRegister automatically fallback to a class name or something like that, if someone leaves the name blank?
    Can a constructor be added with the overload of the HardwareMap, so if forget to call instantiateHardware(hardwareMap) the objects are not null, if we used to constructor overload?

    Comment


    • #3
      Originally posted by dmssargent View Post
      Nice job, though some questions:
      Does the FtcOpModeRegister automatically fallback to a class name or something like that, if someone leaves the name blank?
      Can a constructor be added with the overload of the HardwareMap, so if forget to call instantiateHardware(hardwareMap) the objects are not null, if we used to constructor overload?
      Regarding the first point, if the name is not included, the code will not compile-a string must be passed to the annotation for the code to compile.
      I corrected RobotOpMode and RobotLinearOpMode to initialize the robot object in the constructor; however, it cannot instantiate the hardware in a constructor-that must be done separately, and RobotOpMode and RobotLinearOpMode both handle calling instantiateHardware(hardwareMap) before any user code runs.

      Comment


      • #4
        Originally posted by maths222 View Post
        Regarding the first point, if the name is not included, the code will not compile-a string must be passed to the annotation for the code to compile.
        I corrected RobotOpMode and RobotLinearOpMode to initialize the robot object in the constructor; however, it cannot instantiate the hardware in a constructor-that must be done separately, and RobotOpMode and RobotLinearOpMode both handle calling instantiateHardware(hardwareMap) before any user code runs.
        What happens if the name is specified as an empty string (aka ""), which is the default value of string if it has not initialized? Will the OpMode register that as a blank option?

        Comment


        • #5
          Originally posted by dmssargent View Post
          What happens if the name is specified as an empty string (aka ""), which is the default value of string if it has not initialized? Will the OpMode register that as a blank option?
          I'm not quite sure what you are asking-the only way to end up with a blank string is to type it in yourself-nothing is going to mysteriously put it there.

          Comment


          • #6
            Code:
            @ActiveOpMode(AutoRotateOp.NAME)
            public class AutoRotateOp extends OpMode {
              public static final String NAME = "";
              ...
            }
            which another variation which could be:
            Code:
            @ActiveOpMode("")
            public class AutoRotateOpFoo extends OpMode {...}
            Nevermind that question, I just misread the code, the above declarations should also be valid. Is there any special value of a String that causes the class name to be used instead, or (since I am not seeing that in the code) will there be?

            Comment


            • #7
              Originally posted by dmssargent View Post
              Nevermind that question, I just misread the code, the above declarations should also be valid. Is there any special value of a String that causes the class name to be used instead, or (since I am not seeing that in the code) will there be?
              If the string is omitted/null, I will make it use the class name.

              Comment


              • #8
                I have updated it. It actually cannot use null, so I went with the empty string as the default value; If you want to use it, don't include a parameter-that is much clearer than using the empty string in your own classes.

                Comment


                • #9
                  There seems to be a bug in which the usage of Guava throws off the loader, and the annotation readers crashs and burns, due to Android not allowing retrying failed classes.

                  Comment


                  • #10
                    Originally posted by dmssargent View Post
                    There seems to be a bug in which the usage of Guava throws off the loader, and the annotation readers crashs and burns, due to Android not allowing retrying failed classes.
                    Do you have a stack trace/error log?

                    Comment


                    • #11
                      This error seems to be hard to get an log for, but I got after quite a few tries (note that I added a line to log to tried class):
                      Code:
                      08-31 17:32:07.857    4641-5093/com.qualcomm.ftcrobotcontroller I/CLASSES﹕ class com.google.common.util.concurrent.FuturesGetChecked$1
                      08-31 17:32:07.857    4641-5093/com.qualcomm.ftcrobotcontroller I/CLASSES﹕ interface com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidator
                      08-31 17:32:07.860    4641-5093/com.qualcomm.ftcrobotcontroller I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidatorHolder$ClassValueValidator$1>
                      08-31 17:32:07.860    4641-5093/com.qualcomm.ftcrobotcontroller I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidatorHolder$ClassValueValidator$1>
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ java.lang.ClassNotFoundException: com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidatorHolder$ClassValueValidator$1
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.Class.classForName(Native Method)
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.Class.forName(Class.java:309)
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at com.qualcomm.ftcrobotcontroller.opmodes.FtcOpModeRegister$1.run(FtcOpModeRegister.java:252)
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidatorHolder$ClassValueValidator$1" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.qualcomm.ftcrobotcontroller-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ ... 4 more
                      08-31 17:32:07.861    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ Suppressed: java.lang.NoClassDefFoundError: com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidatorHolder$ClassValueValidator$1
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at dalvik.system.DexFile.defineClassNative(Native Method)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at dalvik.system.DexFile.defineClass(DexFile.java:226)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at dalvik.system.DexPathList.findClass(DexPathList.java:321)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ ... 6 more
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ Suppressed: java.lang.ClassNotFoundException: com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidatorHolder$ClassValueValidator$1
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.Class.classForName(Native Method)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ ... 5 more
                      08-31 17:32:07.862    4641-5093/com.qualcomm.ftcrobotcontroller W/System.err﹕ Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

                      Comment

                      Working...
                      X