What is OkapiLib and Should I Use It?

Me and @Zenix have recently switched to PROS for our code. We are debating using this OkapiLib thing we see in the pros docs, but none of us are quite sure what it does. How does it work, and what does it do?

1 Like

It basically makes it much easier to code an autonomous scheme for your robot since it has all the controllers written out for you. For instance, you can easily generate a motion profile path once you configure your robot. You can also easily use PID and tune it to your preference much more easily than having to write out your own controller. However, I personally would prefer writing out my own controllers so you can modify them to suit your specific needs.

8 Likes

Well, first of all, have you looked at the documentation, specifically the tutorials?
They explain everything about OkapiLib.
If you haven’t seen them yet, you really should do so before asking on the forum (and taking someone’s time to do your research for you :grinning:).

Assuming you have seen the tutorials, API documentation, and examples, let me summarize it for you:

OkapiLib is a library of helper classes that make it easier to program a VEX robot. It does many different things, but the theme is that it lets you easily implement complex things and raise the programming bar.
Okapi contains PID controllers, math facilities, filters (such as moving average or kalman filter), device abstractions, and perhaps the most useful, chassis utilities.
There are a few chassis utilities:

  • Chassis model abstractions - implementations of controls for chassis such as skid-steer, x-drive, etc. It essentially allows you to not worry about the individual motor control and instead control the chassis directly.
    Example commands are chassis.arcade(forward, turn), chassis.forward(power), etc, which all move the chassis forward regardless of actual motor implementation.
  • Chassis PID controllers - building on the chassis models, a chassis controller allows you to move the robot autonomously. It does all the distance math for you, you simply need to give it chassis dimentions. Example commands are chassis.moveDistance(4_ft) or chassis.turnAngle(90_deg).
  • Chassis 2D motion profiling - this uses pathfinder, which generates a sequence of wheel velocities for the robot to drive from one position to another.

Another useful thing OkapiLib has is the Units API. They essentially let you abstract actual units like inches, and instead work with a “length” unit.
Here is an example:

QLength length = 5_cm;
length = length + (2 * feet);
double lengthInMeters = length.convert(meter);

Another common use of the Units API is for angles (QAngle angle = 90_deg;).

OkapiLib can do much more, but those are the core features. It is completely open source, so you can see exactly how it works and learn from it.

Btw, OkapiLib (Okapi) is named after the animal. There is no reason to capitalize the name.

20 Likes

@Zenix was telling me is was said like: Okay-API. Okapi is what I thought at first, but I trusted you Zeke. Why did you let me down?

i didn’t know that was the name of an animal as well

I personally say both. I was more inclined to say Okay-API in the past, but since I know that is wrong, I have switched to okapi :smiley: .
Either way, its an amazing library, and even simply using it will teach you more about C++ and better programming.
It can be a bit frustrating to figure out, but a new version is coming out soon that makes it easier to use.
Just try to do some research (google, docs, learncpp.com) or ask around (especially on discord) if you are stuck.

2 Likes