Laine
August 10, 2020, 12:36am
1
If I set up an inertial sensor when setting up the drivetrain in the robot configuration menu, is there any additional coding to get robot to turn accurately or is it done automatically if set up with the drivetrain.
In order to utilise an inertial sensor to correct turning, additional programming must be done. It’s not automatically set up with installation. You have to do additional coding.
Laine
August 10, 2020, 12:47am
3
Where would I find the additional programming?
I don’t think you can find it anywhere, but you can definitely program it yourself.
Laine
August 10, 2020, 12:50am
5
What I meant by that was where can I learn what needs to be done to get the inertial sensors to work.
For that, I would recommend Vex Doxygen for the sensor commands and stuff (like calibrate sensor, get a sensor reading, all that jazz) and for tutorials you can try YouTube (but I don’t think there’s that many there). If you get stuck while programming or have a specific question, VEXforum’s a great place to PM someone or make a topic with your question.
I hope that helps!
weilin
August 10, 2020, 7:50am
7
These topics have helpful discussion:
There have been quite a few requests for instructions on how to use motor groups and creating a drivetrain with more than 2 motors in VEXcode. I’m going to discuss these classes a little and provide a simple example.
What is a motor group ?
A motor group collects two or more motors together and allows control as if they were a single entity. Just about all motor class member functions (by that I mean spin, spinTo, setVelocity etc.) are available on the motor group class. We introduced motor…
A drivetrain that is created with a gyro or inertial sensor will use the sensor when the drivetrain is asked to make turns. The specific class member functions that use these sensors are turnFor, turnToHeading and turnToRotation.
Drivetrain.turnToHeading( 90 , degrees );
will turn the robot to a heading of 90 degrees (heading is like a compass heading now, 0 to 359.99 degrees). The robot will always take the shortest route to achieve the new heading.
Drivetrain.turnFor( 90, degrees );
will turn the robot 90 degrees starting at the current heading, that is, relative to the current starting position.
Drivetrain.turnToRotation( 500, degrees );
will turn the robot to an absolute rotation of 500 degrees, the robot may turn through more than 360 degrees to achieve this.
See VEXcode help for more information
The turnFor function in the smartdrive class is very simple, no PID or anything is used, all it does is slow down as the turn is getting close to the target and then stop when the error is less than 2 degrees. We may improve a little for a future release but we really want teams to write their own code for this and not rely on VEX providing everything for them, it already does more than some of the dev team would like.
Smartdrive (inherits from vex::drivetrain ) api: VEX Help
Inertial sensor (inherits from vex::guido ) api: VEX Help
We messed around with the new V5 Inertial sensor and completed our turning code. Here’s a little peek at our turning testing: VRC Tower Takeover V5 Inertial Sensor Turning [1080P] - YouTube . As far as we can tell, the sensor seems to be a solid upgrade over the gyro. We made a custom PID function and used that in the video but we’ll test the sensor with both the stock PID and the custom one when we have access to a field. Nice work with this sensor Vex
We are using the Vex V5 Text editor and when we put in a 90 degree turn the robot turns more or less than 90 degrees…never a true 90 degree turn. Is that just the way it is and we need to compensate in our coding or is there some other issue at play?