ADXRS450 Gyro making code crash

My team got a ADXRS450 Gyro and we put it on the bot and it lights up
We can deploy code with the Gyro in the code but it says “No Robot Code”
If we take out any code to do with the Gyro, Robot Code works when deployed.

I already checked other posts on here and example code for adxrs450 but it did not help me. One person said they reset their gyro, and I know you can do gyro.reset() to reset it but I can’t even deploy code to do that.

In my code I make the gyro like this

Drive.h

#include <frc/ADXRS450_Gyro.h>

    frc::ADXRS450_Gyro m_drivegyro;

Robot.h

#include <frc/ADXRS450_Gyro.h>

  frc::ADXRS450_Gyro m_robotgyro;

I tried it like this (also all the other port options) but it didn’t fix it.

#include <frc/SPI.h>
#include <frc/ADXRS450_Gyro.h>
  frc::ADXRS450_Gyro m_robotgyro{frc::SPI::Port::kOnboardCS0};

My code is available here

You should only have it in one place, as you only have one gyro. Right now it looks like you’re constructing one in Drive and one in Robot. Only do one of these. With it in two places, you will likely see an error message in the console when it crashes regarding duplicate port allocation or something like that.

Also make sure you’re using WPILib 2023.3.2 or later

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.