The VectorNav C/C++ Library allows interfacing with VectorNav's orientation and inertial sensor products.
Samples
The folder samples contains sample projects that can be immediately compiled in various environments. The following sections walk through compiling and running the samples provided.
Linux Sample
- Open the file
main.c
and change the configuration defines at the top to your environment specifics.
- For the COM_PORT define, normal physical COM ports typically will be in the form of
/dev/ttyS1
. If you are using an FTDI USB-to-Serial chip (typically found on USB cables supplied with VN-100 Rugged Kits or on a VN-100 Development Board), the necessary drivers are already include in kernel version 2.6.31 and later and can be accessed in the form of /dev/ttyUSB0
.
- For the BAUD_RATE define, change it to the currently saved baudrate speed of your VectorNav device.
- From a terminal window, browse to the folder samples/linux and compile by typing the command
make
.
- The sample program may then be run by executing the command
./main
.
- Some Linux flavors may require administrative access to the COM port. If you receive an error message indicating invalid access privileges, try exeucting the command as
sudo ./main
.
Including in Existing Projects
The following sections provide guidance for using the library in your project.
Microsoft Visual Studio
The following steps will walk you through including the VectorNav C/C++ Library into your existing C or C++ project. You can also find an example usage of the library at windows_basic.c.
- Add the code files src/vn100.c and src/arch/win32/vncp_services.c to your project.
- Right-click on your project file and select Add -> Existing Item... and browse to where you extracted the library files and select the two file.
- Add an additional include directory to the libraries
include
folder.
- Right-click on your project file and select Properties. On the property pages, browse to Configuration Properties -> C/C++ -> General. For the property field Additional Include Directories, add a link to the library's
include
folder.
- Disable usage of precompiled headers for your project.
- Right-click on your project file and select Properties. Browse to the section Configuration Properties -> C/C++ -> Precompiled Header and select the option Not Using Precompiled Headers.
- Add the include line
#include "vectornav.h"
to the top of your code file to get access to all of the types and functions provided by the library.
Linux
The following steps will walk you through adding the VectorNav C/C++ Library to your Linux project. You can also find an example usage of the library at linux_basic.c.
- Add lines to your makefile to compile the code files src/vn100.c and src/arch/linux/vncp_services.c.
- Example lines...
gcc -c -Iinclude src/vn100.c
gcc -c -Iinclude src/arch/linux/vncp_services.c
- When you link the all of the compiled files together, you will need to add a reference to the pthread library as well as the output object files from the previous step.
- Example linker command:
gcc -lpthread main.o vn100.o vncp_services.o -o main
- In code files where you wish to access the functionality of the library, add the line
#include "vectornav.h"
at the top of the code file. You will also need to add a reference to the include directory when you compile your code file.