Is VEX IQ better than the gyro sensor in the brain or should i use a separate gyro sensor?
If you have 2nd Gen with the Brain Intertial Sensor, there is no advantage to using the external 1st Gen Gyro.
The independent sensor is more positionable on the robot than the brain tends to be, so there can be value in that. The brain inertial sensor has more parameters available (3-axis as opposed to just 1-axis with the separate gyro, plus acceleration values that the gyro does not have).
If you only need one axis (heading), then the separate gyro is perfectly fine. If you use the brain inertial, be aware that the rotation value is inverted compared to the gyro sensor.
You can alter that if necessary when using C++ or python (not available using blocks)
Please, by all means, enlighten me! It’s been driving me a bit nuts.
And out of curiosity, why the change in reporting by default?
Okay, I think I see, at least with C++:
vex::inertial brainInertial(vex::turnType::left);
Any chance of an online IQ API reference like V5 has someday? Pretty please?
yea, you can either do in the constructor or using separate call.
for C++
vex::gyro gyro1( PORT1, false, turnType::right );
vex::inertial imu1( turnType::left );
int main() {
gyro1.setTurnType( turnType::right );
while(1) {
// Allow other tasks to run
this_thread::sleep_for(10);
}
}
there is also setTurnType for inertial, but it’s a protected member function (for some reason)
and Python
# probably get a linter error
gyro1=Gyro( Ports.PORT1, TurnType.RIGHT )
gyro1.set_turn_type( TurnType.RIGHT )
# probably get a linter error
imu1=Inertial( TurnType.LEFT )
imu1.set_turn_type( TurnType.LEFT )
legacy reasons.
The cortex yaw rate gyro was increasing angle turning clockwise (turnType::right), and had that printed on the board. The legacy IQ gyro was the opposite and also printed on the sensor, so we could not change either of those. V5 inertial sensor followed the cortex yaw rate sensor, same with GPS. IQ2 then gave a problem, we wanted internal IMU to be the same as V5, but we also needed to support legacy IQ gyro without customer having to change their code. We also wanted EXP to match V5 so internal IMU the same as external V5 IMU. End result is that the IQ gyro is the odd sensor out with all others defaulting to turnType::right, I added the option as an aid to moving code from an IQ1 to an IQ2 (or EXP).
I’ve tried really hard to make APIs across all platforms match where they can to make moving code from IQ1 ↔ IQ2 ↔ EXP ↔ V5 feasible.
Much of the V5 documentation for equivalent sensors/features will be the same.
However, I agree, it would be nice to have a more comprehensive online reference.
A consideration: a moderated wiki-style area might be something to look at; I’m sure there’d be some work to figure out who (if anyone) beyond Vex would make for good external contributors, but that could help enhance things over time with code examples to fill out some of the pages. I also realize that the Doxygen-style output right now is very convenient since it can self-generate. Maybe some ability to solicit entries from the community that could go into the relevant code header blocks that could provide that example usage?
Really too bad there’s not some hybrid Doxy/Wiki monstrosity that would make that all magical. Hey, High School/College kids looking for some school project, get on this idea!
Circling back to the original topic, @Ali_Behram_Albayrak, once my kids are in bed, I’ll record a quick video of the differences showing on a Gen 2 brain (which is how I was comparing them).
@Ali_Behram_Albayrak Pictures instead of video as promised (apparently can’t load videos anymore). Top line is inertial to 6 decimal digits, bottom line is gyro. Long calibration cycles for both.
Gyro is basically center of the robot, brain centered over the top of that. As you can see from the video, not a lot of difference between the two, but there is some.
If it helps, the only difference I have found is that, for some reason, the inertial takes much longer to calibrate ~10-30 seconds, vs the gyro, which take ~2-5 seconds to calibrate.
yea, that’s not true. calibration time for the internal IQ2 inertial sensor is fixed at 2 seconds IIRC.
Interesting we ended up switching mid season because the inertial sensor never calibrated, I can always try again and see if it works, from what I know of the code, the inertial sensor calibration loop just checks the status of the sensor every 50 ms in vexcode iq.
This is definitely not our experience. It generally takes longer than 2 seconds, and sometimes over ten. This is using blocks.
Slight mistake on my part, 25 ms, though it shouldn’t make a difference
void calibrateDrivetrain() {
wait(200, msec);
Brain.Screen.print("Calibrating");
Brain.Screen.newLine();
Brain.Screen.print("Gyro");
DrivetrainGyro.calibrate(calNormal);
while (DrivetrainGyro.isCalibrating()) {
wait(25, msec);
}