How to set V5 Okapi Pros Gear Ratio

Hi,

We are using following code for motion profiling over odometry. we are having issue in programing robot is not moving to desired position as we code for. I think we are not configuring the dimensions correctly. can anyone verify our code and suggest how to set gear ratio in this line of code? I am using a blue cartridge and I am using a gear ratio of 36:70 from motor shaft to wheel shaft.

.withDimensions({AbstractMotor::gearset::blue,(1.4)}, {{3.2_in, 14_in}, imev5BlueTPR})

//our configuration
std::shared_ptr drive =
ChassisControllerBuilder().withMotors(
{-10,- 2}, // Left motors are 1 & 2 (reversed)
{5, 6} // Right motors are 3 & 4
).withGains(
{0.001, 0, 0.0001}, // Distance controller gains
{0.001, 0, 0.0001}, // Turn controller gains
{0.001, 0, 0.0001} // Angle controller gains (helps drive straight)
)
.withDimensions({AbstractMotor::gearset::blue,(70.0/36.0)}, {{3.2_in, 14_in}, imev5BlueTPR})
.withOdometry() // use the same scales as the chassis (above)
.buildOdometry(); // build an odometry chassis

std::shared_ptr profileController =
AsyncMotionProfileControllerBuilder()
.withLimits({
1.0, // Maximum linear velocity of the Chassis in m/s
2.0, // Maximum linear acceleration of the Chassis in m/s/s
10.0 // Maximum linear jerk of the Chassis in m/s/s/s
})
.withOutput(drive)
.buildMotionProfileController();

profileController->generatePath({
{0_ft, 0_ft, 0_deg}, // Profile starting position, this will normally be (0, 0, 0)
{3_ft, 0_ft, 0_deg}}, // The next point in the profile, 3 feet forward
“A” // Profile name
);
profileController->setTarget(“A”);
profileController->waitUntilSettled();

Thanks

One thing I noticed was that you said your gear ratio is 36:70. First of all, there is no 70-tooth gear in Vex. I think you are using a 36:72 instead. I’m not sure what the first line of .withDimensions is for, so I’ll ignore that. The .withDimensions in the ChassisControllerBuilder does have another problem, which is that you enter the gear ratio as 70/36. While it should be 72, it should also be the other way around as the motor is driving the 36-tooth gear rather than the 72-tooth gear.
This is as much as I can tell without a bit more information on what is actually happening with the tests. Some extra information would be helpful, such as whether the robot is overshooting or undershooting, whether you have played around with any values, etc.
Also, please put ``` in the line before and after your code as it makes viewing it a lot easier.

2 Likes

I’m like 90% sure you are just controlling the robot through the async controller, you probably want to take that out

2 Likes

Thanks for reply.
I have using following path to move 3 ft. however; robot is moving just 0.4ft.
What I am configuring wrong. please suggest.

profileController->generatePath({
{0_ft, 0_ft, 0_deg}, // Profile starting position, this will normally be (0, 0, 0)
{3_ft, 0_ft, 0_deg}}, // The next point in the profile, 3 feet forward
“A” // Profile name
);

That definitely seems to be related to the gear ratio, at least partially. The problem is with the profileController variable, where the .withDimensions should have 36/72.0 instead of 70.0/36.0

Also, I would like to just confirm that your gear ratio is 36:72 rather than 36:70 (not sure if that is even possible with Vex gears)

Hi,
I put 36/72 it is still not working.

1 Like

do 72.0/36
36/72 is an integer division which evaluates to 0

2 Likes

I tried 72.0/36 but it still giving same issue.
Later I tried removing withGains. it is not moving full distance but going fast and giving jerk.
How to set proper parameters for withGains to fix this issue.

Thanks

1 Like

It has to be 36/72.0.
The denominator has to be the decimal, not the numerator.