Okapilib Unit Error

Hi everyone,

So I’ve decided to try dabbling in Okapilib, but upon initializing a chassis, I get several errors. The problem occurs when defining the wheel diameter and wheelbase width.

This is the code:

auto drive = okapi::ChassisControllerFactory::create(
  left_drive, right_drive,      //Motor Groups with left and right drive motors
  drive_gearset,                //standard green gearset
  {4_in, 10.5_in}               //Errors    

And this is the output from cquery for each value in the list:

no matching literal operator for call to 'operator""_in' with argument 
of type 'unsigned long long' or 'const char *', and no matching
literal operator template

I would put the output from the terminal, but it’s way too long to put here. Any advice?

I think this is an issue with auto not being able to determine which chassis controller you want. I saw errors (don’t remember if they were the same) when I used auto outside of opcontrol function.

You can try to to explicitly tell it

okapi::ChassisControllerIntegrated drive = okapi::ChassisControllerFactory::create(...

I tried this, still does not work.

then you can do what i did to get the same chassis to work in both opcontrol and auton. Here is the topic i posted on it. You can ignore the LVGL stuff if you want but the repo shows how to use pointers to access the chassis across files. The alternate way is to create your own chassis class which i think is harder to understand.

Forgive me if I’m wrong, but I’m not sure how this applies to the situation. The problem isn’t using the drive for auton and opcontrol, but that defining the wheel diameter and wheelbase width doesn’t work when using units.

Actually, no units are working with Okapilib now that I’ve tested it. I tried to define a motor by using 8_rmtr, and it gave me the same problem.

I understand you just have a problem with “ChassisControllerFactory::create”, but the only example i have working is the one using pointers. I don’t see an error in what you have … unless the “4_in” should be “4.0_in”.

I can try to create an okapi example self contained to main.c (pros 3.2.0), if you’d like.

if i comment out

using namespace okapi;

in main.h

i get the same error

1 Like

Yep, that seems to be the issue. Oof.

Oh well, thank you so much for your help! I don’t think I ever would have figured that out otherwise.

you’re welcome.
I had to start a project from the template to remember all the steps needed to okapi working. That’s when i saw that error.

The unit literals are in an inline namespace called okapi::literals. If you don’t want to use the okapi namespace but you want to use the unit literals, you can use the okapi::literals namespace.