Using an external library with VexCode

Hi! I want to use either the library Eigen or Armadillo to do some matrix math (for odometry). I’m pretty inexperienced with CPP (moving from java). How can I add this library so I can use it for my robot?

I don’t do much with Vex C++. But from my understanding you can’t use external libs with it. but if your a mildly experienced programmer Pros work with external libs. https://pros.cs.purdue.edu/v5/cli/conductor.html?highlight=conductor
look at the install function.

You can use external libraries in VEXCode. You just need to copy over the headers (Eigen is header-only) to your project and include it in.

Yes, if you are experienced enough to use Eigen you might want to look into using PROS, it is slightly more open.

However, @lerker100 the PROS conductor has nothing to do with external real-world libraries, its just the way that PROS can deliver updates and PROS template packages can be made.

The way external libraries works varies, but often it involves copying c++ code files and headers into a project. PROS can not facilitate this for you as there is not a “standard external lib” that is ready-to-go and works with PROS.
The only thing they have in common is that they are both C++.

1 Like

OK I haven’t used VexCode because I completely switched from VCS to Pros around Christmas last season. As I understand it by reading the Pros Docs the conductor can import external libs into a Pros project. However it isn’t clear on how to do it the install function says that it can “Install a library into a PROS project” but doesn’t show any way to do so.

1 Like

No, what the conductor does is manage PROS packages.
A PROS package is a zip that contains files such as header and source files. When you apply a package, it imports those files into your project, and keeps track of them.
The entire PROS API/kernel is in such a package, as well as okapilib.

The conductor makes it easy to upgrade, install, or remove packages. All it does in the backend is add and remove files from your project.
The only official packages are libpros and okapilib.
However, the purpose of the conductor is to make it simple to import additional code to your project to avoid copy/pasting. Here is an example package I have made.

So you could, if you want, set up Eigen in a PROS project by copy/pasting the files and setting everything up. Then, you could export that as a template, and create a PROS package containing Eigen that can easily be distributed to any other PROS project.

The way the conductor works is that you can import a template into the PROS cli prosv5 c fetch <template>.
You can then install that package into your project prosv5 c install <templatename>.
You could also remove that package from your project.

So again, the conductor is not for installing external libraries, it is a way to distribute and share code like plugins. However, an external library can be made into a PROS package.

1 Like

You are correct, a PROS user can use Eigen by copy its headers into the include directory of a project. I used Eigen in this manner with the code on team BLRS’ 15" robot last season (https://github.com/purduesigbots/forkner-public).

One relevant note for anyone wishing to use Eigen with PROS, the Dynamic matrix classes will not work out of the box. The matrix classes with sizes defined at compile time using the templating will work just fine (which is what I used exclusively), but the Dynamic matrices will not be able to change their size properly at runtime and will not work without modifications.

1 Like

You can use Eigen with VEXcode, previous discussion on this topic was here.

1 Like