Announcement

Collapse
No announcement yet.

Mounting the RevHub vertically

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

  • FTC6055
    started a topic Mounting the RevHub vertically

    Mounting the RevHub vertically

    Like many people on the forum, we have had issues with initializing the RevHub in any position except horizontally. Yaw seems to always be initialized at 0, but both pitch and roll start out at weird numbers. We've been messing around with it for a while, and these numbers seem to be the angle the RevHub is at, relative to horizontal (i.e. initializing vertically starts out at about 90 degrees for pitch and about 0 for roll, where as a 45 degree angle is 45 for pitch and 0 for roll). Whenever we place the RevHub horizontally after initializing it at a different angle, it goes back to 0,0,0. The weird part comes in when we initialize it vertically and rotate it. Just spinning it around the axis pointing up changes all three variables. We tried messing around with the AXIS_REMAP_CONFIG variable, but it had no effect. Is there any other fix for this?

  • 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:

Working...
X