I have this type of usage working for Okapi V3. You can see what i did here:
I had to explicitly declare the type in the header file (robot.h) so it could be referenced in any file with the include.
extern std::shared_ptr<okapi::ChassisControllerIntegrated> chassis;
(Note that I did not do a good job of keeping my header files limited to only where they were needed. I put everything in main.h , I plan to clean that up one day.)
The definition is in opcontrol but can be used in the auton files.
std::shared_ptr<okapi::ChassisControllerIntegrated> chassis =
You only need the type of structure (in my example) if you use multiple files that want access to chassis. If you only have one file, then I’m not sure the issue.
BTW, I plan on migrating my example code to v4 soon , maybe this weekend.
I forgot to say there is another way by putting the chassis definition in its own class. Then the class can be used as expected (declared in the header and defined in a CPP).