Announcement

Collapse
No announcement yet.

Odd problem with Core Device Interface (seems to impact both Color Sensor and ODS)

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Earlier someone posted once instantiated the sensor will take up time. Hardwaremap has remove, put, rebuilddevicenames. Would remove take the sensor out of consideration? Could you then add it back in with put and rebuild?

    Comment


    • #32
      Originally posted by 3805Mentor View Post
      Earlier someone posted once instantiated the sensor will take up time. Hardwaremap has remove, put, rebuilddevicenames. Would remove take the sensor out of consideration? Could you then add it back in with put and rebuild?
      No, I don't think that would work. Removing the sensor from the HardwareMap does not result in it going away, just making it inaccessible from the HardwareMap. In the old drivers for Modern Robotics I2C sensors (the ones besides compass and range), the constructor registers the sensor object to handle the port ready callbacks from the DIM. So even if the HardwareMap no longer held a reference to the sensor object, the DIM object still would and it would continue to issue I2C reads as often as it could. You could try deregistering the device for I2C port ready callbacks and then manually re-registering it when you want to start reading values from it. Here is an example piece of code that deregisters the callback for a color sensor and re-registers the callback for a gyro sensor. We aren't using any of these devices, so I am not sure whether it is possible to do this, or whether it actually prevents the unnecessary requests from being sent, but it's worth a shot.
      Code:
      [COLOR=#cc7832]import [/COLOR]com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cColorSensor[COLOR=#cc7832];
      [/COLOR][COLOR=#cc7832]import [/COLOR]com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro[COLOR=#cc7832];
      [/COLOR][COLOR=#cc7832]import [/COLOR]com.qualcomm.robotcore.eventloop.opmode.OpMode[COLOR=#cc7832];
      [/COLOR][COLOR=#cc7832]
      [/COLOR][COLOR=#cc7832]public class [/COLOR]TestOpMode [COLOR=#cc7832]extends [/COLOR]OpMode {
        [COLOR=#cc7832]public void [/COLOR][COLOR=#ffc66d]init[/COLOR]() {
          [COLOR=#cc7832]final [/COLOR]ModernRoboticsI2cColorSensor colorSensor = (ModernRoboticsI2cColorSensor)[COLOR=#cc7832]this[/COLOR].[COLOR=#9876aa]hardwareMap[/COLOR].get([COLOR=#6a8759]"color"[/COLOR])[COLOR=#cc7832];
      [/COLOR]    colorSensor.getI2cController().deregisterForPortReadyCallback(colorSensor.getPort())[COLOR=#cc7832];
      [/COLOR][COLOR=#cc7832]    final [/COLOR]ModernRoboticsI2cGyro gyroSensor = (ModernRoboticsI2cGyro)[COLOR=#cc7832]this[/COLOR].[COLOR=#9876aa]hardwareMap[/COLOR].get([COLOR=#6a8759]"gyro"[/COLOR])[COLOR=#cc7832];
      [/COLOR]    gyroSensor.getI2cController().registerForI2cPortReadyCallback(gyroSensor[COLOR=#cc7832], [/COLOR]gyroSensor.getPort())[COLOR=#cc7832];
      [/COLOR]  }
      [COLOR=#cc7832]  public void [/COLOR][COLOR=#ffc66d]loop[/COLOR]() {}
      }

      Comment


      • #33
        We have the same problem. We have had a couple of side posts with mikets - he has been a great help. I am finally able to post to the forum, so...
        We tested with an opmode based on TimerTest in this tread. We have 2 I2C devices and see ~100ms between gyro update rate when in power mode (RUN_WITHOUT_ENCODERS) set to 0.5. We see similar numbers in speed mode (RUN_USING_ENCODERS) set to 0.4 with maxSpeed 3000. These settings give 1 full turn in ~ 3.2s, and we see ~11 degree steps.
        This is clearly unusable for PID based control for anything other than very slow turn rates.
        We have a simple proportional only controller with a loop break if gyro heading <= THRESH. The threshold is 2 degrees. Quite often, we completely miss diving into this condition and end up with oscillation.

        Does anyone know if FTC is looking into this? Is it likely to be in the FTC SDK or in the CDIM firmware?
        We are considering separating the 2 I2C devices on to two separate CDIMs - seems a huge waste given all the CDIM inputs, but...
        Any thoughts on whether or not this should give improvement over 2 I2Cs on 1 CDIM?

        Our bot configuration has:
        -3 motor controllers
        --2 rear drive wheels (AndyMark motors)
        --2 shooter motors (AndyMark)
        --1 sweeper/1 elevator (Tetrix motors)
        -1 servo controller
        -- 2 connected servos
        -1 CDIM
        -- 1 MR I2C gyro
        -- 1 MR I2C color sensor

        Comment


        • #34
          Modern Robotics has conducted a series of tests to determine the throughput of the Core Device Interface Module (CDIM) hardware/firmware read requests for analog and I2C sensor ports. These tests were done using Windows desktop PC programmed with C++ and measure the time from issuing a read request to receiving the data back so the time includes the USB transmission times and the time taken by the CDIM firmware to process the read request. Each test read the sensor 1,000 times.

          Analog Sensor Ports
          8 analog ports, A0 - A7 were read each time in one read transaction so it did not matter how many analog sensors were attached, all 8 port values were returned every time.
          The average time to read all 8 analog sensor ports in one transaction was 1.5ms.

          I2C Sensor Ports
          The test program read one I2C sensor in each read transactions. It is possible to issue multiple I2C read requests in one transaction but this feature was not used in these tests. Tests were run using multiple Modern Robotics color sensors and Modern Robotics gyro sensors. Each I2C read request returned 8 bytes of data from the sensor.
          The average time to read an I2C sensor was 4.5ms.

          These results show the times taken to read a sensor port and do not include the additional times needed by Android and the SDK to process read transactions.

          Comment


          • #35
            Originally posted by Modern Robotics Support View Post
            Modern Robotics has conducted a series of tests to determine the throughput of the Core Device Interface Module (CDIM) hardware/firmware read requests for analog and I2C sensor ports. These tests were done using Windows desktop PC programmed with C++ and measure the time from issuing a read request to receiving the data back so the time includes the USB transmission times and the time taken by the CDIM firmware to process the read request. Each test read the sensor 1,000 times.

            Analog Sensor Ports
            8 analog ports, A0 - A7 were read each time in one read transaction so it did not matter how many analog sensors were attached, all 8 port values were returned every time.
            The average time to read all 8 analog sensor ports in one transaction was 1.5ms.

            I2C Sensor Ports
            The test program read one I2C sensor in each read transactions. It is possible to issue multiple I2C read requests in one transaction but this feature was not used in these tests. Tests were run using multiple Modern Robotics color sensors and Modern Robotics gyro sensors. Each I2C read request returned 8 bytes of data from the sensor.
            The average time to read an I2C sensor was 4.5ms.

            These results show the times taken to read a sensor port and do not include the additional times needed by Android and the SDK to process read transactions.
            Thanks for responding to this thread. The concern is not the time it takes to read an I2C sensor. It's the returned value that doesn't change for 300 msec. I think there is an issue with the FTC SDK software. I think it is caching device data and returning the data from its cache. So if the cache is not updated in a timely manner, the data is stale. Would you try running this test code with multiple I2C sensors?
            Code:
            [COLOR=#000080][B]package [/B][/COLOR]samples;
            
            [COLOR=#000080][B]import [/B][/COLOR]android.util.Log;
            
            [COLOR=#000080][B]import [/B][/COLOR]com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro;
            [COLOR=#000080][B]import [/B][/COLOR][COLOR=#808000]com.qualcomm.robotcore.eventloop.opmode.Disabled[/COLOR];
            [COLOR=#000080][B]import [/B][/COLOR]com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
            [COLOR=#000080][B]import [/B][/COLOR][COLOR=#808000]com.qualcomm.robotcore.eventloop.opmode.TeleOp[/COLOR];
            [COLOR=#000080][B]import [/B][/COLOR]com.qualcomm.robotcore.hardware.DcMotor;
            
            [COLOR=#808000]@TeleOp[/COLOR](name=[COLOR=#008000][B]"Test: Simple Sensor Sample Time"[/B][/COLOR], group=[COLOR=#008000][B]"3543TestSamples"[/B][/COLOR])
            [COLOR=#808000]@Disabled
            [/COLOR][COLOR=#000080][B]public class [/B][/COLOR]SensorSampleTimeTest [COLOR=#000080][B]extends [/B][/COLOR]LinearOpMode
            {
                [COLOR=#000080][B]private enum [/B][/COLOR]SensorType
                {
                    [COLOR=#660e7a][B][I]DRIVEBASE_ENCODERS[/I][/B][/COLOR],
                    [COLOR=#660e7a][B][I]GYRO
            [/I][/B][/COLOR][COLOR=#660e7a][B][I]    [/I][/B][/COLOR]}
            
                [COLOR=#000080][B]private static final [/B][/COLOR]String [COLOR=#660e7a][B][I]TAG [/I][/B][/COLOR]= [COLOR=#008000][B]"TrcDbg"[/B][/COLOR];
                [COLOR=#000080][B]private static final double [/B][/COLOR][COLOR=#660e7a][B][I]DRIVE_POWER [/I][/B][/COLOR]= [COLOR=#0000ff]0.2[/COLOR];
                [COLOR=#000080][B]private static final double [/B][/COLOR][COLOR=#660e7a][B][I]TURN_POWER [/I][/B][/COLOR]= [COLOR=#0000ff]0.5[/COLOR];
                [COLOR=#000080][B]private static [/B][/COLOR]SensorType [COLOR=#660e7a][I]sensorType [/I][/COLOR]= SensorType.[COLOR=#660e7a][B][I]GYRO[/I][/B][/COLOR];
                [COLOR=#000080][B]private static final [/B][/COLOR]DcMotor.Direction [COLOR=#660e7a][B][I]LEFTWHEEL_DIRECTION [/I][/B][/COLOR]= DcMotor.Direction.[COLOR=#660e7a][B][I]FORWARD[/I][/B][/COLOR];
                [COLOR=#000080][B]private static final [/B][/COLOR]DcMotor.Direction [COLOR=#660e7a][B][I]RIGHTWHEEL_DIRECTION [/I][/B][/COLOR]= DcMotor.Direction.[COLOR=#660e7a][B][I]REVERSE[/I][/B][/COLOR];
            
                [COLOR=#000080][B]private [/B][/COLOR]DcMotor [COLOR=#660e7a][B]lfWheel[/B][/COLOR];
                [COLOR=#000080][B]private [/B][/COLOR]DcMotor [COLOR=#660e7a][B]rfWheel[/B][/COLOR];
                [COLOR=#000080][B]private [/B][/COLOR]DcMotor [COLOR=#660e7a][B]lrWheel[/B][/COLOR];
                [COLOR=#000080][B]private [/B][/COLOR]DcMotor [COLOR=#660e7a][B]rrWheel[/B][/COLOR];
                [COLOR=#000080][B]private [/B][/COLOR]ModernRoboticsI2cGyro [COLOR=#660e7a][B]gyro[/B][/COLOR];
            
                [COLOR=#000080][B]public void [/B][/COLOR]runOpMode()
                {
                    initRobot();
            
                    waitForStart();
            
                    [COLOR=#000080][B]long [/B][/COLOR]minLoopInterval = Long.[COLOR=#660e7a][B][I]MAX_VALUE[/I][/B][/COLOR];
                    [COLOR=#000080][B]long [/B][/COLOR]maxLoopInterval = Long.[COLOR=#660e7a][B][I]MIN_VALUE[/I][/B][/COLOR];
                    [COLOR=#000080][B]long [/B][/COLOR]loopCount = [COLOR=#0000ff]0[/COLOR];
                    [COLOR=#000080][B]long [/B][/COLOR]prevLoopTime = [COLOR=#0000ff]0[/COLOR];
            
                    [COLOR=#000080][B]long [/B][/COLOR]minSampleInterval = Long.[COLOR=#660e7a][B][I]MAX_VALUE[/I][/B][/COLOR];
                    [COLOR=#000080][B]long [/B][/COLOR]maxSampleInterval = Long.[COLOR=#660e7a][B][I]MIN_VALUE[/I][/B][/COLOR];
                    [COLOR=#000080][B]long [/B][/COLOR]sampleCount = [COLOR=#0000ff]0[/COLOR];
                    [COLOR=#000080][B]long [/B][/COLOR]prevSampleTime;
            
                    [COLOR=#000080][B]long [/B][/COLOR]startTime = System.[I]nanoTime[/I]();
                    prevSampleTime = startTime;
                    [COLOR=#000080][B]int [/B][/COLOR]prevSample = getSensorValue();
            
                    [COLOR=#000080][B]while [/B][/COLOR](opModeIsActive())
                    {
                        [COLOR=#000080][B]long [/B][/COLOR]currTime = System.[I]nanoTime[/I]();
                        [COLOR=#000080][B]int [/B][/COLOR]currSample = getSensorValue();
                        [COLOR=#000080][B]if [/B][/COLOR](prevLoopTime != [COLOR=#0000ff]0[/COLOR])
                        {
                            [COLOR=#000080][B]long [/B][/COLOR]loopInterval = currTime - prevLoopTime;
            
                            [COLOR=#000080][B]if [/B][/COLOR](currSample != prevSample)
                            {
                                [COLOR=#000080][B]long [/B][/COLOR]sampleTime = currTime - prevSampleTime;
                                sampleCount++;
                                prevSample = currSample;
                                prevSampleTime = currTime;
                                [COLOR=#000080][B]if [/B][/COLOR](sampleTime < minSampleInterval)
                                    minSampleInterval = sampleTime;
                                [COLOR=#000080][B]else if [/B][/COLOR](sampleTime > maxSampleInterval)
                                    maxSampleInterval = sampleTime;
                            }
            
                            [COLOR=#000080][B]if [/B][/COLOR](loopInterval < minLoopInterval)
                            {
                                minLoopInterval = loopInterval;
                            }
                            [COLOR=#000080][B]else if [/B][/COLOR](loopInterval > maxLoopInterval)
                            {
                                maxLoopInterval = loopInterval;
                            }
                            runRobot(String.[I]format[/I]([COLOR=#008000][B]"[%4d:%7.3f] LoopInterval=%7.3f, "[/B][/COLOR],
                                    loopCount, (currTime - startTime)/[COLOR=#0000ff]1000000.0[/COLOR], loopInterval/[COLOR=#0000ff]1000000.0[/COLOR]));
                        }
            
                        prevLoopTime = currTime;
                        loopCount++;
                    }
                    stopRobot();
            
                    [COLOR=#000080][B]long [/B][/COLOR]endTime = System.[I]nanoTime[/I]();
                    Log.[I]i[/I]([COLOR=#660e7a][B][I]TAG[/I][/B][/COLOR], String.[I]format[/I](
                            [COLOR=#008000][B]"Loop: MinInterval=%7.3f, MaxInterval=%7.3f, AvgInterval=%7.3f"[/B][/COLOR],
                            minLoopInterval/[COLOR=#0000ff]1000000.0[/COLOR], maxLoopInterval/[COLOR=#0000ff]1000000.0[/COLOR],
                            (endTime - startTime)/[COLOR=#0000ff]1000000.0[/COLOR]/loopCount));
                    Log.[I]i[/I]([COLOR=#660e7a][B][I]TAG[/I][/B][/COLOR], String.[I]format[/I](
                            [COLOR=#008000][B]"Sensor: MinSampleInterval=%7.3f, MaxSampleInterval=%7.3f, AvgSampleInterval=%7.3f"[/B][/COLOR],
                            minSampleInterval/[COLOR=#0000ff]1000000.0[/COLOR], maxSampleInterval/[COLOR=#0000ff]1000000.0[/COLOR],
                            (endTime - startTime)/[COLOR=#0000ff]1000000.0[/COLOR]/sampleCount));
                }   [COLOR=#808080][I]//runOpMode
            [/I][/COLOR][COLOR=#808080][I]
            [/I][/COLOR][COLOR=#808080][I]    [/I][/COLOR][COLOR=#000080][B]private void [/B][/COLOR]initRobot()
                {
                    [COLOR=#660e7a][B]lfWheel [/B][/COLOR]= [COLOR=#660e7a][B]hardwareMap[/B][/COLOR].[COLOR=#660e7a][B]dcMotor[/B][/COLOR].get([COLOR=#008000][B]"lfWheel"[/B][/COLOR]);
                    [COLOR=#660e7a][B]rfWheel [/B][/COLOR]= [COLOR=#660e7a][B]hardwareMap[/B][/COLOR].[COLOR=#660e7a][B]dcMotor[/B][/COLOR].get([COLOR=#008000][B]"rfWheel"[/B][/COLOR]);
                    [COLOR=#660e7a][B]lrWheel [/B][/COLOR]= [COLOR=#660e7a][B]hardwareMap[/B][/COLOR].[COLOR=#660e7a][B]dcMotor[/B][/COLOR].get([COLOR=#008000][B]"lrWheel"[/B][/COLOR]);
                    [COLOR=#660e7a][B]rrWheel [/B][/COLOR]= [COLOR=#660e7a][B]hardwareMap[/B][/COLOR].[COLOR=#660e7a][B]dcMotor[/B][/COLOR].get([COLOR=#008000][B]"rrWheel"[/B][/COLOR]);
                    [COLOR=#660e7a][B]lfWheel[/B][/COLOR].setDirection([COLOR=#660e7a][B][I]LEFTWHEEL_DIRECTION[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]lrWheel[/B][/COLOR].setDirection([COLOR=#660e7a][B][I]LEFTWHEEL_DIRECTION[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]rfWheel[/B][/COLOR].setDirection([COLOR=#660e7a][B][I]RIGHTWHEEL_DIRECTION[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]rrWheel[/B][/COLOR].setDirection([COLOR=#660e7a][B][I]RIGHTWHEEL_DIRECTION[/I][/B][/COLOR]);
            
                    [COLOR=#660e7a][B]lfWheel[/B][/COLOR].setMode(DcMotor.RunMode.[COLOR=#660e7a][B][I]STOP_AND_RESET_ENCODER[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]rfWheel[/B][/COLOR].setMode(DcMotor.RunMode.[COLOR=#660e7a][B][I]STOP_AND_RESET_ENCODER[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]lrWheel[/B][/COLOR].setMode(DcMotor.RunMode.[COLOR=#660e7a][B][I]STOP_AND_RESET_ENCODER[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]rrWheel[/B][/COLOR].setMode(DcMotor.RunMode.[COLOR=#660e7a][B][I]STOP_AND_RESET_ENCODER[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]lfWheel[/B][/COLOR].setMode(DcMotor.RunMode.[COLOR=#660e7a][B][I]RUN_WITHOUT_ENCODER[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]rfWheel[/B][/COLOR].setMode(DcMotor.RunMode.[COLOR=#660e7a][B][I]RUN_WITHOUT_ENCODER[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]lrWheel[/B][/COLOR].setMode(DcMotor.RunMode.[COLOR=#660e7a][B][I]RUN_WITHOUT_ENCODER[/I][/B][/COLOR]);
                    [COLOR=#660e7a][B]rrWheel[/B][/COLOR].setMode(DcMotor.RunMode.[COLOR=#660e7a][B][I]RUN_WITHOUT_ENCODER[/I][/B][/COLOR]);
            
                    [COLOR=#660e7a][B]gyro [/B][/COLOR]= (ModernRoboticsI2cGyro)[COLOR=#660e7a][B]hardwareMap[/B][/COLOR].[COLOR=#660e7a][B]gyroSensor[/B][/COLOR].get([COLOR=#008000][B]"gyroSensor"[/B][/COLOR]);
                    [COLOR=#660e7a][B]gyro[/B][/COLOR].resetZAxisIntegrator();
                }   [COLOR=#808080][I]//initRobot
            [/I][/COLOR][COLOR=#808080][I]
            [/I][/COLOR][COLOR=#808080][I]    [/I][/COLOR][COLOR=#000080][B]private int [/B][/COLOR]getSensorValue()
                {
                    [COLOR=#000080][B]int [/B][/COLOR]value = [COLOR=#0000ff]0[/COLOR];
            
                    [COLOR=#000080][B]switch [/B][/COLOR]([COLOR=#660e7a][I]sensorType[/I][/COLOR])
                    {
                        [COLOR=#000080][B]case [/B][/COLOR][COLOR=#660e7a][B][I]DRIVEBASE_ENCODERS[/I][/B][/COLOR]:
                            value = ([COLOR=#660e7a][B]lfWheel[/B][/COLOR].getCurrentPosition() + [COLOR=#660e7a][B]rfWheel[/B][/COLOR].getCurrentPosition() +
                                     [COLOR=#660e7a][B]lrWheel[/B][/COLOR].getCurrentPosition() + [COLOR=#660e7a][B]rrWheel[/B][/COLOR].getCurrentPosition())/[COLOR=#0000ff]4[/COLOR];
                            [COLOR=#000080][B]break[/B][/COLOR];
            
                        [COLOR=#000080][B]case [/B][/COLOR][COLOR=#660e7a][B][I]GYRO[/I][/B][/COLOR]:
                            value = -[COLOR=#660e7a][B]gyro[/B][/COLOR].getIntegratedZValue();
                            [COLOR=#000080][B]break[/B][/COLOR];
                    }
            
                    [COLOR=#000080][B]return [/B][/COLOR]value;
                }   [COLOR=#808080][I]//getSensorValue
            [/I][/COLOR][COLOR=#808080][I]
            [/I][/COLOR][COLOR=#808080][I]    [/I][/COLOR][COLOR=#000080][B]private void [/B][/COLOR]runRobot(String prefix)
                {
                    [COLOR=#000080][B]switch [/B][/COLOR]([COLOR=#660e7a][I]sensorType[/I][/COLOR])
                    {
                        [COLOR=#000080][B]case [/B][/COLOR][COLOR=#660e7a][B][I]DRIVEBASE_ENCODERS[/I][/B][/COLOR]:
                            [COLOR=#808080][I]//
            [/I][/COLOR][COLOR=#808080][I]                // Driving forward and checking encoders.
            [/I][/COLOR][COLOR=#808080][I]                //
            [/I][/COLOR][COLOR=#808080][I]                [/I][/COLOR][COLOR=#660e7a][B]lfWheel[/B][/COLOR].setPower([COLOR=#660e7a][B][I]DRIVE_POWER[/I][/B][/COLOR]);
                            [COLOR=#660e7a][B]rfWheel[/B][/COLOR].setPower([COLOR=#660e7a][B][I]DRIVE_POWER[/I][/B][/COLOR]);
                            [COLOR=#660e7a][B]lrWheel[/B][/COLOR].setPower([COLOR=#660e7a][B][I]DRIVE_POWER[/I][/B][/COLOR]);
                            [COLOR=#660e7a][B]rrWheel[/B][/COLOR].setPower([COLOR=#660e7a][B][I]DRIVE_POWER[/I][/B][/COLOR]);
                            Log.[I]i[/I]([COLOR=#660e7a][B][I]TAG[/I][/B][/COLOR], prefix + String.[I]format[/I]([COLOR=#008000][B]"lf=%d, rf=%d, lr=%d, rr=%d"[/B][/COLOR],
                                    [COLOR=#660e7a][B]lfWheel[/B][/COLOR].getCurrentPosition(), [COLOR=#660e7a][B]rfWheel[/B][/COLOR].getCurrentPosition(),
                                    [COLOR=#660e7a][B]lrWheel[/B][/COLOR].getCurrentPosition(), [COLOR=#660e7a][B]rrWheel[/B][/COLOR].getCurrentPosition()));
                            [COLOR=#000080][B]break[/B][/COLOR];
            
                        [COLOR=#000080][B]case [/B][/COLOR][COLOR=#660e7a][B][I]GYRO[/I][/B][/COLOR]:
                            [COLOR=#808080][I]//
            [/I][/COLOR][COLOR=#808080][I]                // Turning right and checking gyro.
            [/I][/COLOR][COLOR=#808080][I]                //
            [/I][/COLOR][COLOR=#808080][I]                [/I][/COLOR][COLOR=#660e7a][B]lfWheel[/B][/COLOR].setPower([COLOR=#660e7a][B][I]TURN_POWER[/I][/B][/COLOR]);
                            [COLOR=#660e7a][B]lrWheel[/B][/COLOR].setPower([COLOR=#660e7a][B][I]TURN_POWER[/I][/B][/COLOR]);
                            [COLOR=#660e7a][B]rfWheel[/B][/COLOR].setPower(-[COLOR=#660e7a][B][I]TURN_POWER[/I][/B][/COLOR]);
                            [COLOR=#660e7a][B]rrWheel[/B][/COLOR].setPower(-[COLOR=#660e7a][B][I]TURN_POWER[/I][/B][/COLOR]);
                            Log.[I]i[/I]([COLOR=#660e7a][B][I]TAG[/I][/B][/COLOR], prefix + String.[I]format[/I]([COLOR=#008000][B]"heading=%d"[/B][/COLOR], -[COLOR=#660e7a][B]gyro[/B][/COLOR].getIntegratedZValue()));
                            [COLOR=#000080][B]break[/B][/COLOR];
                    }
                }   [COLOR=#808080][I]//runRobot
            [/I][/COLOR][COLOR=#808080][I]
            [/I][/COLOR][COLOR=#808080][I]    [/I][/COLOR][COLOR=#000080][B]private void [/B][/COLOR]stopRobot()
                {
                    [COLOR=#660e7a][B]lfWheel[/B][/COLOR].setPower([COLOR=#0000ff]0.0[/COLOR]);
                    [COLOR=#660e7a][B]lrWheel[/B][/COLOR].setPower([COLOR=#0000ff]0.0[/COLOR]);
                    [COLOR=#660e7a][B]rfWheel[/B][/COLOR].setPower([COLOR=#0000ff]0.0[/COLOR]);
                    [COLOR=#660e7a][B]rrWheel[/B][/COLOR].setPower([COLOR=#0000ff]0.0[/COLOR]);
                }   [COLOR=#808080][I]//stopRobot
            [/I][/COLOR][COLOR=#808080][I]
            [/I][/COLOR]}   [COLOR=#808080][I]//class SensorSampleTimeTest[/I][/COLOR]

            Comment


            • #36
              BTW, when you plug in multiple I2C devices to the CDI module, you just need to "declare" them in the robot config. That's all it takes to degrade the sampling interval time of the gyro.

              Comment


              • #37
                Before I conduct my own set of experiments exploring workarounds for the stale data issue that is being discussed. It seems to me that when the various I2C objects are being constructed they are being "engaged" and thus using USB bandwidth which is the problem being actively discussed (so far as I can see).

                Has anyone trying calling disengage of after acquiring I2C devices that are not correctly in use, and then re-calling engage before the programmer starts using the device. Keep in mind that "disengage"/"engage" are considered protected methods, and therefore you have to implement a method of disengaging Java modifier protection or create a forward delegate providing access to those methods.

                I would not recommend this be done by someone inexperienced at programming since you are running the risk of breaking something in the internal SDK by performing this experiment.

                Comment


                • #38
                  Update: I ran a test tonight with a similar TimerTest, but with the color sensor removed from the robot config. Sample times went from 100ms (with gyro and color sensor) to 30-40 ms (with just gyro. We are going to try to add a second CDIM. Huge overkill to have all those ports on 2 modules just to each have 1 device connected, but if it gives that much improvement - with 1.5 weeks to states, then I'll take it.

                  I have read some of the discussions on the I2C handling of read and write, but have not dug into any of the code deeply.
                  Does anyone know if other combinations (that don't include a gyro) are affected in a similar manner?

                  Comment


                  • #39
                    Originally posted by FTC7253 View Post
                    Update: I ran a test tonight with a similar TimerTest, but with the color sensor removed from the robot config. Sample times went from 100ms (with gyro and color sensor) to 30-40 ms (with just gyro. We are going to try to add a second CDIM. Huge overkill to have all those ports on 2 modules just to each have 1 device connected, but if it gives that much improvement - with 1.5 weeks to states, then I'll take it.

                    I have read some of the discussions on the I2C handling of read and write, but have not dug into any of the code deeply.
                    Does anyone know if other combinations (that don't include a gyro) are affected in a similar manner?
                    There may be an easier way. I was amazed I didn't think of it earlier. I was brainstorming with a couple mentors in our team about this problem. We were discussing which I2C devices to remove from the I2C bus and how we will replace the lost functionality with something else. Then it dawned on me that instead of moving other sensors off the I2C bus, why not move the gyro off the I2C bus? It happens that our FRC team has a lot of "obsolete" analog gyros floating around. I quickly hooked one up and it did work. I checked my gyro test and I see different values on EVERY SINGLE LOOP when the robot is spinning.

                    Comment


                    • #40
                      What manufacturer and class are these "obsolete" gyros?

                      Comment


                      • #41
                        Originally posted by FTC7253 View Post
                        What manufacturer and class are these "obsolete" gyros?
                        Not OP, but maybe http://www.robotshop.com/en/300s-sin...ro-sensor.html ?
                        John McDonnell
                        Volunteer, former mentor

                        Comment


                        • #42
                          Originally posted by FTC7253 View Post
                          What manufacturer and class are these "obsolete" gyros?
                          I no longer know what manufacturer of that gyro is. It's a blue board and it was in Kit of Parts every year since 2010 for the cRIO until we switched to RoboRIO.
                          In any case, any analog gyro would work including the one JohnMcDonnell suggested. In fact, that gyro has very similar spec to the one we are using.

                          Comment


                          • #43
                            It is this gyro:
                            http://wpilib.screenstepslive.com/s/...ving-direction
                            I believe it has an Analog Device chip on it. Don't know the part number on the chip though. In any case, like I said, any analog gyro would work.

                            Comment


                            • #44
                              Since it would appear that these don't include on-board integration, you'll have to handle that yourself in software. Ensuring timing and signal delays will be "interesting"...
                              Technical Coach, Newton Busters FTC 10138, FLL 3077
                              Chicago 'burbs, IL

                              Comment


                              • #45
                                From FTC Team 358's guide :
                                Accelerometer/Gyro
                                The sensor board in the 2012 FRC Kit of Parts hosts both an Analog Devices ADXL345 3-axis Digital Accelerometer and an Analog Devices ADW22307 1-axis Analog Gyroscope.
                                The AndyMark part number is (or was) AM-2067. There is a usage guide from AndyMark, and I found a datasheet for it, but the actual part isn't available on the AndyMark site or anywhere else, as far as I could tell.
                                John McDonnell
                                Volunteer, former mentor

                                Comment

                                Working...
                                X