I need some guidance on V5 code

I still don’t know how to use inertial sensors to control the robot’s forward and rotation.
Can someone please guide me??
by the way, I use C++

I would recommend using the in-built motor encoders. Based on what I’m looking at in the API, the inertial sensor is best for returning values for angles.

https://pros.cs.purdue.edu/v5/api/cpp/imu.html

4 Likes

Can you elaborate more? I have just been in contact with V5 not long ago, and I don’t even know about motor encoders

these.


people use them for tracker wheels and the such
1 Like

Does this apply to V5code pro

Is it useful? Currently I only have one inertial sensor

You can also use the built in motor encoders. For example, I can write the code:

Motor1.spinFor(5, turns, 100, velocityUnits::pct);

This utilizes the motor encoders already inside of the V5 motors, something that is nice compared to the old 393 motors(unless you use shaft encoders).

1 Like

The tracker wheels with Shaft Encoders are mostly important for really advanced programming techniques like Odometry. The internal motor encoder are most likely the most useful.

2 Likes

The inertial sensor can only know rotation and acceleration. I wouldn’t suggest using the internal motor encoders, as they can skip and slide. One problem I’ve encountered with the inertial sensor is that it’s off by about 1.4% consistently. To fix that, you should implement a correction function. If you want to track forward motion, I would recommend getting either the optical shaft encoder or a rotation sensor.

1 Like