Announcement

Collapse
No announcement yet.

Mounting the RevHub vertically

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

  • FLARE
    replied
    Originally posted by 4634 Programmer View Post

    The REV Hub guide has a picture showing the location of the IMU inside it
    This shows where it is, but it would have been helpful to add the axes orientation to the diagram. From testing, it looks like x & y are opposite of what we expected.

    Leave a comment:


  • 4634 Programmer
    replied
    Originally posted by jkenney View Post
    The problem with those pictures is, they show you the little imu chip that's in the REV controller somewhere, but they don't show you its orientation within the controller. Its pretty clear that with the REV controller mounted horizontally, the imu chip is also horizontal (i.e., its z axis is up). But you don't know which directions are y and x. To find out, just run the BNO055 sample op mode. Start with the REV controller horizontal. Then tip it back and forth around one of its horizontal axes; If that gives you a change in "roll", then you are rotating about the y axis of the chip. If it gives you a change in "pitch", then you are rotating about the x axis of the chip. That's a very quick way of mapping out the x,y,z axes of the imu chip within the REV expansion hub.
    The REV Hub guide has a picture showing the location of the IMU inside it

    Leave a comment:


  • jkenney
    replied
    The problem with those pictures is, they show you the little imu chip that's in the REV controller somewhere, but they don't show you its orientation within the controller. Its pretty clear that with the REV controller mounted horizontally, the imu chip is also horizontal (i.e., its z axis is up). But you don't know which directions are y and x. To find out, just run the BNO055 sample op mode. Start with the REV controller horizontal. Then tip it back and forth around one of its horizontal axes; If that gives you a change in "roll", then you are rotating about the y axis of the chip. If it gives you a change in "pitch", then you are rotating about the x axis of the chip. That's a very quick way of mapping out the x,y,z axes of the imu chip within the REV expansion hub.

    Leave a comment:


  • gorpong
    replied
    Originally posted by 5294-jjkd View Post
    The link works fine for me. Here is a copy of the image retrieved and embedded in this message:

    uBz3oyj.png
    Sorry about that, my router at home's parental controls got in the way. I can see it now, thanks!

    Leave a comment:


  • 5294-jjkd
    replied
    The link works fine for me. Here is a copy of the image retrieved and embedded in this message:

    uBz3oyj.png

    Leave a comment:


  • gorpong
    replied
    Originally posted by 4634 Programmer View Post
    Thank you for posting, but when I click on it and copy/paste it directly into a browser, I get a 404 error in Chrome and in Firefox it tells me it can't be displayed because it contains errors.

    Leave a comment:


  • 4634 Programmer
    replied
    Originally posted by gorpong View Post
    Can someone please post a picture of which axes are which on the Expansion HUB for the IMU? I looked all over the place and can't seem to find anything that tells me which is which for mounting purposes. I recall seeing one, somewhere, but didn't save it and now The Google is letting me down for finding it again.
    Here you go. http://i.imgur.com/uBz3oyj.png

    Leave a comment:


  • gorpong
    replied
    Can someone please post a picture of which axes are which on the Expansion HUB for the IMU? I looked all over the place and can't seem to find anything that tells me which is which for mounting purposes. I recall seeing one, somewhere, but didn't save it and now The Google is letting me down for finding it again.

    Leave a comment:


  • 4634 Programmer
    replied
    Originally posted by Philbot View Post

    This code looks like the vanilla code.

    What is different here that deals with a vertical module ?
    To be completely honest I don't really know what exactly fixed it. I was messing around trying to get it to work, and eventually I got it working properly with that code...

    Leave a comment:


  • Philbot
    replied
    Originally posted by 4634 Programmer View Post
    Here's some code that works without doing all the remapping stuff: https://gist.github.com/FROGbots-463...4c16e52616f35c
    This code looks like the vanilla code.

    What is different here that deals with a vertical module ?

    Leave a comment:


  • jkenney
    replied
    Realized I have a mistake in the axis remapping code above. It works for swapping x and z axes, but if one needed to swap y and z it would break.

    To swap x and z, the AXIS_MAP_CONFIG register must be written to 0x6, or 0b000110.
    To swap y and z, the AXIS_MAP_CONFIG register must be written to 0x18, or 0b011000.

    The mask I put in for each of the write statements in the code ( 0x0F, or 0b001111) wouldn't work for swapping y and z, because it would mask out the first '1'. The masks probably aren't necessary at all, but I should have used: 0b111111 for the AXIS_MAP_CONFIG write; 0b111 for the AXIS_MAP_SIGN write; and 0b1111 for the OPR_MODE writes.

    Leave a comment:


  • 4634 Programmer
    replied
    Aha, finally figured out how to post code correctly. This is the same thing as in the Gist above:

    Code:
    package org.firstinspires.ftc.teamcode;
    
    import com.qualcomm.hardware.bosch.BNO055IMU;
    import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
    import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
    import org.firstinspires.ftc.robotcore.external.navigation.Acceleration;
    import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
    import org.firstinspires.ftc.robotcore.external.navigation.AxesOrder;
    import org.firstinspires.ftc.robotcore.external.navigation.AxesReference;
    import org.firstinspires.ftc.robotcore.external.navigation.Orientation;
    import java.util.Locale;
    
    @TeleOp(name = "IMUtest", group = "Sensor")
    //@Disabled
    public class IMUtest extends LinearOpMode
    {
        private BNO055IMU imu;
    
        private Orientation angles;
        private Acceleration gravity;
    
        @Override
        public void runOpMode()
        {
    
            BNO055IMU.Parameters parameters = new BNO055IMU.Parameters();
            parameters.angleUnit            = BNO055IMU.AngleUnit.DEGREES;
            parameters.accelUnit            = BNO055IMU.AccelUnit.METERS_PERSEC_PERSEC;
            parameters.loggingEnabled       = true;
            parameters.useExternalCrystal   = true;
            parameters.mode                 = BNO055IMU.SensorMode.IMU;
            parameters.loggingTag           = "IMU";
            imu                             = hardwareMap.get(BNO055IMU.class, "imu");
    
            imu.initialize(parameters);
            telemetry.setMsTransmissionInterval(100);
            waitForStart();
    
            while (opModeIsActive())
            {
                angles  = imu.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES);
                gravity = imu.getGravity();
                sendTelemetry();
            }
        }
    
        void sendTelemetry()
        {
            telemetry.addData("Status", imu.getSystemStatus().toString());
            telemetry.addData("Calib", imu.getCalibrationStatus().toString());
            telemetry.addData("Heading", formatAngle(angles.angleUnit, angles.firstAngle));
            telemetry.addData("Roll", formatAngle(angles.angleUnit, angles.secondAngle));
            telemetry.addData("Pitch", formatAngle(angles.angleUnit, angles.thirdAngle));
            telemetry.addData("Grav", gravity.toString());
            telemetry.update();
        }
    
        String formatAngle(AngleUnit angleUnit, double angle)
        {
            return formatDegrees(AngleUnit.DEGREES.fromUnit(angleUnit, angle));
        }
    
        String formatDegrees(double degrees)
        {
            return String.format(Locale.getDefault(), "%.1f", AngleUnit.DEGREES.normalize(degrees));
        }
    }

    Leave a comment:


  • 4634 Programmer
    replied
    Here's some code that works without doing all the remapping stuff: https://gist.github.com/FROGbots-463...4c16e52616f35c

    Leave a comment:


  • FTC6055
    replied
    This worked! Thank you so much!

    Leave a comment:


  • jkenney
    replied
    We were able to fix this tonight, by remapping axes:

    byte AXIS_MAP_CONFIG_BYTE = 0x6; //This is what to write to the AXIS_MAP_CONFIG register to swap x and z axes
    byte AXIS_MAP_SIGN_BYTE = 0x1; //This is what to write to the AXIS_MAP_SIGN register to negate the z axis

    //Need to be in CONFIG mode to write to registers
    imu.write8(BNO055IMU.Register.OPR_MODE,BNO055IMU.S ensorMode.CONFIG.bVal & 0x0F);

    sleep(100); //Changing modes requires a delay before doing anything else

    //Write to the AXIS_MAP_CONFIG register
    imu.write8(BNO055IMU.Register.AXIS_MAP_CONFIG,AXIS _MAP_CONFIG_BYTE & 0x0F);

    //Write to the AXIS_MAP_SIGN register
    imu.write8(BNO055IMU.Register.AXIS_MAP_SIGN,AXIS_M AP_SIGN_BYTE & 0x0F);

    //Need to change back into the IMU mode to use the gyro
    imu.write8(BNO055IMU.Register.OPR_MODE,BNO055IMU.S ensorMode.IMU.bVal & 0x0F);

    sleep(100); //Changing modes again requires a delay

    Then we used the REV unit just as we had when it was horizontal, using the z axis (now remapped to x) for heading.

    This allowed us to get good heading data with the REV unit mounted vertically. We didn't have time to look closely at roll and pitch, but we really only care about the heading.

    Depending on how you turn it vertical, you need to either swap (x with z) or (y with z).

    The AXIS_MAP_CONFIG and AXIS_MAP_SIGN registers are documented in the BNO055 datasheet available on the Adafruit website.

    I'd like to refine this; maybe put it into a new class that overrides the BNO055Impl class.

    Leave a comment:

Working...
X