Announcement

Collapse
No announcement yet.

MR Gyro - 200 to 250 mSec lag in changes of heading value? Need Help or experiences.

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

  • #16
    Originally posted by skatefriday View Post
    gyro.getHeading() is simply going to return the last cached heading read from the device.

    The driver for the gyro sits on a thread that continually reads the device if there's no other work to perform. This typically happens in roughly 10ms intervals. Can you please rerun your tests using a non-linear opmode?
    We tried putting the gyro loop into a non-linear opmode. The refresh rate was exactly the same as when we ran it in our linear opmode, which is about 140 ms between each getIntegratedZValue() change. If we are also running our motors, the refresh rate is closer to 250 ms.
    We also tested a new MR gyro to make sure it was not an individual hardware problem, but both experienced the same issue.

    Code:
       public void loop() {
            telemetry.addData("Status", "Running: " + runtime.toString());
    
            telemetry.addData("Heading ", robot.GetCurrentHeading());
            Log.d("heading ", String.valueOf(robot.GetCurrentHeading()));
            telemetry.update();
        }

    Comment


    • #17
      We gave up on tuning PID using the MR I2C gyro. We tried really hard but it's futile with that kind of sampling interval.

      Comment


      • #18
        This sounds like the same problem we are having and the same as http://ftcforum.usfirst.org/showthre...ensor-and-ODS).
        We only have two I2C devices on our CDIM - 1 MR gyro, and one MR color sensor. After we added the color sensor, our angle closure got worse.
        After reading these threads, I did testing and saw that the time between gyro updates was ~100ms. When turning at ~100deg/s in my test, this gave 10 degree gaps. Others indicate that the problem gets worse by 50-100ms with each added I2C device.
        I had tried code with not references to the color sensor, and with the color sensor unplugged, but no difference. When I remove the color sensor from the config, however, I get sample update times of 30-40 ms!!!
        One of our teams qualified for states this past weekend, so we may scavenge the CDIM from the other bot and see what mileage we get with two separate modules.

        Comment


        • #19
          We also use a MR color sensor with the MR gyro. We will have to try the same experiment - we built a test bed using just our second set of electronics, but did not attach a color sensor.

          Comment


          • #20
            7253 and 7152, please consider trying the workaround proposed by GearTicks in this post using the op mode here to see what effect (if any) disabling the color sensor has on the gyro readings.
            John McDonnell
            Volunteer, former mentor

            Comment


            • #21
              @JohnMcDonnell - I won't have the bot until tomorrow night. I will test then. Thanks

              Comment


              • #22
                @JohnMcDonnel - I tested with the deregister and register to disable/enable the color sensor. In our test opMode, the gyro sample time was ~35ms with the color sensor deregistered and ~100ms with it registered. Big difference. 35ms is awesome, but it is way better. I didn't get the chance to test with the opMode you provided - I will try it next meeting.
                I have to look into things a bit, but I am not sure the color sensor was behaving perfectly when it came back on. The led comes on when commanded, but it did not seem to find the line in the couple of test runs we did after a dereg/reg cycle.

                Comment


                • #23
                  Fix for slow gyro

                  My team had the same problem with this, our MR gyro was givin a new reading every 200-300ms which was really affecting our ability to do autonomous. Do we did some tests and I found that the Interface module was "overloaded" you could say. So we put the gyro on its own seperate interface module and we were able to bring the lag down to 50ms which is a big improvement and we can be much more accurate now. I hope this helps anyone!

                  Comment


                  • #24
                    Originally posted by DogbotsProgrammer View Post
                    My team had the same problem with this, our MR gyro was givin a new reading every 200-300ms which was really affecting our ability to do autonomous. Do we did some tests and I found that the Interface module was "overloaded" you could say. So we put the gyro on its own seperate interface module and we were able to bring the lag down to 50ms which is a big improvement and we can be much more accurate now. I hope this helps anyone!
                    Hi

                    this issue was discussed in detail, and resolved to some degree in the Beta Update 2.61

                    http://ftcforum.usfirst.org/showthre...ll=1#post33107

                    Are you still using the 2.4 SDK, or have you upgraded to the 2.61 beta?

                    Phil

                    Comment


                    • #25
                      Originally posted by Philbot View Post
                      Hi

                      this issue was discussed in detail, and resolved to some degree in the Beta Update 2.61

                      http://ftcforum.usfirst.org/showthre...ll=1#post33107

                      Are you still using the 2.4 SDK, or have you upgraded to the 2.61 beta?

                      Phil
                      At this point I would skip 2.61 Beta and go to 2.62 Alpha as the Beta had a USB timeout issue that was fatal to our robot. It shows itself as a "OpMode stuck in Loop" error, and several robots were randomly seeing it at a meet we had yesterday.

                      Comment


                      • #26
                        We ran 2.61 yesterday at a tournament and didn't have any issues with our system.

                        On another note has there been anything for sure about using a separate CDIM that only controls the gyro?

                        We currently have 2-ODS, 2-Color and 1-Gyro plugged into our CDIM but plan on adding 1 or 2 Range Sensors in the future. I read that some teams have isolated the gyro on another CDIM and that has significantly helped with the response time of the Gyro. Has this been tested at any length before we add another CDIM just for the purpose of putting a gyro on it?

                        Comment


                        • #27
                          Fix for Slow Gyro - 2 CDIM Help

                          Originally posted by DogbotsProgrammer View Post
                          My team had the same problem with this, our MR gyro was givin a new reading every 200-300ms which was really affecting our ability to do autonomous. Do we did some tests and I found that the Interface module was "overloaded" you could say. So we put the gyro on its own seperate interface module and we were able to bring the lag down to 50ms which is a big improvement and we can be much more accurate now. I hope this helps anyone!
                          My team tried this approach and were unable to get the sensors to be recognized with two CDIMs. Both CDIMs are recognized by the robot controller and they have distinctive names. We went so far as to test each of the CDIMs with the Core Device Discovery with sensors plugged in and were able to read and write as documented in the MR Sensor documentation. All of the "duplicate" i2c sensors have unique addresses. When we revert back to one CDIM and leave the 2nd CDIM powered up, we still can not access the sensors. However, when we unplug the cable (USB A to mini B) to the 2nd CDIM we are able to get data from the sensors - obviously we are only using 1 CDIM with this configuration.

                          Any help will be appreciated. Thanks


                          Code:
                          public abstract class AutonomousHeader extends LinearOpMode {
                          
                          DcMotor motorBackLeft, motorBackRight, motorFrontLeft, motorFrontRight,
                                  motorShooter, motorSweeper, motorLift;
                          Servo servoBeacon, /*servoLift*/ servoGate;
                          GyroSensor sensorGyro;
                          
                          byte[] rangeSensorLeftCache;
                          byte[] rangeSensorRightCache;
                          
                          I2cDevice rangeSensorLeft;
                          I2cDevice rangeSensorRight;
                          I2cDeviceSynch rangeSensorLeftReader;
                          I2cDeviceSynch rangeSensorRightReader;
                          
                          byte[] colorSensorLeftCache;
                          byte[] colorSensorRightCache;
                          byte[] colorSensorFrontCache;
                          
                          I2cDevice colorSensorLeft;
                          I2cDevice colorSensorRight;
                          I2cDevice colorSensorFront;
                          I2cDeviceSynch colorSensorLeftReader;
                          I2cDeviceSynch colorSensorRightReader;
                          I2cDeviceSynch colorSensorFrontReader;
                          
                          public void initialize () {
                          
                              motorBackLeft = hardwareMap.dcMotor.get("motorBackLeft");
                              motorBackRight = hardwareMap.dcMotor.get("motorBackRight");
                              motorFrontLeft = hardwareMap.dcMotor.get("motorFrontLeft");
                              motorFrontRight = hardwareMap.dcMotor.get("motorFrontRight");
                              motorShooter = hardwareMap.dcMotor.get("motorShooter");
                              motorSweeper = hardwareMap.dcMotor.get("motorSweeper");
                              motorLift = hardwareMap.dcMotor.get("motorLift");
                              rangeSensorLeft = hardwareMap.i2cDevice.get("rangeSensorLeft");
                              rangeSensorRight = hardwareMap.i2cDevice.get("rangeSensorRight");
                              colorSensorLeft = hardwareMap.i2cDevice.get("colorSensorLeft");
                              colorSensorRight = hardwareMap.i2cDevice.get("colorSensorRight");
                              colorSensorFront = hardwareMap.i2cDevice.get("colorSensorFront");
                              sensorGyro = hardwareMap.gyroSensor.get("sensorGyro");
                              servoBeacon = hardwareMap.servo.get("servoBeacon");
                              // servoLift = hardwareMap.servo.get("servoLift");
                              servoGate = hardwareMap.servo.get("servoGate");
                          
                              colorSensorLeftReader = new I2cDeviceSynchImpl(colorSensorLeft, I2cAddr.create8bit(0x3c), false);
                              colorSensorRightReader = new I2cDeviceSynchImpl(colorSensorRight, I2cAddr.create8bit(0x3e), false);
                              colorSensorFrontReader = new I2cDeviceSynchImpl(colorSensorFront, I2cAddr.create8bit(0x40), false);
                              rangeSensorLeftReader = new I2cDeviceSynchImpl(rangeSensorLeft, I2cAddr.create8bit(0x28), false);
                              rangeSensorRightReader = new I2cDeviceSynchImpl(rangeSensorRight, I2cAddr.create8bit(0x30), false);
                          
                              colorSensorLeftReader.write8(3, 0);
                              colorSensorRightReader.write8(3, 0);
                              colorSensorFrontReader.write8(3, 1);
                          
                              colorSensorLeftReader.engage();
                              colorSensorRightReader.engage();
                              colorSensorFrontReader.engage();
                              rangeSensorLeftReader.engage();
                              rangeSensorRightReader.engage();
                          
                              motorBackLeft.setDirection(DcMotor.Direction.REVERSE);
                              motorFrontLeft.setDirection(DcMotor.Direction.REVERSE);
                              motorShooter.setDirection(DcMotor.Direction.REVERSE);
                              servoBeacon.setPosition(0.0);
                              // servoLift.setPosition(0.4);
                              servoGate.setPosition(0.0);
                          
                              motorShooter.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
                          }
                          
                          public void calibrateGyro () throws InterruptedException {
                          
                              sensorGyro.calibrate();
                          
                              while (sensorGyro.isCalibrating()) {
                          
                                  Thread.sleep(50);
                          
                                  telemetry.addData("Calibrated", false);
                                  telemetry.update();
                              }
                          
                              telemetry.addData("Calibrated", true);
                              telemetry.update();
                          }

                          Comment

                          Working...
                          X