VectorNav C/C++ Library
linux_basic.c

This example shows how to use the VectorNav C/C++ Library in a Linux based environment. This example will opan a connection to a VN-100 device, display the current yaw, pitch, roll attitude for ten seconds, and then close the connection to the device. Note that in this examples, the thread calling the function vn100_getYawPitchRoll will block for several milliseconds while the underlying function mechanisms sends a request to the VN-100 sensor over the serial port and waits for a response. If it is important to not block the thread, consider only retrieving the latest asynchronous data packet received from the sensor by calling the function vn100_getCurrentAsyncData. An example of using this function may be found in linux_async.c.

#include <stdio.h>
#include <unistd.h>
#include "vectornav.h"

/* Change the connection settings to your configuration. */
const char* const COM_PORT = "//dev//ttyS1";
const int BAUD_RATE = 115200;

int main()
{
    Vn100 vn100;
    VnYpr ypr;
    int i;

    vn100_connect(&vn100, COM_PORT, BAUD_RATE);

    for (i = 0; i < 10; i++) {
        vn100_getYawPitchRoll(&vn100, &ypr);
        printf("YPR: %+#7.2f %+#7.2f %+#7.2f\n", ypr.yaw, ypr.pitch, ypr.roll);
        sleep(1);
    }
    
    vn100_disconnect(&vn100);

    return 0;
}

 All Data Structures Files Functions Variables Typedefs Defines