Hey,
My team (me) had just decided to switch our programming with text based code and have decided the incorporation of the inertial sensor into the build. I’ve done some research online, through vex forums and on youtube but was overwhelmed with new terminologies that I don’t know about. I’m rather new to programming but have done some basic programming corses and our team is as well to VEX generally.
Are there any good advice to the programming of the inertial sensor (to drive and turn straight)? Or just general advice to start working with VEXcode Pro V5? Any response is welcomed! 
1 Like
At least on the C++ side, I (as a mentor) think that the starter programs and templates provided by Vex are great at illustrating how to use each sensor at a basic level.
For example, here is the sample “Accurate Turn with Inertial Sensor Program”:
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
Inertial20.calibrate();
// waits for the Inertial Sensor to calibrate
while (Inertial20.isCalibrating()) {
wait(100, msec);
}
// Turns the robot to the right
LeftMotor.spin(forward);
RightMotor.spin(reverse);
// Waits until the motor reaches a 90 degree turn and stops the Left and
// Right Motors.
waitUntil((Inertial20.rotation(degrees) >= 90.0));
LeftMotor.stop();
RightMotor.stop();
wait(1, seconds);
}
One can even throw that code to ChatGPT and get a reasonable explanation:
/* Here is the explanation for the code above:
1. The first section of code initializes the inertial sensor and waits for it
to calibrate.
2. The second section of code turns the robot to the right.
3. The third section of code waits until the robot turns 90 degrees and then
stops the Left and Right Motors. */
1 Like
I am happy to see you invest time into learning code.
I do want to share that there is a shortcut for the inertial sensor. The Drivetrain does allow you to add an inertial sensor by default. This will greatly improve the accuracy of your robot auton movement.
It does a pretty good job but it’s not as accurate as some of the advanced code you will find on this forum.
If you are just starting out then this might be a good place to learn. Later if you want the high speed and incredibly accurate robot movements like you see at Worlds, then you will need to spend more time learning to get the full potential out of the sensor.
int main() {
Drivetrain.turnToRotation(90, degrees);
Drivetrain.driveFor(forward, 16, inches);
}
1 Like