[Prosv5]The problem of setting the gyroscope to a global class

I try to play "pros ":ADIGyro gyro(GYRO_PORT);'set to global class.
Then I cannot be at "void initialize();"The gyroscope has been initialized.
Does this have any effect on the initialization of the gyroscope?
I found an abnormal gyro reading in today’s test, and I’m not sure if I set it as a global class relationship.

Configuring an ADI Port as a gyroscope starts a roughly 1300ms calibration routine in Vex OS. When you declare a gyro object globally, it will start this calibration effectively at the beginning of


. As a result, you will receive invalid gyroscope values for the first 1300ms of the



When you call the constructor for a gyroscope at a local scope (such as in the


function), then the 1300ms delay will occur during the call to the constructor.

When I updated prosv5-cli to 3.1.2 okapilib to 3.3.5 .
gyro.get_value () always returns 127.
I don’t know why.

There’s a bug that was introduced in PROS kernel version 3.1.2 that causes the behavior that you reported in your github issue. We have a fix written and tested for this issue, and will be releasing it as soon as possible.

The fix is live now in PROS kernel version 3.1.3, if you run

prosv5 c u

in your PROS project’s directory then it will update and fix the gyroscope issue.

I upgraded the prosv5 kernel to 3.1.3 okapilib to 3.3.5. The problem is still there.
In addition, I would like to ask whether ADIGyro initialization in global mode is before initialize() or inside initialize().
I think there should be a static function in this class to record the number of initializations, but I don’t see it.

Have you compiled your project since upgrading?

ADIGyro initialization in global mode happens before initialize().

I’m not quite sure I follow why there would be such a function. Can you elaborate?

I re-created the pros 3.1.3 program and the questions remain.
But when I switched back to the branch of pros3.1.1, everything was fine.
I usually use static variables within a class to determine how many times the constructor executes because I think the ADIGyro class can only be constructed once.

pros 3.1.1 okapilib 3.3.4 it’s all right.
pros 3.1.3 okaplib 3.3.5 it’s looks like have some bugs.

The code is exactly the same, and I’m sure I didn’t make a mistake

@3038922 we apologize for the inconvenience. As it turns out, the 3.1.3 template was originally built incorrectly, but this has since been resolved.

To get the correct version of kernel 3.1.3, please run the following commands:

purge the old version:

prosv5 c p kernel@3.1.3

fetch the new version:

prosv5 c f kernel@3.1.3

then, to apply this to projects that may already have kernel 3.1.3 installed:

prosv5 c a --force-apply kernel@3.1.3

1 Like

Problem solved. Thanks for your team’s efforts.
Pros are great. He gives me and my students a real understanding of c&cpp.