initial
This commit is contained in:
37
vnproglib/c/include/vn/bool.h
Normal file
37
vnproglib/c/include/vn/bool.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef VNBOOL_H_INCLUDED
|
||||
#define VNBOOL_H_INCLUDED
|
||||
|
||||
/** \brief Boolean definition. */
|
||||
|
||||
#include "vn/util/compiler.h"
|
||||
#include "vn/int.h"
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
|
||||
#if VN_HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#if !defined(__GNUC__)
|
||||
/* _Bool builtin type is included in GCC. */
|
||||
/* ISO C Standard: 5.2.5 An object declared as type _Bool is large
|
||||
* enough to store the values 0 and 1. */
|
||||
typedef int8_t _Bool;
|
||||
#endif
|
||||
|
||||
/* ISO C Standard: 7.16 Boolean type */
|
||||
|
||||
#if defined(__STDC__) && defined(__GNUC__)
|
||||
/* Avoid warning "ISO C90/89 does not support boolean types" */
|
||||
#define bool int8_t
|
||||
#else
|
||||
#define bool _Bool
|
||||
#endif
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
7
vnproglib/c/include/vn/const.h
Normal file
7
vnproglib/c/include/vn/const.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef __VNCONTS_H__
|
||||
#define __VNCONTS_H__
|
||||
|
||||
/** Pi in double format. */
|
||||
#define VNC_PI_D (3.141592653589793238)
|
||||
|
||||
#endif
|
||||
16
vnproglib/c/include/vn/conv.h
Normal file
16
vnproglib/c/include/vn/conv.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef __VNCONV_H__
|
||||
#define __VNCONV_H__
|
||||
|
||||
#include "vn/math/vector.h"
|
||||
|
||||
/** Converts ECEF coordinate to LLA frame.
|
||||
* \param[in] ecef Coordinate in ECEF frame.
|
||||
* \return Coordinate converted to LLA frame. */
|
||||
vec3d ecef_to_lla_v3d(vec3d ecef);
|
||||
|
||||
/** Converts LLA coordinate to ECEF frame.
|
||||
* \param[in] lla Coordinate in LLA frame in (deg, deg, meter) units.
|
||||
* \return Coordinate converted to ECEF frame in (km, km, km) units. */
|
||||
vec3d lla_to_ecef_v3d(vec3d lla);
|
||||
|
||||
#endif
|
||||
670
vnproglib/c/include/vn/enum.h
Normal file
670
vnproglib/c/include/vn/enum.h
Normal file
@ -0,0 +1,670 @@
|
||||
#ifndef VNENUM_H_INCLUDED
|
||||
#define VNENUM_H_INCLUDED
|
||||
|
||||
/** \brief The different types of UART packets. */
|
||||
typedef enum
|
||||
{
|
||||
PACKETTYPE_BINARY, /**< Binary packet. */
|
||||
PACKETTYPE_ASCII, /**< ASCII packet. */
|
||||
PACKETTYPE_UNKNOWN /**< Unknown packet type. */
|
||||
} PacketType;
|
||||
|
||||
/** \brief The available binary output groups. */
|
||||
typedef enum
|
||||
{
|
||||
BINARYGROUPTYPE_COMMON = 0x01, /**< Common group. */
|
||||
BINARYGROUPTYPE_TIME = 0x02, /**< Time group. */
|
||||
BINARYGROUPTYPE_IMU = 0x04, /**< IMU group. */
|
||||
BINARYGROUPTYPE_GPS = 0x08, /**< GPS group. */
|
||||
BINARYGROUPTYPE_ATTITUDE = 0x10, /**< Attitude group. */
|
||||
BINARYGROUPTYPE_INS = 0x20, /**< INS group. */
|
||||
BINARYGROUPTYPE_GPS2 = 0x40 /**< GPS2 group. */
|
||||
} BinaryGroupType;
|
||||
|
||||
/** \brief Async modes for the Binary Output registers. */
|
||||
typedef enum
|
||||
{
|
||||
ASYNCMODE_NONE = 0, /**< None. */
|
||||
ASYNCMODE_PORT1 = 1, /**< Serial port 1. */
|
||||
ASYNCMODE_PORT2 = 2, /**< Serial port 2. */
|
||||
ASYNCMODE_BOTH = 3 /**< Both serial ports. */
|
||||
} AsyncMode;
|
||||
|
||||
/** \brief Flags for the binary group 1 'Common' in the binary output registers. */
|
||||
typedef enum
|
||||
{
|
||||
COMMONGROUP_NONE = 0x0000, /**< None. */
|
||||
COMMONGROUP_TIMESTARTUP = 0x0001, /**< TimeStartup. */
|
||||
COMMONGROUP_TIMEGPS = 0x0002, /**< TimeGps. */
|
||||
COMMONGROUP_TIMESYNCIN = 0x0004, /**< TimeSyncIn. */
|
||||
COMMONGROUP_YAWPITCHROLL = 0x0008, /**< YawPitchRoll. */
|
||||
COMMONGROUP_QUATERNION = 0x0010, /**< Quaternion. */
|
||||
COMMONGROUP_ANGULARRATE = 0x0020, /**< AngularRate. */
|
||||
COMMONGROUP_POSITION = 0x0040, /**< Position. */
|
||||
COMMONGROUP_VELOCITY = 0x0080, /**< Velocity. */
|
||||
COMMONGROUP_ACCEL = 0x0100, /**< Accel. */
|
||||
COMMONGROUP_IMU = 0x0200, /**< Imu. */
|
||||
COMMONGROUP_MAGPRES = 0x0400, /**< MagPres. */
|
||||
COMMONGROUP_DELTATHETA = 0x0800, /**< DeltaTheta. */
|
||||
COMMONGROUP_INSSTATUS = 0x1000, /**< InsStatus. */
|
||||
COMMONGROUP_SYNCINCNT = 0x2000, /**< SyncInCnt. */
|
||||
COMMONGROUP_TIMEGPSPPS = 0x4000 /**< TimeGpsPps. */
|
||||
} CommonGroup;
|
||||
|
||||
/** \brief Flags for the binary group 2 'Time' in the binary output registers. */
|
||||
typedef enum
|
||||
{
|
||||
TIMEGROUP_NONE = 0x0000, /**< None. */
|
||||
TIMEGROUP_TIMESTARTUP = 0x0001, /**< TimeStartup. */
|
||||
TIMEGROUP_TIMEGPS = 0x0002, /**< TimeGps. */
|
||||
TIMEGROUP_GPSTOW = 0x0004, /**< GpsTow. */
|
||||
TIMEGROUP_GPSWEEK = 0x0008, /**< GpsWeek. */
|
||||
TIMEGROUP_TIMESYNCIN = 0x0010, /**< TimeSyncIn. */
|
||||
TIMEGROUP_TIMEGPSPPS = 0x0020, /**< TimeGpsPps. */
|
||||
TIMEGROUP_TIMEUTC = 0x0040, /**< TimeUTC. */
|
||||
TIMEGROUP_SYNCINCNT = 0x0080, /**< SyncInCnt. */
|
||||
TIMEGROUP_SYNCOUTCNT = 0x0100, /**< SyncOutCnt. */
|
||||
TIMEGROUP_TIMESTATUS = 0x0200 /**< TimeStatus. */
|
||||
} TimeGroup;
|
||||
|
||||
/** \brief Flags for the binary group 3 'IMU' in the binary output registers. */
|
||||
typedef enum
|
||||
{
|
||||
IMUGROUP_NONE = 0x0000, /**< None. */
|
||||
IMUGROUP_IMUSTATUS = 0x0001, /**< ImuStatus. */
|
||||
IMUGROUP_UNCOMPMAG = 0x0002, /**< UncompMag. */
|
||||
IMUGROUP_UNCOMPACCEL = 0x0004, /**< UncompAccel. */
|
||||
IMUGROUP_UNCOMPGYRO = 0x0008, /**< UncompGyro. */
|
||||
IMUGROUP_TEMP = 0x0010, /**< Temp. */
|
||||
IMUGROUP_PRES = 0x0020, /**< Pres. */
|
||||
IMUGROUP_DELTATHETA = 0x0040, /**< DeltaTheta. */
|
||||
IMUGROUP_DELTAVEL = 0x0080, /**< DeltaVel. */
|
||||
IMUGROUP_MAG = 0x0100, /**< Mag. */
|
||||
IMUGROUP_ACCEL = 0x0200, /**< Accel. */
|
||||
IMUGROUP_ANGULARRATE = 0x0400, /**< AngularRate. */
|
||||
IMUGROUP_SENSSAT = 0x0800 /**< SensSat. */
|
||||
#ifdef EXTRA
|
||||
,
|
||||
IMUGROUP_RAW = 0x1000 /**< Raw. */
|
||||
#endif
|
||||
} ImuGroup;
|
||||
|
||||
/** \brief Flags for the binary group 4 'GPS' in the binary output registers. */
|
||||
typedef enum
|
||||
{
|
||||
GPSGROUP_NONE = 0x0000, /**< None. */
|
||||
GPSGROUP_UTC = 0x0001, /**< UTC. */
|
||||
GPSGROUP_TOW = 0x0002, /**< Tow. */
|
||||
GPSGROUP_WEEK = 0x0004, /**< Week. */
|
||||
GPSGROUP_NUMSATS = 0x0008, /**< NumSats. */
|
||||
GPSGROUP_FIX = 0x0010, /**< Fix. */
|
||||
GPSGROUP_POSLLA = 0x0020, /**< PosLla. */
|
||||
GPSGROUP_POSECEF = 0x0040, /**< PosEcef. */
|
||||
GPSGROUP_VELNED = 0x0080, /**< VelNed. */
|
||||
GPSGROUP_VELECEF = 0x0100, /**< VelEcef. */
|
||||
GPSGROUP_POSU = 0x0200, /**< PosU. */
|
||||
GPSGROUP_VELU = 0x0400, /**< VelU. */
|
||||
GPSGROUP_TIMEU = 0x0800, /**< TimeU. */
|
||||
GPSGROUP_TIMEINFO = 0x1000, /**< TimeInfo. */
|
||||
GPSGROUP_DOP = 0x2000 /**< DOP. */
|
||||
|
||||
#ifdef EXTRA
|
||||
,
|
||||
GPSGROUP_SVSTAT = 0x1000 /**< SvStat. */
|
||||
#endif
|
||||
} GpsGroup;
|
||||
|
||||
/** \brief Flags for the binary group 5 'Attitude' in the binary output registers. */
|
||||
typedef enum
|
||||
{
|
||||
ATTITUDEGROUP_NONE = 0x0000, /**< None. */
|
||||
ATTITUDEGROUP_VPESTATUS = 0x0001, /**< VpeStatus. */
|
||||
ATTITUDEGROUP_YAWPITCHROLL = 0x0002, /**< YawPitchRoll. */
|
||||
ATTITUDEGROUP_QUATERNION = 0x0004, /**< Quaternion. */
|
||||
ATTITUDEGROUP_DCM = 0x0008, /**< DCM. */
|
||||
ATTITUDEGROUP_MAGNED = 0x0010, /**< MagNed. */
|
||||
ATTITUDEGROUP_ACCELNED = 0x0020, /**< AccelNed. */
|
||||
ATTITUDEGROUP_LINEARACCELBODY = 0x0040, /**< LinearAccelBody. */
|
||||
ATTITUDEGROUP_LINEARACCELNED = 0x0080, /**< LinearAccelNed. */
|
||||
ATTITUDEGROUP_YPRU = 0x0100 /**< YprU. */
|
||||
#ifdef EXTRA
|
||||
,
|
||||
ATTITUDEGROUP_YPRRATE = 0x0200, /**< YprRate. */
|
||||
ATTITUDEGROUP_STATEAHRS = 0x0400, /**< StateAhrs. */
|
||||
ATTITUDEGROUP_COVAHRS = 0x0800 /**< CovAhrs. */
|
||||
#endif
|
||||
} AttitudeGroup;
|
||||
|
||||
/** \brief Flags for the binary group 6 'INS' in the binary output registers. */
|
||||
typedef enum
|
||||
{
|
||||
INSGROUP_NONE = 0x0000, /**< None. */
|
||||
INSGROUP_INSSTATUS = 0x0001, /**< InsStatus. */
|
||||
INSGROUP_POSLLA = 0x0002, /**< PosLla. */
|
||||
INSGROUP_POSECEF = 0x0004, /**< PosEcef. */
|
||||
INSGROUP_VELBODY = 0x0008, /**< VelBody. */
|
||||
INSGROUP_VELNED = 0x0010, /**< VelNed. */
|
||||
INSGROUP_VELECEF = 0x0020, /**< VelEcef. */
|
||||
INSGROUP_MAGECEF = 0x0040, /**< MagEcef. */
|
||||
INSGROUP_ACCELECEF = 0x0080, /**< AccelEcef. */
|
||||
INSGROUP_LINEARACCELECEF = 0x0100, /**< LinearAccelEcef. */
|
||||
INSGROUP_POSU = 0x0200, /**< PosU. */
|
||||
INSGROUP_VELU = 0x0400 /**< VelU. */
|
||||
#ifdef EXTRA
|
||||
,
|
||||
INSGROUP_STATEINS = 0x0800, /**< StateIns. */
|
||||
INSGROUP_COVINS = 0x1000 /**< CovIns. */
|
||||
#endif
|
||||
} InsGroup;
|
||||
|
||||
/** \brief Enumeration of the velocity types */
|
||||
typedef enum
|
||||
{
|
||||
CDVEL_None,
|
||||
CDVEL_GpsNed,
|
||||
CDVEL_GpsEcef,
|
||||
CDVEL_EstimatedNed,
|
||||
CDVEL_EstimatedEcef,
|
||||
CDVEL_EstimatedBody
|
||||
} VelocityType;
|
||||
|
||||
/** \brief Errors that the VectorNav sensor can report. */
|
||||
typedef enum
|
||||
{
|
||||
ERR_HARD_FAULT = 1, /**< Hard fault. */
|
||||
ERR_SERIAL_BUFFER_OVERFLOW = 2, /**< Serial buffer overflow. */
|
||||
ERR_INVALID_CHECKSUM = 3, /**< Invalid checksum. */
|
||||
ERR_INVALID_COMMAND = 4, /**< Invalid command. */
|
||||
ERR_NOT_ENOUGH_PARAMETERS = 5, /**< Not enough parameters. */
|
||||
ERR_TOO_MANY_PARAMETERS = 6, /**< Too many parameters. */
|
||||
ERR_INVALID_PARAMETER = 7, /**< Invalid parameter. */
|
||||
ERR_INVALID_REGISTER = 8, /**< Invalid register. */
|
||||
ERR_UNAUTHORIZED_ACCESS = 9, /**< Unauthorized access. */
|
||||
ERR_WATCHDOG_RESET = 10, /**< Watchdog reset. */
|
||||
ERR_OUTPUT_BUFFER_OVERFLOW = 11, /**< Output buffer overflow. */
|
||||
ERR_INSUFFICIENT_BAUD_RATE = 12, /**< Insufficient baud rate. */
|
||||
ERR_ERROR_BUFFER_OVERFLOW = 255 /**< Error buffer overflow. */
|
||||
} SensorError;
|
||||
|
||||
/** \brief Enumeration of the various error messages used by the library. */
|
||||
typedef enum
|
||||
{
|
||||
/** Indicates there were no errors encountered. */
|
||||
E_NONE,
|
||||
|
||||
/** Indicates an unknown error occurred. */
|
||||
E_UNKNOWN,
|
||||
|
||||
/** Indicates a provided buffer was too small to complete the action. */
|
||||
E_BUFFER_TOO_SMALL,
|
||||
|
||||
/** Indicates a provided value is not valid. */
|
||||
E_INVALID_VALUE,
|
||||
|
||||
/** Indicates the requested functionality is currently not implemented. */
|
||||
E_NOT_IMPLEMENTED,
|
||||
|
||||
/** Indicates the requested functionality is not supported. */
|
||||
E_NOT_SUPPORTED,
|
||||
|
||||
/** Indicates the requested item was not found. */
|
||||
E_NOT_FOUND,
|
||||
|
||||
/** Indicates the operation timed out. */
|
||||
E_TIMEOUT,
|
||||
|
||||
/** Indicates insufficient permission to perform the operation. */
|
||||
E_PERMISSION_DENIED,
|
||||
|
||||
/** Indicates an invalid operation was attempted. */
|
||||
E_INVALID_OPERATION,
|
||||
|
||||
/** Indicates an event was signaled. */
|
||||
E_SIGNALED,
|
||||
|
||||
/** Indicates either not enough memory is available or no memory was allocated */
|
||||
E_MEMORY_NOT_ALLOCATED,
|
||||
|
||||
/** VectorNav sensor hard fault (Code 1). */
|
||||
E_SENSOR_HARD_FAULT = 1001,
|
||||
|
||||
/** VectorNav sensor serial buffer overflow (Code 2). */
|
||||
E_SENSOR_SERIAL_BUFFER_OVERFLOW = 1002,
|
||||
|
||||
/** VectorNav sensor invalid checksum (Code 3). */
|
||||
E_SENSOR_INVALID_CHECKSUM = 1003,
|
||||
|
||||
/** VectorNav sensor invalid command (Code 4). */
|
||||
E_SENSOR_INVALID_COMMAND = 1004,
|
||||
|
||||
/** VectorNav sensor not enough parameters (Code 5). */
|
||||
E_SENSOR_NOT_ENOUGH_PARAMETERS = 1005,
|
||||
|
||||
/** VectorNav sensor too many parameters (Code 6). */
|
||||
E_SENSOR_TOO_MANY_PARAMETERS = 1006,
|
||||
|
||||
/** VectorNav sensor invalid parameter (Code 7). */
|
||||
E_SENSOR_INVALID_PARAMETER = 1007,
|
||||
|
||||
/** VectorNav sensor invalid register (Code 8). */
|
||||
E_SENSOR_INVALID_REGISTER = 1008,
|
||||
|
||||
/** VectorNav sensor unauthorized access (Code 9). */
|
||||
E_SENSOR_UNAUTHORIZED_ACCESS = 1009,
|
||||
|
||||
/** VectorNav sensor watchdog reset (Code 10). */
|
||||
E_SENSOR_WATCHDOG_RESET = 1010,
|
||||
|
||||
/** VectorNav sensor output buffer overflow (Code 11). */
|
||||
E_SENSOR_OUTPUT_BUFFER_OVERFLOW = 1011,
|
||||
|
||||
/** VectorNav sensor insufficient baud rate (Code 12). */
|
||||
E_SENSOR_INSUFFICIENT_BAUD_RATE = 1012,
|
||||
|
||||
/** VectorNav sensor error buffer overflow (Code 13). */
|
||||
E_SENSOR_ERROR_BUFFER_OVERFLOW = 1013,
|
||||
|
||||
E_DATA_NOT_ELLIPTICAL = 2001, /**< \brief Data set not elliptical. */
|
||||
E_ILL_CONDITIONED = 2002, /**< \brief Algorithm had a bad condition. */
|
||||
E_EXCEEDED_MAX_ITERATIONS = 2003, /**< \brief Algorithm exceeded the number of interations it is allowed. */
|
||||
E_BAD_FINAL_INTERATION = 2004, /**< \brief Algorithm's last interation changed exceeded threshold. */
|
||||
E_INSUFFICIENT_DATA = 2005, /**< \brief Not enough data points were provided. */
|
||||
|
||||
/** \brief Errors that the VectorNav bootload can report. */
|
||||
E_BOOTLOADER_NONE = 3000, /**< No Error, send next record*/
|
||||
E_BOOTLOADER_INVALID_COMMAND = 3001, /**< Problem with VNX record, abort */
|
||||
E_BOOTLOADER_INVALID_RECORD_TYPE = 3002, /**< Problem with VNX record, abort */
|
||||
E_BOOTLOADER_INVALID_BYTE_COUNT = 3003, /**< Problem with VNX record, abort */
|
||||
E_BOOTLOADER_INVALID_MEMORY_ADDRESS = 3004, /**< Problem with VNX record, abort */
|
||||
E_BOOTLOADER_COMM_ERROR = 3005, /**< Checksum error, resend record */
|
||||
E_BOOTLOADER_INVALID_HEX_FILE = 3006, /**< Problem with VNX record, abort */
|
||||
E_BOOTLOADER_DECRYPTION_ERROR = 3007, /**< Invalid VNX file or record sent out of order, abort */
|
||||
E_BOOTLOADER_INVALID_BLOCK_CRC = 3008, /**< Data verification failed, abort */
|
||||
E_BOOTLOADER_INVALID_PROGRAM_CRC = 3009, /**< Problemw ith firmware on device */
|
||||
E_BOOTLOADER_INVALID_PROGRAM_SIZE = 3010, /**< Problemw ith firmware on device */
|
||||
E_BOOTLOADER_MAX_RETRY_COUNT = 3011, /**< Too many errors, abort */
|
||||
E_BOOTLOADER_TIMEOUT = 3012, /**< Timeout expired, reset */
|
||||
E_BOOTLOADER_RESERVED = 3013 /**< Contact VectorNav, abort */
|
||||
|
||||
} VnError;
|
||||
|
||||
/** \brief Enumeration of the various error-detection algorithms used by the
|
||||
* library. */
|
||||
typedef enum
|
||||
{
|
||||
/** Signifies no error-detection should be performed. */
|
||||
VNERRORDETECTIONMODE_NONE,
|
||||
|
||||
/** Signifies to use 8-bit XOR checksum. */
|
||||
VNERRORDETECTIONMODE_CHECKSUM,
|
||||
|
||||
/** Signifies to use CRC16-CCITT algorithm. */
|
||||
VNERRORDETECTIONMODE_CRC
|
||||
|
||||
} VnErrorDetectionMode;
|
||||
|
||||
/** \brief Different modes for the SyncInMode field of the Synchronization Control register. */
|
||||
typedef enum
|
||||
{
|
||||
#ifdef EXTRA
|
||||
/** \brief Count the number of trigger events on SYNC_IN_2 pin.
|
||||
/ * \deprecated This option is obsolete for VN-100 firmware version 2.0 and greater and VN-200 firmware version 1.0 and greater.
|
||||
*/
|
||||
VNSYNCINMODE_COUNT2 = 0,
|
||||
/** \brief Start ADC sampling on trigger of SYNC_IN_2 pin.
|
||||
/ * \deprecated This option is obsolete for VN-100 firmware version 2.0 and greater and VN-200 firmware version 1.0 and greater.
|
||||
*/
|
||||
VNSYNCINMODE_ADC2 = 1,
|
||||
/** \brief Output asynchronous message on trigger of SYNC_IN_2 pin.
|
||||
/ * \deprecated This option is obsolete for VN-100 firmware version 2.0 and greater and VN-200 firmware version 1.0 and greater.
|
||||
*/
|
||||
VNSYNCINMODE_ASYNC2 = 2,
|
||||
#endif
|
||||
/** \brief Count number of trigger events on SYNC_IN pin.
|
||||
*/
|
||||
VNSYNCINMODE_COUNT = 3,
|
||||
/** \brief Start IMU sampling on trigger of SYNC_IN pin.
|
||||
*/
|
||||
VNSYNCINMODE_IMU = 4,
|
||||
/** \brief Output asynchronous message on trigger of SYNC_IN pin.
|
||||
*/
|
||||
VNSYNCINMODE_ASYNC = 5
|
||||
} VnSyncInMode;
|
||||
|
||||
/** \brief Different modes for the SyncInEdge field of the Synchronization Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Trigger on the rising edge on the SYNC_IN pin.
|
||||
*/
|
||||
VNSYNCINEDGE_RISING = 0,
|
||||
/** \brief Trigger on the falling edge on the SYNC_IN pin.
|
||||
*/
|
||||
VNSYNCINEDGE_FALLING = 1
|
||||
} VnSyncInEdge;
|
||||
|
||||
/** \brief Different modes for the SyncOutMode field of the Synchronization Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief None.
|
||||
*/
|
||||
VNSYNCOUTMODE_NONE = 0,
|
||||
/** \brief Trigger at start of IMU sampling.
|
||||
*/
|
||||
VNSYNCOUTMODE_ITEMSTART = 1,
|
||||
/** \brief Trigger when IMU measurements are available.
|
||||
*/
|
||||
VNSYNCOUTMODE_IMUREADY = 2,
|
||||
/** \brief Trigger when attitude measurements are available.
|
||||
*/
|
||||
VNSYNCOUTMODE_INS = 3,
|
||||
/** \brief Trigger on GPS PPS event when a 3D fix is valid.
|
||||
*/
|
||||
VNSYNCOUTMODE_GPSPPS = 6
|
||||
} VnSyncOutMode;
|
||||
|
||||
/** \brief Different modes for the SyncOutPolarity field of the Synchronization Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Negative pulse.
|
||||
*/
|
||||
VNSYNCOUTPOLARITY_NEGATIVE = 0,
|
||||
/** \brief Positive pulse.
|
||||
*/
|
||||
VNSYNCOUTPOLARITY_POSITIVE = 1
|
||||
} VnSyncOutPolarity;
|
||||
|
||||
/** \brief Counting modes for the Communication Protocol Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Off.
|
||||
*/
|
||||
VNCOUNTMODE_NONE = 0,
|
||||
/** \brief SyncIn counter.
|
||||
*/
|
||||
VNCOUNTMODE_SYNCINCOUNT = 1,
|
||||
/** \brief SyncIn time.
|
||||
*/
|
||||
VNCOUNTMODE_SYNCINTIME = 2,
|
||||
/** \brief SyncOut counter.
|
||||
*/
|
||||
VNCOUNTMODE_SYNCOUTCOUNTER = 3,
|
||||
/** \brief GPS PPS time.
|
||||
*/
|
||||
VNCOUNTMODE_GPSPPS = 4
|
||||
} VnCountMode;
|
||||
|
||||
/** \brief Status modes for the Communication Protocol Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Off.
|
||||
*/
|
||||
VNSTATUSMODE_OFF = 0,
|
||||
/** \brief VPE status.
|
||||
*/
|
||||
VNSTATUSMODE_VPESTATUS = 1,
|
||||
/** \brief INS status.
|
||||
*/
|
||||
VNSTATUSMODE_INSSTATUS = 2
|
||||
} VnStatusMode;
|
||||
|
||||
/** \brief Checksum modes for the Communication Protocol Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Off.
|
||||
*/
|
||||
VNCHECKSUMMODE_OFF = 0,
|
||||
/** \brief 8-bit checksum.
|
||||
*/
|
||||
VNCHECKSUMMODE_CHECKSUM = 1,
|
||||
/** \brief 16-bit CRC.
|
||||
*/
|
||||
VNCHECKSUMMODE_CRC = 2
|
||||
} VnChecksumMode;
|
||||
|
||||
/** \brief Error modes for the Communication Protocol Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Ignore error.
|
||||
*/
|
||||
VNERRORMODE_IGNORE = 0,
|
||||
/** \brief Send error.
|
||||
*/
|
||||
VNERRORMODE_SEND = 1,
|
||||
/** \brief Send error and set ADOR register to off.
|
||||
*/
|
||||
VNERRORMODE_SENDANDOFF = 2
|
||||
} VnErrorMode;
|
||||
|
||||
/** \brief Filter modes for the IMU Filtering Configuration register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief No filtering.
|
||||
*/
|
||||
VNFILTERMODE_NOFILTERING = 0,
|
||||
/** \brief Filtering performed only on raw uncompensated IMU measurements.
|
||||
*/
|
||||
VNFILTERMODE_ONLYRAW = 1,
|
||||
/** \brief Filtering performed only on compensated IMU measurements.
|
||||
*/
|
||||
VNFILTERMODE_ONLYCOMPENSATED = 2,
|
||||
/** \brief Filtering performed on both uncompensated and compensated IMU measurements.
|
||||
*/
|
||||
VNFILTERMODE_BOTH = 3
|
||||
} VnFilterMode;
|
||||
|
||||
/** \brief Integration frames for the Delta Theta and Delta Velocity Configuration register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Body frame.
|
||||
*/
|
||||
VNINTEGRATIONFRAME_BODY = 0,
|
||||
/** \brief NED frame.
|
||||
*/
|
||||
VNINTEGRATIONFRAME_NED = 1
|
||||
} VnIntegrationFrame;
|
||||
|
||||
/** \brief Compensation modes for the Delta Theta and Delta Velocity configuration register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief None.
|
||||
*/
|
||||
VNCOMPENSATIONMODE_NONE = 0,
|
||||
/** \brief Bias.
|
||||
*/
|
||||
VNCOMPENSATIONMODE_BIAS = 1
|
||||
} VnCompensationMode;
|
||||
|
||||
/** \brief GPS fix modes for the GPS Solution - LLA register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief No fix.
|
||||
*/
|
||||
VNGPSFIX_NOFIX = 0,
|
||||
/** \brief Time only.
|
||||
*/
|
||||
VNGPSFIX_TIMEONLY = 1,
|
||||
/** \brief 2D.
|
||||
*/
|
||||
VNGPSFIX_2D = 2,
|
||||
/** \brief 3D.
|
||||
*/
|
||||
VNGPSFIX_3D = 3
|
||||
} VnGpsFix;
|
||||
|
||||
/** \brief GPS modes for the GPS Configuration register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Use onboard GPS.
|
||||
*/
|
||||
VNGPSMODE_ONBOARDGPS = 0,
|
||||
/** \brief Use external GPS.
|
||||
*/
|
||||
VNGPSMODE_EXTERNALGPS = 1,
|
||||
/** \brief Use external VN-200 as GPS.
|
||||
*/
|
||||
VNGPSMODE_EXTERNALVN200GPS = 2
|
||||
} VnGpsMode;
|
||||
|
||||
/** \brief GPS PPS mode for the GPS Configuration register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief GPS PPS signal on GPS_PPS pin and triggered on rising edge.
|
||||
*/
|
||||
VNPPSSOURCE_GPSPPSRISING = 0,
|
||||
/** \brief GPS PPS signal on GPS_PPS pin and triggered on falling edge.
|
||||
*/
|
||||
VNPPSSOURCE_GPSPPSFALLING = 1,
|
||||
/** \brief GPS PPS signal on SyncIn pin and triggered on rising edge.
|
||||
*/
|
||||
VNPPSSOURCE_SYNCINRISING = 2,
|
||||
/** \brief GPS PPS signal on SyncIn pin and triggered on falling edge.
|
||||
*/
|
||||
VNPPSSOURCE_SYNCINFALLING = 3
|
||||
} VnPpsSource;
|
||||
|
||||
/** \brief VPE Enable mode for the VPE Basic Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Disable
|
||||
*/
|
||||
VNVPEENABLE_DISABLE = 0,
|
||||
/** \brief Enable
|
||||
*/
|
||||
VNVPEENABLE_ENABLE = 1
|
||||
} VnVpeEnable;
|
||||
|
||||
/** \brief VPE Heading modes used by the VPE Basic Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Absolute heading.
|
||||
*/
|
||||
VNHEADINGMODE_ABSOLUTE = 0,
|
||||
/** \brief Relative heading.
|
||||
*/
|
||||
VNHEADINGMODE_RELATIVE = 1,
|
||||
/** \brief Indoor heading.
|
||||
*/
|
||||
VNHEADINGMODE_INDOOR = 2
|
||||
} VnHeadingMode;
|
||||
|
||||
/** \brief VPE modes for the VPE Basic Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Off.
|
||||
*/
|
||||
VNVPEMODE_OFF = 0,
|
||||
/** \brief Mode 1.
|
||||
*/
|
||||
VNVPEMODE_MODE1 = 1
|
||||
} VnVpeMode;
|
||||
|
||||
/** \brief Different scenario modes for the INS Basic Configuration register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief AHRS.
|
||||
*/
|
||||
VNSCENARIO_AHRS = 0,
|
||||
/** \brief General purpose INS with barometric pressure sensor.
|
||||
*/
|
||||
VNSCENARIO_INSWITHPRESSURE = 1,
|
||||
/** \brief General purpose INS without barometric pressure sensor.
|
||||
*/
|
||||
VNSCENARIO_INSWITHOUTPRESSURE = 2,
|
||||
/** \brief GPS moving baseline for dynamic applications.
|
||||
*/
|
||||
VNSCENARIO_GPSMOVINGBASELINEDYNAMIC = 3,
|
||||
/** \brief GPS moving baseline for static applications.
|
||||
*/
|
||||
VNSCENARIO_GPSMOVINGBASELINESTATIC = 4
|
||||
} VnScenario;
|
||||
|
||||
/** \brief HSI modes used for the Magnetometer Calibration Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Real-time hard/soft iron calibration algorithm is turned off.
|
||||
*/
|
||||
VNHSIMODE_OFF = 0,
|
||||
/** \brief Runs the real-time hard/soft iron calibration algorithm.
|
||||
*/
|
||||
VNHSIMODE_RUN = 1,
|
||||
/** \brief Resets the real-time hard/soft iron solution.
|
||||
*/
|
||||
VNHSIMODE_RESET = 2
|
||||
} VnHsiMode;
|
||||
|
||||
/** \brief HSI output types for the Magnetometer Calibration Control register. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Onboard HSI is not applied to the magnetic measurements.
|
||||
*/
|
||||
VNHSIOUTPUT_NOONBOARD = 1,
|
||||
/** \brief Onboard HSI is applied to the magnetic measurements.
|
||||
*/
|
||||
VNHSIOUTPUT_USEONBOARD = 3
|
||||
} VnHsiOutput;
|
||||
|
||||
/** \brief Type of velocity compensation performed by the VPE. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Disabled
|
||||
*/
|
||||
VNVELOCITYCOMPENSATIONMODE_DISABLED = 0,
|
||||
/** \brief Body Measurement
|
||||
*/
|
||||
VNVELOCITYCOMPENSATIONMODE_BODYMEASUREMENT = 1
|
||||
} VnVelocityCompensationMode;
|
||||
|
||||
/** \brief How the magnetometer is used by the filter. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Magnetometer will only affect heading.
|
||||
*/
|
||||
VNMAGNETICMODE_2D = 0,
|
||||
/** \brief Magnetometer will affect heading, pitch, and roll.
|
||||
*/
|
||||
VNMAGNETICMODE_3D = 1
|
||||
} VnMagneticMode;
|
||||
|
||||
/** \brief Source for magnetometer used by the filter. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief Use internal magnetometer.
|
||||
*/
|
||||
VNEXTERNALSENSORMODE_INTERNAL = 0,
|
||||
/** \brief Use external magnetometer. Will use measurement at every new time step.
|
||||
*/
|
||||
VNEXTERNALSENSORMODE_EXTERNAL200HZ = 1,
|
||||
/** \brief Use external magnetometer. Will only use when the measurement is updated.
|
||||
*/
|
||||
VNEXTERNALSENSORMODE_EXTERNALONUPDATE = 2
|
||||
} VnExternalSensorMode;
|
||||
|
||||
/** \brief Options for the use of FOAM. */
|
||||
typedef enum
|
||||
{
|
||||
/** \brief FOAM is not used.
|
||||
*/
|
||||
VNFOAMINIT_NOFOAMINIT = 0,
|
||||
/** \brief FOAM is used to initialize only pitch and roll.
|
||||
*/
|
||||
VNFOAMINIT_FOAMINITPITCHROLL = 1,
|
||||
/** \brief FOAM is used to initialize heading, pitch and roll.
|
||||
*/
|
||||
VNFOAMINIT_FOAMINITHEADINGPITCHROLL = 2,
|
||||
/** \brief FOAM is used to initialize pitch, roll and covariance.
|
||||
*/
|
||||
VNFOAMINIT_FOAMINITPITCHROLLCOVARIANCE = 3,
|
||||
/** \brief FOAM is used to initialize heading, pitch, roll and covariance
|
||||
*/
|
||||
VNFOAMINIT_FOAMINITHEADINGPITCHROLLCOVARIANCE = 4
|
||||
} VnFoamInit;
|
||||
|
||||
/** \brief The different types of processors. */
|
||||
typedef enum
|
||||
{
|
||||
VNPROCESSOR_NAV, /**< Navigation Processor. */
|
||||
VNPROCESSOR_GPS, /**< GPS Processor. */
|
||||
VNPROCESSOR_IMU /**< IMU Processor. */
|
||||
} VnProcessorType;
|
||||
|
||||
#endif
|
||||
14
vnproglib/c/include/vn/error.h
Normal file
14
vnproglib/c/include/vn/error.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef VN_ERROR_H_INCLUDED
|
||||
#define VN_ERROR_H_INCLUDED
|
||||
|
||||
#include "vn/enum.h"
|
||||
|
||||
/** \brief Unified error code system. */
|
||||
|
||||
/** \brief Converts a VnError enum into a string.
|
||||
*
|
||||
* \param[out] out The buffer to place the string in.
|
||||
* \param[in] val The VnError value to convert to string. */
|
||||
void strFromVnError(char* out, VnError val);
|
||||
|
||||
#endif
|
||||
34
vnproglib/c/include/vn/error_detection.h
Normal file
34
vnproglib/c/include/vn/error_detection.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef VNERRDET_H_INCLUDED
|
||||
#define VNERRDET_H_INCLUDED
|
||||
|
||||
/** \brief Error-detection capabilities. */
|
||||
|
||||
#include "vn/enum.h"
|
||||
#include "vn/int.h"
|
||||
#include "vn/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Computes the 8-bit XOR checksum of the provided data.
|
||||
*
|
||||
* \param[in] data Pointer to the start of data to perform the checksum of.
|
||||
* \param[in] length The number of bytes to include in the checksum.
|
||||
* \return The computed checksum.
|
||||
*/
|
||||
uint8_t VnChecksum8_compute(char const *data, size_t length);
|
||||
|
||||
/** \brief Computes the 16-bit CRC16-CCITT of the provided data.
|
||||
*
|
||||
* \param[in] data Pointer to the start of data to perform the CRC of.
|
||||
* \param[in] length The number of bytes to include in the CRC.
|
||||
* \return The computed CRC.
|
||||
*/
|
||||
uint16_t VnCrc16_compute(char const *data, size_t length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
29
vnproglib/c/include/vn/int.h
Normal file
29
vnproglib/c/include/vn/int.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef VNINT_H_INCLUDED
|
||||
#define VNINT_H_INCLUDED
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4820)
|
||||
#pragma warning(disable : 4255)
|
||||
#endif
|
||||
|
||||
/* Visual Studio 2008 and earlier do not include the stdint.h header file. */
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500
|
||||
typedef signed __int8 int8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
/* Just include the standard header file for integer types. */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
87
vnproglib/c/include/vn/math/matrix.h
Normal file
87
vnproglib/c/include/vn/math/matrix.h
Normal file
@ -0,0 +1,87 @@
|
||||
#ifndef VN_MATRIX_H_INCLUDED
|
||||
#define VN_MATRIX_H_INCLUDED
|
||||
|
||||
#include "vn/util/compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Represents a 3x3 matrix with an underlying data type of <c>float</c>. */
|
||||
typedef union
|
||||
{
|
||||
float e[3*3]; /**< The matrix's elements in column-major ordering. */
|
||||
|
||||
/* Check if the compiler supports anonymous unions. */
|
||||
#if defined(__STDC_VERSION___) && (__STDC_VERSION__ >= 201112L) && defined(__GNUC__)
|
||||
|
||||
struct
|
||||
{
|
||||
float e00; /**< Element [0,0]. */
|
||||
float e10; /**< Element [1,0]. */
|
||||
float e20; /**< Element [2,0]. */
|
||||
float e01; /**< Element [0,1]. */
|
||||
float e11; /**< Element [1,1]. */
|
||||
float e21; /**< Element [2,1]. */
|
||||
float e02; /**< Element [0,2]. */
|
||||
float e12; /**< Element [1,2]. */
|
||||
float e22; /**< Element [2,2]. */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} mat3f;
|
||||
|
||||
/** \brief Represents a quaternion reading with underlying data type of <c>float</c>. */
|
||||
typedef union
|
||||
{
|
||||
float c[4]; /**< Indexable. */
|
||||
|
||||
/* Check if the compiler supports anonymous unions. */
|
||||
#if defined(__STDC_VERSION___) && (__STDC_VERSION__ >= 201112L) && defined(__GNUC__)
|
||||
|
||||
struct
|
||||
{
|
||||
float x; /**< The x component. */
|
||||
float y; /**< The y component. */
|
||||
float z; /**< The z component. */
|
||||
float w; /**< The w component. */
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
float c0; /**< Component 0. */
|
||||
float c1; /**< Component 1. */
|
||||
float c2; /**< Component 2. */
|
||||
float c3; /**< Component 2. */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} quatf;
|
||||
|
||||
/** \brief Initializes a 3x3 float matrix from an float array with matrix
|
||||
* elements in column-major ordering.
|
||||
*
|
||||
* \param[out] m 3x3 float matrix to initialize
|
||||
* \param[in] fa float array containing a 3x3 matrix in column-major order */
|
||||
void vn_m3_init_fa(mat3f* m, const float* fa);
|
||||
|
||||
/** \brief Converts a mat3f to a string.
|
||||
*
|
||||
* \param[out] out The char buffer to output the result to.
|
||||
* \param[in] m The mat3f to convert.
|
||||
*/
|
||||
void strFromMat3f(char* out, mat3f m);
|
||||
|
||||
/** \brief Negates a mat3f.
|
||||
* \param[in] m Matrix to negate.
|
||||
* \return Negated matrix. */
|
||||
mat3f vnm_negative_mat3f(mat3f m);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
172
vnproglib/c/include/vn/math/vector.h
Normal file
172
vnproglib/c/include/vn/math/vector.h
Normal file
@ -0,0 +1,172 @@
|
||||
#ifndef VN_VECTOR_H_INCLUDED
|
||||
#define VN_VECTOR_H_INCLUDED
|
||||
|
||||
#include "vn/util/compiler.h"
|
||||
|
||||
/** \brief Various vector types and operations. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Represents a 3 component vector with an underlying data type of
|
||||
* <c>float</c>. */
|
||||
typedef union
|
||||
{
|
||||
float c[3]; /**< Indexable. */
|
||||
|
||||
/* Check if the compiler supports anonymous unions. */
|
||||
#if defined(__STDC_VERSION___) && (__STDC_VERSION__ >= 201112L) && defined(__GNUC__)
|
||||
|
||||
struct
|
||||
{
|
||||
float x; /**< X component. */
|
||||
float y; /**< Y component. */
|
||||
float z; /**< Z component. */
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
float c0; /**< Component 0. */
|
||||
float c1; /**< Component 1. */
|
||||
float c2; /**< Component 2. */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} vec3f;
|
||||
|
||||
/** \brief Represents a 3 component vector with an underlying data type of
|
||||
* <c>double</c>. */
|
||||
typedef union
|
||||
{
|
||||
double c[3]; /**< Indexable. */
|
||||
|
||||
/* Check if the compiler supports anonymous unions. */
|
||||
#if defined(__STDC_VERSION___) && (__STDC_VERSION__ >= 201112L) && defined(__GNUC__)
|
||||
|
||||
struct
|
||||
{
|
||||
double x; /**< The x component. */
|
||||
double y; /**< The y component. */
|
||||
double z; /**< The z component. */
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
double c0; /**< Component 0. */
|
||||
double c1; /**< Component 1. */
|
||||
double c2; /**< Component 2. */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} vec3d;
|
||||
|
||||
/** \brief Represents a 4 component vector with an underlying data type of
|
||||
* <c>float</c>. */
|
||||
typedef union
|
||||
{
|
||||
float c[4]; /**< Indexable. */
|
||||
|
||||
/* Check if the compiler supports anonymous unions. */
|
||||
#if (defined(__STDC_VERSION___) && (__STDC_VERSION__ >= 201112L)) && defined(__GNUC__)
|
||||
|
||||
struct
|
||||
{
|
||||
float x; /**< The x component. */
|
||||
float y; /**< The y component. */
|
||||
float z; /**< The z component. */
|
||||
float w; /**< The w component. */
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
float c0; /**< Component 0. */
|
||||
float c1; /**< Component 1. */
|
||||
float c2; /**< Component 2. */
|
||||
float c3; /**< Component 2. */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} vec4f;
|
||||
|
||||
/** \brief Initializes a 3-dimensional float vector from an float array.
|
||||
*
|
||||
* \param[out] v 3-dimensional float vector to initialize
|
||||
* \param[in] fa float array a 3-componet vector */
|
||||
void vn_v3_init_fa(vec3f* v, const float* fa);
|
||||
|
||||
/** Creates a vec3d initialized with provided values.
|
||||
* \param[in] x x-component.
|
||||
* \param[in] y y-component.
|
||||
* \param[in] z z-component.
|
||||
* \return The initialized vec3d. */
|
||||
vec3d create_v3d(double x, double y, double z);
|
||||
|
||||
/** \brief Adds two vec3f together.
|
||||
*
|
||||
* \param[in] lhs The lhs vec3f.
|
||||
* \param[in] rhs The rhs vec3f.
|
||||
* \return The resulting vec3f from adding lhs and rhs together. */
|
||||
vec3f add_v3f_v3f(vec3f lhs, vec3f rhs);
|
||||
|
||||
/** \brief Adds two vec3d together.
|
||||
*
|
||||
* \param[in] lhs The lhs vec3d.
|
||||
* \param[in] rhs The rhs vec3d.
|
||||
* \return The resulting vec3d from adding lhs and rhs together. */
|
||||
vec3d add_v3d_v3d(vec3d lhs, vec3d rhs);
|
||||
|
||||
/** \brief Adds two vec4f together.
|
||||
*
|
||||
* \param[in] lhs The lhs vec4f.
|
||||
* \param[in] rhs The rhs vec4f.
|
||||
* \return The resulting vec4f from adding lhs and rhs together. */
|
||||
vec4f add_v4f_v4f(vec4f lhs, vec4f rhs);
|
||||
|
||||
/** \brief Subtracts a vec3f from another vec3f.
|
||||
*
|
||||
* \param[in] lhs The lhs vec3f.
|
||||
* \param[in] rhs The rhs vec3f.
|
||||
* \return The resulting vec3f from subtracting rhs from lhs. */
|
||||
vec3f sub_v3f_v3f(vec3f lhs, vec3f rhs);
|
||||
|
||||
/** \brief Subtracts a vec3d from another vec3d.
|
||||
*
|
||||
* \param[in] lhs The lhs vec3d.
|
||||
* \param[in] rhs The rhs vec3d.
|
||||
* \return The resulting vec3d from subtracting rhs from lhs. */
|
||||
vec3d sub_v3d_v3d(vec3d lhs, vec3d rhs);
|
||||
|
||||
/** \brief Subtracts a vec4f from another vec4f.
|
||||
*
|
||||
* \param[in] lhs The lhs vec4f.
|
||||
* \param[in] rhs The rhs vec4f.
|
||||
* \return The resulting vec4f from subtracting rhs from lhs. */
|
||||
vec4f sub_v4f_v4f(vec4f lhs, vec4f rhs);
|
||||
|
||||
/** \brief Converts a vec3f to a string.
|
||||
*
|
||||
* \param[out] out The char buffer to output the result to.
|
||||
* \param[in] v The vec3f to convert. */
|
||||
void str_vec3f(char* out, vec3f v);
|
||||
|
||||
/** \brief Converts a vec3d to a string.
|
||||
*
|
||||
* \param[out] out The char buffer to output the result to.
|
||||
* \param[in] v The vec3d to convert. */
|
||||
void str_vec3d(char* out, vec3d v);
|
||||
|
||||
/** \brief Converts a vec4f to a string.
|
||||
*
|
||||
* \param[out] out The char buffer to output the result to.
|
||||
* \param[in] v The vec4f to convert. */
|
||||
void str_vec4f(char* out, vec4f v);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
61
vnproglib/c/include/vn/protocol/common.h
Normal file
61
vnproglib/c/include/vn/protocol/common.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef _VNCOMMON_H_
|
||||
#define _VNCOMMON_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Enumeration of the available asynchronous ASCII message types. */
|
||||
typedef enum
|
||||
{
|
||||
VNOFF = 0, /**< Asynchronous output is turned off. */
|
||||
VNYPR = 1, /**< Asynchronous output type is Yaw, Pitch, Roll. */
|
||||
VNQTN = 2, /**< Asynchronous output type is Quaternion. */
|
||||
#ifdef EXTRA
|
||||
VNQTM = 3, /**< Asynchronous output type is Quaternion and Magnetic. */
|
||||
VNQTA = 4, /**< Asynchronous output type is Quaternion and Acceleration. */
|
||||
VNQTR = 5, /**< Asynchronous output type is Quaternion and Angular Rates. */
|
||||
VNQMA = 6, /**< Asynchronous output type is Quaternion, Magnetic and Acceleration. */
|
||||
VNQAR = 7, /**< Asynchronous output type is Quaternion, Acceleration and Angular Rates. */
|
||||
#endif
|
||||
VNQMR = 8, /**< Asynchronous output type is Quaternion, Magnetic, Acceleration and Angular Rates. */
|
||||
#ifdef EXTRA
|
||||
VNDCM = 9, /**< Asynchronous output type is Directional Cosine Orientation Matrix. */
|
||||
#endif
|
||||
VNMAG = 10, /**< Asynchronous output type is Magnetic Measurements. */
|
||||
VNACC = 11, /**< Asynchronous output type is Acceleration Measurements. */
|
||||
VNGYR = 12, /**< Asynchronous output type is Angular Rate Measurements. */
|
||||
VNMAR = 13, /**< Asynchronous output type is Magnetic, Acceleration, and Angular Rate Measurements. */
|
||||
VNYMR = 14, /**< Asynchronous output type is Yaw, Pitch, Roll, Magnetic, Acceleration, and Angular Rate Measurements. */
|
||||
#ifdef EXTRA
|
||||
VNYCM = 15, /**< Asynchronous output type is Yaw, Pitch, Roll, and Calibrated Measurements. */
|
||||
#endif
|
||||
VNYBA = 16, /**< Asynchronous output type is Yaw, Pitch, Roll, Body True Acceleration. */
|
||||
VNYIA = 17, /**< Asynchronous output type is Yaw, Pitch, Roll, Inertial True Acceleration. */
|
||||
#ifdef EXTRA
|
||||
VNICM = 18, /**< Asynchronous output type is Yaw, Pitch, Roll, Inertial Magnetic/Acceleration, and Angular Rate Measurements. */
|
||||
#endif
|
||||
VNIMU = 19, /**< Asynchronous output type is Calibrated Inertial Measurements. */
|
||||
VNGPS = 20, /**< Asynchronous output type is GPS LLA. */
|
||||
VNGPE = 21, /**< Asynchronous output type is GPS ECEF. */
|
||||
VNINS = 22, /**< Asynchronous output type is INS LLA solution. */
|
||||
VNINE = 23, /**< Asynchronous output type is INS ECEF solution. */
|
||||
VNISL = 28, /**< Asynchronous output type is INS LLA 2 solution. */
|
||||
VNISE = 29, /**< Asynchronous output type is INS ECEF 2 solution. */
|
||||
VNDTV = 30, /**< Asynchronous output type is Delta Theta and Delta Velocity. */
|
||||
VNRTK = 31 /**< Asynchronous output type is RTK, from the GPS processor. */
|
||||
#ifdef EXTRA
|
||||
,
|
||||
VNRAW = 252, /**< Asynchronous output type is Raw Voltage Measurements. */
|
||||
VNCMV = 253, /**< Asynchronous output type is Calibrated Measurements. */
|
||||
VNSTV = 254, /**< Asynchronous output type is Kalman Filter State Vector. */
|
||||
VNCOV = 255 /**< Asynchronous output type is Kalman Filter Covariance Matrix Diagonal. */
|
||||
#endif
|
||||
} VnAsciiAsync;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
2481
vnproglib/c/include/vn/protocol/spi.h
Normal file
2481
vnproglib/c/include/vn/protocol/spi.h
Normal file
File diff suppressed because it is too large
Load Diff
3650
vnproglib/c/include/vn/protocol/upack.h
Normal file
3650
vnproglib/c/include/vn/protocol/upack.h
Normal file
File diff suppressed because it is too large
Load Diff
129
vnproglib/c/include/vn/protocol/upackf.h
Normal file
129
vnproglib/c/include/vn/protocol/upackf.h
Normal file
@ -0,0 +1,129 @@
|
||||
#ifndef VNUPACKF_H_INCLUDED
|
||||
#define VNUPACKF_H_INCLUDED
|
||||
|
||||
#include "vn/protocol/upack.h"
|
||||
|
||||
/*#include "vnint.h"*/
|
||||
/*#include "vnbool.h"*/
|
||||
/*#include "vntypes.h"
|
||||
#include "vnerror.h"*/
|
||||
|
||||
|
||||
#ifndef VNUART_PROTOCOL_BUFFER_SIZE
|
||||
/** Default internal buffers size for handling received UART data. */
|
||||
#define VNUART_PROTOCOL_BUFFER_SIZE 256
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Defines signature of functions that can handle callback
|
||||
* notifications of packets successfully received and validated from a
|
||||
* VectorNav sensor. */
|
||||
typedef void(*VnUartPacketFinder_PacketFoundHandler)(void *userData, VnUartPacket* packet, size_t runningIndexOfPacketStart);
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4820)
|
||||
#endif
|
||||
|
||||
/** \brief Data structure holding current parsing status of data received from
|
||||
* a VectorNav sensor.
|
||||
*
|
||||
* This structure contains a buffer which will hold bytes that are currently
|
||||
* being processed. The size of this buffer can be adjusted by defining the
|
||||
* size using the preprocesser. For example, the size can be adjusted to use
|
||||
* 1024 bytes by defining VNUART_PROTOCOL_BUFFER_SIZE=1024. */
|
||||
typedef struct
|
||||
{
|
||||
/** \brief Callback for when a packet has been found and validated. */
|
||||
VnUartPacketFinder_PacketFoundHandler packetFoundHandler;
|
||||
|
||||
/** \brief User data for callbacks on the packetFoundHandler. */
|
||||
void *packetFoundHandlerUserData;
|
||||
|
||||
/** \brief Used for correlating the position in the received raw data
|
||||
* stream where packets are found. */
|
||||
size_t runningDataIndex;
|
||||
|
||||
/** \brief Indicates if an ASCII packet is currently being built. */
|
||||
bool asciiCurrentlyBuildingPacket;
|
||||
|
||||
/** \brief Indicates a suspected start of an ASCII packet. */
|
||||
size_t asciiPossibleStartOfPacketIndex;
|
||||
|
||||
/** \brief Index of start of ASCII packet in total running index. */
|
||||
size_t asciiRunningDataIndexOfStart;
|
||||
|
||||
/** \brief Indicates if the first ending character has been found. */
|
||||
bool asciiEndChar1Found;
|
||||
|
||||
/** \brief Indicates if we are currently building a binary packet. */
|
||||
bool binaryCurrentlyBuildingBinaryPacket;
|
||||
|
||||
/** \brief Index of start of binary packet in total running index. */
|
||||
size_t binaryRunningDataIndexOfStart;
|
||||
|
||||
/** \brief Holds the size of the receive buffer. */
|
||||
size_t bufferSize;
|
||||
|
||||
/** \brief The current location to append data into the buffer. */
|
||||
size_t bufferAppendLocation;
|
||||
|
||||
/** \brief Indicates if we have found the groups present data field for a
|
||||
* binary packet we are building. */
|
||||
bool binaryGroupsPresentFound;
|
||||
|
||||
/** \brief The groups present found from a binary packet. */
|
||||
uint8_t binaryGroupsPresent;
|
||||
|
||||
/** \brief Indicates the number of bytes remaining to have all group fields
|
||||
* for a binary data packet we are processing. */
|
||||
uint8_t binaryNumOfBytesRemainingToHaveAllGroupFields;
|
||||
|
||||
/** \brief Start index of a possible binary packet. */
|
||||
size_t binaryPossibleStartIndex;
|
||||
|
||||
/** \brief Keeps track of the number of bytes remaining for a complete
|
||||
* binary packet. */
|
||||
size_t binaryNumberOfBytesRemainingForCompletePacket;
|
||||
|
||||
/** \brief The receive buffer. */
|
||||
uint8_t receiveBuffer[VNUART_PROTOCOL_BUFFER_SIZE];
|
||||
|
||||
} VnUartPacketFinder;
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/** \brief Initializes the VnUartPacketFinder data structure.
|
||||
*
|
||||
* \param[in] pf VnUartPacketFinder to init. */
|
||||
void VnUartPacketFinder_initialize(VnUartPacketFinder* pf);
|
||||
|
||||
/** \brief Processes received data from the UART.
|
||||
*
|
||||
* \param[in] finder The associated VnUartPacketFinder containing the data
|
||||
* processing state.
|
||||
* \param[in] data The received data.
|
||||
* \param[in] len The number of bytes to process.
|
||||
* \param[in] bootloaderFilter Enable filtering for bootloader messages. */
|
||||
VnError VnUartPacketFinder_processData_ex(VnUartPacketFinder* finder, uint8_t* data, size_t len, bool bootloaderFilter);
|
||||
VnError VnUartPacketFinder_processData(VnUartPacketFinder* finder, uint8_t* data, size_t len);
|
||||
|
||||
|
||||
/** \brief Allows registering for notification of when valid packets are found.
|
||||
*
|
||||
* \param[in] handler The callback function for receiving notifications.
|
||||
* \param[in] userData Pointer to user supplied data which will be sent on all callback notifications.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnUartPacketFinder_registerPacketFoundHandler(VnUartPacketFinder* finder, VnUartPacketFinder_PacketFoundHandler handler, void *userData);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
2020
vnproglib/c/include/vn/sensors.h
Normal file
2020
vnproglib/c/include/vn/sensors.h
Normal file
File diff suppressed because it is too large
Load Diff
245
vnproglib/c/include/vn/sensors/compositedata.h
Normal file
245
vnproglib/c/include/vn/sensors/compositedata.h
Normal file
@ -0,0 +1,245 @@
|
||||
#ifndef _VNCOMPOSITEDATA_H_
|
||||
#define _VNCOMPOSITEDATA_H_
|
||||
|
||||
#include "vn/bool.h"
|
||||
#include "vn/xplat/criticalsection.h"
|
||||
#include "vn/enum.h"
|
||||
#include "vn/int.h"
|
||||
#include "vn/math/vector.h"
|
||||
#include "vn/math/matrix.h"
|
||||
#include "vn/protocol/upack.h"
|
||||
#include "vn/math/vector.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4820)
|
||||
#endif
|
||||
|
||||
/** \brief Composite structure of all available data types from VectorNav sensors. */
|
||||
typedef struct
|
||||
{
|
||||
vec3f yawPitchRoll; /**< Yaw, pitch, roll data. */
|
||||
vec4f quaternion; /**< Quaternion data. */
|
||||
mat3f directionCosineMatrix; /**< Direction cosine matrix data. */
|
||||
vec3d positionGpsLla; /**< GPS latitude, longitude, altitude data. */
|
||||
vec3d positionGpsEcef; /**< GPS earth-centered, earth-fixed data. */
|
||||
vec3d positionEstimatedLla; /**< Estimated latitude, longitude, altitude data. */
|
||||
vec3d positionEstimatedEcef; /**< Estimated earth-centered, earth-fixed position data. */
|
||||
VelocityType velocityType; /**< Type of velocity in the struct. */
|
||||
vec3f velocityGpsNed; /**< GPS velocity NED data. */
|
||||
vec3f velocityGpsEcef; /**< GPS velocity ECEF data. */
|
||||
vec3f velocityEstimatedBody; /**< Estimated velocity body data. */
|
||||
vec3f velocityEstimatedNed; /**< Estimated velocity NED data. */
|
||||
vec3f velocityEstimatedEcef; /**< Estimated velocity ECEF data. */
|
||||
vec3f magnetic; /**< Magnetic data. */
|
||||
vec3f magneticUncompensated; /**< Magnetic uncompensated data. */
|
||||
vec3f magneticNed; /**< Magnetic NED data. */
|
||||
vec3f magneticEcef; /**< Magnetic ECEF data. */
|
||||
#ifdef EXTRA
|
||||
vec3f magneticRaw; /**< Magnetic raw data. */
|
||||
#endif
|
||||
vec3f acceleration; /**< Acceleration data. */
|
||||
vec3f accelerationUncompensated; /**< Acceleration uncompensated data. */
|
||||
vec3f accelerationNed; /**< Acceleration NED data. */
|
||||
vec3f accelerationEcef; /**< Acceleration ECEF data. */
|
||||
vec3f accelerationLinearBody; /**< Acceleration linear body data. */
|
||||
vec3f accelerationLinearNed; /**< Acceleration linear NED data. */
|
||||
vec3f accelerationLinearEcef; /**< Acceleration linear ECEF data. */
|
||||
#ifdef EXTRA
|
||||
vec3f accelerationRaw; /**< Acceleration raw data. */
|
||||
#endif
|
||||
vec3f angularRate; /**< Angular rate data. */
|
||||
vec3f angularRateUncompensated; /**< Angular rate uncompensated data. */
|
||||
#ifdef EXTRA
|
||||
vec3f angularRateRaw; /**< Angular rate raw data. */
|
||||
#endif
|
||||
float temperature; /**< Temperature data. */
|
||||
#ifdef EXTRA
|
||||
float temperatureRaw; /**< Temperature raw data. */
|
||||
#endif
|
||||
float pressure; /**< Pressure data. */
|
||||
uint64_t timeStartup; /**< Time startup data. */
|
||||
float deltaTime; /**< Delta time data. */
|
||||
vec3f deltaTheta; /**< Delta theta data. */
|
||||
vec3f deltaVelocity; /**< Delta velocity data. */
|
||||
double tow; /**< GPS time of week data. */
|
||||
uint16_t week; /**< Week data. */
|
||||
uint8_t gpsFix; /**< GPS fix data. */
|
||||
uint8_t numSats; /**< NumSats data. */
|
||||
uint64_t timeGps; /**< TimeGps data. */
|
||||
uint64_t timeGpsPps; /**< TimeGpsPps data. */
|
||||
TimeUtc timeUtc; /**< TimeUtc data. */
|
||||
uint64_t gpsTow; /**< GpsTow data. */
|
||||
vec3f attitudeUncertainty; /**< Attitude uncertainty data. */
|
||||
vec3f positionUncertaintyGpsNed; /**< GPS position uncertainty NED data. */
|
||||
vec3f positionUncertaintyGpsEcef; /**< GPS position uncertainty ECEF data. */
|
||||
float positionUncertaintyEstimated; /**< Estimated position uncertainty data. */
|
||||
float velocityUncertaintyGps; /**< GPS velocity uncertainty data. */
|
||||
float velocityUncertaintyEstimated; /**< Estimated velocity uncertainty data. */
|
||||
uint32_t timeUncertainty; /**< Time uncertainty data. */
|
||||
uint16_t vpeStatus; /**< VpeStatus data. */
|
||||
uint16_t insStatus; /**< InsStatus data. */
|
||||
uint64_t timeSyncIn; /**< TimeSyncIn data. */
|
||||
uint32_t syncInCnt; /**< SyncInCnt data. */
|
||||
uint32_t syncOutCnt; /**< SyncInCnt data. */
|
||||
uint16_t sensSat; /**< SensSat data. */
|
||||
#ifdef EXTRA
|
||||
vec3f yprRates; /**< YprRates data. */
|
||||
#endif
|
||||
vec3d positionGps2Lla; /**< GPS2 latitude, longitude, altitude data. */
|
||||
vec3d positionGps2Ecef; /**< GPS2 earth-centered, earth-fixed data. */
|
||||
vec3f velocityGps2Ned; /**< GPS2 velocity NED data. */
|
||||
vec3f velocityGps2Ecef; /**< GPS2 velocity ECEF data. */
|
||||
uint16_t weekGps2; /**< GPS2 Week data. */
|
||||
uint8_t fixGps2; /**< GPS2 fix data. */
|
||||
uint8_t numSatsGps2; /**< GPS2 NumSats data. */
|
||||
uint64_t timeGps2; /**< GPS2 TimeGps data. */
|
||||
uint64_t timeGps2Pps; /**< GPS2 TimeGpsPps data. */
|
||||
uint64_t gps2Tow; /**< GPS2 GpsTow data. */
|
||||
float velocityUncertaintyGps2; /**< GPS2velocity uncertainty data. */
|
||||
vec3f positionUncertaintyGps2Ned; /**< GPS2 position uncertainty NED data. */
|
||||
vec3f positionUncertaintyGps2Ecef; /**< GPS2 position uncertainty ECEF data. */
|
||||
uint32_t timeUncertaintyGps2; /**< GPS2 Time uncertainty data. */
|
||||
TimeInfo timeInfo;
|
||||
GpsDop dop;
|
||||
} VnCompositeData;
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/** \brief Indicates if course over ground has valid data
|
||||
*
|
||||
* \param[in] compositeData The associated VnCompositeData structure.
|
||||
* \return Flag indicating if the course over ground data is available. */
|
||||
bool VnCompositeData_hasCourseOverGround(VnCompositeData* compositeData);
|
||||
|
||||
/** \brief Computers the course over ground from any velocity data available
|
||||
*
|
||||
* \param[in] compositeData The associated VnCompositeData structure.
|
||||
* \param[out] courseOverGroundOut The computered course over ground.
|
||||
* \return Flag indicating if the calculation was successful. */
|
||||
bool VnCompositeData_courseOverGround(VnCompositeData* compositeData, float* courseOverGroundOut);
|
||||
|
||||
/** \brief Indicates if speed over ground has valid data..
|
||||
*
|
||||
* \param[in] compositeData The associated VnCompositeData structure.
|
||||
* \return Flag indicating if the speed over ground data is available. */
|
||||
bool VnCompositeData_hasSpeedOverGround(VnCompositeData* compositeData);
|
||||
|
||||
/** \brief Computers the speed over ground from any velocity data available
|
||||
*
|
||||
* \param[in] compositeData The associated VnCompositeData structure.
|
||||
* \param[out] speedOverGroundOut The computered course over ground.
|
||||
* \return Flag indicating if the calculation was successful. */
|
||||
bool VnCompositeData_speedOverGround(VnCompositeData* compositeData, float* speedOverGroundOut);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_initialize(VnCompositeData* compositeData);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processBinaryPacket(VnCompositeData* compositeData, VnUartPacket* packet, VnCriticalSection* criticalSection);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processAsciiAsyncPacket(VnCompositeData* compositeData, VnUartPacket* packet, VnCriticalSection* criticalSection);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processBinaryPacketCommonGroup(
|
||||
VnCompositeData* compositeData,
|
||||
VnUartPacket* packet,
|
||||
CommonGroup groupFlags);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processBinaryPacketTimeGroup(
|
||||
VnCompositeData* compositeData,
|
||||
VnUartPacket* packet,
|
||||
TimeGroup groupFlags);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processBinaryPacketImuGroup(
|
||||
VnCompositeData* compositeData,
|
||||
VnUartPacket* packet,
|
||||
ImuGroup groupFlags);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processBinaryPacketGpsGroup(
|
||||
VnCompositeData* compositeData,
|
||||
VnUartPacket* packet,
|
||||
GpsGroup groupFlags);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processBinaryPacketAttitudeGroup(
|
||||
VnCompositeData* compositeData,
|
||||
VnUartPacket* packet,
|
||||
AttitudeGroup groupFlags);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processBinaryPacketInsGroup(
|
||||
VnCompositeData* compositeData,
|
||||
VnUartPacket* packet,
|
||||
InsGroup groupFlags);
|
||||
|
||||
/** \brief
|
||||
*
|
||||
* \param[in]
|
||||
* \param[out]
|
||||
* \return
|
||||
*/
|
||||
void VnCompositeData_processBinaryPacketGps2Group(
|
||||
VnCompositeData* compositeData,
|
||||
VnUartPacket* packet,
|
||||
GpsGroup groupFlags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
60
vnproglib/c/include/vn/sensors/ezasyncdata.h
Normal file
60
vnproglib/c/include/vn/sensors/ezasyncdata.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef _VNEZASYNCDATA_H_
|
||||
#define _VNEZASYNCDATA_H_
|
||||
|
||||
#include "vn/int.h"
|
||||
#include "vn/error.h"
|
||||
#include "vn/sensors/compositedata.h"
|
||||
#include "vn/sensors.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Structure supporting easy and reliable access to asynchronous data
|
||||
* from a VectorNav sensor at the cost of a slight performance hit. */
|
||||
typedef struct
|
||||
{
|
||||
/** \brief The associated connected sensor. */
|
||||
VnSensor* sensor;
|
||||
|
||||
/** \brief Critical section for accessing the current data. */
|
||||
VnCriticalSection* curDataCS;
|
||||
|
||||
/** \brief The current data received from asynchronous data packets. */
|
||||
VnCompositeData* curData;
|
||||
|
||||
} VnEzAsyncData;
|
||||
|
||||
/** \brief Initializes and connects to a VectorNav sensor with the specified
|
||||
* connection parameters.
|
||||
*
|
||||
* \param[in] ezAsyncData The associated VnEzAsyncData structure.
|
||||
* \param]in] portName The name of the serial port to connect to.
|
||||
* \param[in] baudrate The baudrate to connect at.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnEzAsyncData_initializeAndConnect(VnEzAsyncData* ezAsyncData, const char* portName, uint32_t baudrate);
|
||||
|
||||
/** \brief Disconnects from a VectorNav sensor.
|
||||
*
|
||||
* \param[in] ezAsyncData The associated VnEzAsyncData structure.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnEzAsyncData_disconnectAndUninitialize(VnEzAsyncData* ezAsyncData);
|
||||
|
||||
/** \brief Returns the most recent asynchronous data the VnEzAsyncData structure
|
||||
* has processed.
|
||||
*
|
||||
* \param[in] ezAsyncData The associated VnEzAsyncData structure.
|
||||
* \return The latest data processed. */
|
||||
VnCompositeData VnEzAsyncData_currentData(VnEzAsyncData* ezAsyncData);
|
||||
|
||||
/** \brief Returns the underlying VnSensor referenced.
|
||||
*
|
||||
* \param[in] ezAsyncData The associated VnEzAsyncData structure.
|
||||
* \return The underlying VnSensor reference. */
|
||||
VnSensor* VnEzAsyncData_sensor(VnEzAsyncData* ezAsyncData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
94
vnproglib/c/include/vn/sensors/searcher.h
Normal file
94
vnproglib/c/include/vn/sensors/searcher.h
Normal file
@ -0,0 +1,94 @@
|
||||
#ifndef _SEARCHER_H_
|
||||
#define _SEARCHER_H_
|
||||
|
||||
#include "vn/bool.h"
|
||||
#include "vn/int.h"
|
||||
#include "vn/xplat/serialport.h"
|
||||
#include "vn/xplat/thread.h"
|
||||
|
||||
/* These defines are used to enable a single function name while implementing */
|
||||
/* different solutions given the OS. */
|
||||
#if defined __linux__ || defined __CYGWIN__
|
||||
#define VnSearcher_findPorts VnSearcher_findPorts_LINUX
|
||||
#elif defined _WIN32
|
||||
#define VnSearcher_findPorts VnSearcher_findPorts_WIN32
|
||||
#else
|
||||
#error ERROR: System not yet supported in VnSearcher
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4820)
|
||||
#endif
|
||||
|
||||
/** \brief containing information about the port to be searched. */
|
||||
typedef struct
|
||||
{
|
||||
/** \brief Contains the name of the port. */
|
||||
char* portName;
|
||||
|
||||
/** \brief VnThread object for callback purposes. */
|
||||
VnThread thread;
|
||||
|
||||
/** \brief Baud of the attached senosr, -1 for no sensor, -2 for error. */
|
||||
int32_t baud;
|
||||
|
||||
/** \brief size of the data array */
|
||||
size_t dataSize;
|
||||
|
||||
/** \brief VnSerialPort object to handle communication to the sensor. */
|
||||
VnSerialPort* port;
|
||||
|
||||
/** \brief Array to store partial/completed communication data from the sensor. */
|
||||
char data[255];
|
||||
} VnPortInfo;
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/** \brief Takes a VnPortInfo and returns the name of the port.
|
||||
* \parm[in] portInfo Pointer to a VnPortInfo struct
|
||||
* \return The name of the port
|
||||
*/
|
||||
char* VnSearcher_getPortName(VnPortInfo* portInfo);
|
||||
|
||||
/** \brief Takes a VnPortInfo and returns the baud rate or error code.
|
||||
* \parm[in] portInfo Pointer to a VnPortInfo struct
|
||||
* \return The baud rate of the port or an error code.
|
||||
* -1 indicates no sensor on the port.
|
||||
* -2 indicates an error trying to find a sensor.
|
||||
*/
|
||||
int32_t VnSearcher_getPortBaud(VnPortInfo* portInfo);
|
||||
|
||||
/** \brief Function to find the names of all of the system's serial ports.
|
||||
* \parm[out] portNames Array containing the names of all of the serial ports.
|
||||
* \parm[out] numPortsFound Number of serial ports found.
|
||||
*/
|
||||
void VnSearcher_findPorts(char*** portNames, int32_t* numPortsFound);
|
||||
|
||||
/** \brief Function to search an input port and return either the baud rate of the connected
|
||||
* sensor or an error code.
|
||||
* \parm[in] portName The system name of the port to be searched.
|
||||
* \parm[out] foundBaudrate Baud rate of the attacked sensor, -1 for no sensor, -2 for error
|
||||
*/
|
||||
void VnSearcher_findPortBaud(char* portName, int32_t* foundBaudrate);
|
||||
|
||||
/** \brief Convenience function to find all available sensors currently attached
|
||||
* to the system.
|
||||
* \parm[out] sensorsFound Pointer to an array of sensors attached to the system.
|
||||
* \parm[out] numSensors The number of sensors found.
|
||||
*/
|
||||
void VnSearcher_findAllSensors(VnPortInfo*** sensorsFound, int32_t* numSensors);
|
||||
|
||||
/** \brief Function that will search all of the input ports to see if an available sensor is attached to it.
|
||||
* NOTE: The OS will not allow the detection of sensor that is in use.
|
||||
* \parm[in] portsToCheck Array containing the names of all the ports to check.
|
||||
* \parm[in] Number of ports to check.
|
||||
* \parm[out] An array of VnPortInfo structs the same size as numPortsToCheck. The baud rate will indicate
|
||||
* if a sensor is attached. baud > 0 is the sensor baudrate, baud = -1 no sensor attached, and baud = -2
|
||||
* an error occured while detecting the sensor.
|
||||
*/
|
||||
void VnSearcher_searchInputPorts(char*** portsToCheck, int32_t numPortsToCheck, VnPortInfo*** sensorsFound);
|
||||
|
||||
#endif
|
||||
60
vnproglib/c/include/vn/types.h
Normal file
60
vnproglib/c/include/vn/types.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef VN_TYPES_H_INCLUDED
|
||||
#define VN_TYPES_H_INCLUDED
|
||||
|
||||
/** \brief Standard types used through out the library. */
|
||||
#include "vn/int.h"
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__)
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#else
|
||||
|
||||
/* Must not have C99. */
|
||||
|
||||
/** Backup definition of size_t. */
|
||||
typedef unsigned int size_t;
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Adding VectorNav data types */
|
||||
typedef struct
|
||||
{
|
||||
int8_t year; /** \brief Year field. */
|
||||
uint8_t month; /** \brief Month field. */
|
||||
uint8_t day; /** \brief Day field. */
|
||||
uint8_t hour; /** \brief Hour field. */
|
||||
uint8_t min; /** \brief Min field. */
|
||||
uint8_t sec; /** \brief Sec field. */
|
||||
uint16_t ms; /** \brief Ms field. */
|
||||
} TimeUtc;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float gDOP; /** \brief Gdop field. */
|
||||
float pDOP; /** \brief Pdop field. */
|
||||
float tDOP; /** \brief Tdop field. */
|
||||
float vDOP; /** \brief Vdop field. */
|
||||
float hDOP; /** \brief Hdop field. */
|
||||
float nDOP; /** \brief Ndop field. */
|
||||
float eDOP; /** \brief Edop field. */
|
||||
} GpsDop;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t timeStatus; /** \brief timeStatus field. */
|
||||
int8_t leapSeconds; /** \brief leapSeconds field. */
|
||||
} TimeInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
273
vnproglib/c/include/vn/util.h
Normal file
273
vnproglib/c/include/vn/util.h
Normal file
@ -0,0 +1,273 @@
|
||||
#ifndef VNUTIL_H_INCLUDED
|
||||
#define VNUTIL_H_INCLUDED
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "vn/int.h"
|
||||
#include "vn/bool.h"
|
||||
#include "vn/error.h"
|
||||
#include "vn/math/matrix.h"
|
||||
#include "vn/math/vector.h"
|
||||
#include "vn/util/export.h"
|
||||
#include "vn/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Defines for the specific version of the VectorNav library. */
|
||||
#define VNAPI_MAJOR 1
|
||||
#define VNAPI_MINOR 2
|
||||
#define VNAPI_PATCH 0
|
||||
#define VNAPI_REVISION 126
|
||||
|
||||
/** \brief Returns the major version of the VectorNav library.
|
||||
*
|
||||
* \return The major version. */
|
||||
int VnApi_major(void);
|
||||
|
||||
/** \brief Returns the minor version of the VectorNav library.
|
||||
*
|
||||
* \return The minor version. */
|
||||
int VnApi_minor(void);
|
||||
|
||||
/** \brief Returns the patch version of the VectorNav library.
|
||||
*
|
||||
* \return The patch version. */
|
||||
int VnApi_patch(void);
|
||||
|
||||
/** \brief Returns the revision version of the VectorNav library.
|
||||
*
|
||||
* \return The revision version. */
|
||||
int VnApi_revision(void);
|
||||
|
||||
/** \brief Returns the full version of the VectorNav library as a string.
|
||||
*
|
||||
* \param[out] out The buffer to place the string.
|
||||
* \param[in] outLength The number of characters available in the out buffer.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnApi_getVersion(char *out, size_t outLength);
|
||||
|
||||
/** \brief Converts the single hexadecimal character to a uint8_t.
|
||||
*
|
||||
* \param[in] c The hexadecimal character to convert.
|
||||
* \return The converted value.
|
||||
*/
|
||||
uint8_t VnUtil_toUint8FromHexChar(char c);
|
||||
|
||||
/** \brief Converts a 2 character hexadecimal string to a uint8_t.
|
||||
*
|
||||
* \param[in] str Pointer to 2 characters representing a hexadecimal
|
||||
* number.
|
||||
* \return The converted value.
|
||||
*/
|
||||
uint8_t VnUtil_toUint8FromHexStr(char const *str);
|
||||
|
||||
/** \brief Converts a 4 character hexadecimal string to a uint16_t.
|
||||
*
|
||||
* \param[in] str Pointer to 4 characters representing a hexadecimal
|
||||
* number.
|
||||
* \return The converted value.
|
||||
*/
|
||||
uint16_t VnUtil_toUint16FromHexStr(char const *str);
|
||||
|
||||
/** \brief Converts a uint8_t to a hexadecimal string.
|
||||
*
|
||||
* \param[in] toConvert The uint8_t to convert.
|
||||
* \param[in] output Pointer to the char array to write the converted value.
|
||||
* This will take 2 bytes for the output.
|
||||
*/
|
||||
void VnUtil_toHexStrFromUint8(uint8_t toConvert, char *output);
|
||||
|
||||
/** \brief Converts a uint16_t to a hexadecimal string.
|
||||
*
|
||||
* \param[in] toConvert The uint16_t to convert.
|
||||
* \param[in] output Pointer to the char array to write the converted value.
|
||||
* This will take 4 bytes for the output.
|
||||
*/
|
||||
void VnUtil_toHexStrFromUint16(uint16_t toConvert, char *output);
|
||||
|
||||
/** \brief Converts a uint16_t to a string.
|
||||
*
|
||||
* \param[in] toConvert The uint16_t to convert.
|
||||
* \param[in] output Pointer to the char array to write the converted value.
|
||||
* \return The number of characters that were written.
|
||||
*/
|
||||
size_t VnUtil_toStrFromUint16(uint16_t toConvert, char *output);
|
||||
|
||||
/** \brief Returns the number of bits set.
|
||||
*
|
||||
* \param[in] data The data value to count the number of bits set.
|
||||
* \return The number of bits set.
|
||||
*/
|
||||
uint8_t DllExport VnUtil_countSetBitsUint8(uint8_t data);
|
||||
|
||||
/** \brief Converts a boolean value into a string.
|
||||
*
|
||||
* \param[out] out The value converted to a string.
|
||||
* \param[in] val The value to convert.
|
||||
*/
|
||||
void strFromBool(char *out, bool val);
|
||||
|
||||
/** \defgroup byteOrderers Byte Ordering Functions
|
||||
* \brief This group of functions are useful for ordering of bytes
|
||||
* sent/received from VectorNav sensors.
|
||||
*
|
||||
* \{ */
|
||||
|
||||
/** \brief Converts a 16-bit integer in sensor order to host order.
|
||||
*
|
||||
* \param[in] sensorOrdered The 16-bit integer in sensor order.
|
||||
* \return The value converted to host ordered. */
|
||||
uint16_t stoh16(uint16_t sensorOrdered);
|
||||
|
||||
/** \brief Converts a 32-bit integer in sensor order to host order.
|
||||
*
|
||||
* \param[in] sensorOrdered The 32-bit integer in sensor order.
|
||||
* \return The value converted to host ordered. */
|
||||
uint32_t stoh32(uint32_t sensorOrdered);
|
||||
|
||||
/** \brief Converts a 64-bit integer in sensor order to host order.
|
||||
*
|
||||
* \param[in] sensorOrdered The 64-bit integer in sensor order.
|
||||
* \return The value converted to host ordered. */
|
||||
uint64_t stoh64(uint64_t sensorOrdered);
|
||||
|
||||
/** \brief Converts a 16-bit integer in host order to sensor order.
|
||||
*
|
||||
* \param[in] hostOrdered The 16-bit integer in host order.
|
||||
* \return The value converted to sensor ordered. */
|
||||
uint16_t htos16(uint16_t hostOrdered);
|
||||
|
||||
/** \brief Converts a 32-bit integer in host order to sensor order.
|
||||
*
|
||||
* \param[in] hostOrdered The 32-bit integer in host order.
|
||||
* \return The value converted to sensor ordered. */
|
||||
uint32_t htos32(uint32_t hostOrdered);
|
||||
|
||||
/** \brief Converts a 64-bit integer in host order to sensor order.
|
||||
*
|
||||
* \param[in] hostOrdered The 64-bit integer in host order.
|
||||
* \return The value converted to sensor ordered. */
|
||||
uint64_t htos64(uint64_t hostOrdered);
|
||||
|
||||
/** \brief Converts a 4-byte float in host order to sensor order.
|
||||
*
|
||||
* \param[in] hostOrdered The 4-byte float in host order.
|
||||
* \return The value converted to sensor ordered. */
|
||||
float htosf4(float hostOrdered);
|
||||
|
||||
/** \brief Converts an 8-byte float in host order to sensor order.
|
||||
*
|
||||
* \param[in] hostOrdered The 8-byte float in host order.
|
||||
* \return The value converted to sensor ordered. */
|
||||
double htosf8(double hostOrdered);
|
||||
|
||||
/** \} */
|
||||
|
||||
/** \defgroup sensorValueExtractors Sensor Value Extractors
|
||||
* \brief This group of methods is useful for extracting data from binary
|
||||
* data received from a VectorNav sensor either from a UART binary or a
|
||||
* SPI packet. Any necessary byte ordering will be performed.
|
||||
*
|
||||
* \{ */
|
||||
|
||||
/** \brief Extracts a uint16_t with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
uint16_t VnUtil_extractUint16(const char* pos);
|
||||
|
||||
/** \brief Extracts a uint32_t with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
uint32_t VnUtil_extractUint32(const char* pos);
|
||||
|
||||
/** \brief Extracts a <c>float</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
float VnUtil_extractFloat(const char* pos);
|
||||
|
||||
/** \brief Extracts a <c>double</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
double VnUtil_extractDouble(const char* pos);
|
||||
|
||||
/*#if THIS_SHOULD_BE_MOVED_TO_MATH_C_PACK*/
|
||||
|
||||
/** \brief Extracts a <c>vec3f</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
vec3f VnUtil_extractVec3f(const char* pos);
|
||||
|
||||
/** \brief Extracts a <c>vec4f</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
vec4f VnUtil_extractVec4f(const char* pos);
|
||||
|
||||
/** \brief Extracts a <c>vec3d</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
vec3d VnUtil_extractVec3d(const char* pos);
|
||||
|
||||
/** \brief Extracts a <c>mat3f</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
mat3f VnUtil_extractMat3f(const char* pos);
|
||||
|
||||
/** \brief Extracts a <c>GpsDop</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
GpsDop VnUtil_extractGpsDop(const char* pos);
|
||||
|
||||
/** \brief Extracts a <c>TimeUtc</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
TimeUtc VnUtil_extractTimeUtc(const char* pos);
|
||||
|
||||
/** \brief Extracts a <c>TimeInfo</c> with appropriate byte reordering from the binary
|
||||
* array received from a VectorNav sensor either from the UART binary or
|
||||
* SPI packet.
|
||||
*
|
||||
* \param[in] pos The current position to extract the value from.
|
||||
* \return The extracted value. */
|
||||
TimeInfo VnUtil_extractTimeInfo(const char* pos);
|
||||
|
||||
/*#endif*/
|
||||
|
||||
/* \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
37
vnproglib/c/include/vn/util/compiler.h
Normal file
37
vnproglib/c/include/vn/util/compiler.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef _VN_UTIL_COMPILER_H
|
||||
#define _VN_UTIL_COMPILER_H
|
||||
|
||||
/* This header provides some simple checks for various features supported by the
|
||||
* current compiler. */
|
||||
|
||||
/* Determine the level of standard C support. */
|
||||
#if __STDC__
|
||||
#if defined (__STDC_VERSION__)
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define C99
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Determine if the compiler has stdbool.h. */
|
||||
#if defined(C99) || _MSC_VER >= 1800
|
||||
#define VN_HAVE_STDBOOL_H 1
|
||||
#else
|
||||
#define VN_HAVE_STDBOOL_H 0
|
||||
#endif
|
||||
|
||||
/* Determine if the secure CRT is available. */
|
||||
#if defined(_MSC_VER)
|
||||
#define VN_HAVE_SECURE_CRT 1
|
||||
#else
|
||||
#define VN_HAVE_SECURE_CRT 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Determine if the generic type math library (tgmath.h) is available. */
|
||||
#if defined(C99)
|
||||
#define VN_HAVE_GENERIC_TYPE_MATH 1
|
||||
#else
|
||||
#define VN_HAVE_GENERIC_TYPE_MATH 0
|
||||
#endif
|
||||
16
vnproglib/c/include/vn/util/export.h
Normal file
16
vnproglib/c/include/vn/util/export.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef VNEXPORT_H_INCLUDED
|
||||
#define VNEXPORT_H_INCLUDED
|
||||
|
||||
/* Not only does this have to be windows to use __declspec */
|
||||
/* it also needs to actually be outputting a DLL */
|
||||
#if defined _WINDOWS && defined _WINDLL
|
||||
#if proglib_c_EXPORTS
|
||||
#define DllExport __declspec(dllexport)
|
||||
#else
|
||||
#define DllExport __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define DllExport
|
||||
#endif
|
||||
|
||||
#endif
|
||||
19
vnproglib/c/include/vn/util/port.h
Normal file
19
vnproglib/c/include/vn/util/port.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef VNPORT_H_INCLUDED
|
||||
#define VNPORT_H_INCLUDED
|
||||
|
||||
/** Basic portability measures. */
|
||||
|
||||
/** VNAPI - DLL linkage specifier. */
|
||||
#ifdef _MSC_VER
|
||||
#if VN_LINKED_AS_SHARED_LIBRARY
|
||||
#define VNAPI __declspec(dllimport)
|
||||
#elif VN_CREATE_SHARED_LIBRARY
|
||||
#define VNAPI __declspec(dllexport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef VNAPI
|
||||
#define VNAPI
|
||||
#endif
|
||||
|
||||
#endif
|
||||
9
vnproglib/c/include/vn/vectornav.h
Normal file
9
vnproglib/c/include/vn/vectornav.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef VECTORNAV_H
|
||||
#define VECTORNAV_H
|
||||
|
||||
#include "vnbool.h"
|
||||
#include "vnenum.h"
|
||||
#include "vnutil.h"
|
||||
#include "vnupackf.h"
|
||||
|
||||
#endif
|
||||
77
vnproglib/c/include/vn/xplat/criticalsection.h
Normal file
77
vnproglib/c/include/vn/xplat/criticalsection.h
Normal file
@ -0,0 +1,77 @@
|
||||
/** \file
|
||||
* {COMMON_HEADER}
|
||||
*
|
||||
* \section DESCRIPTION
|
||||
* This header file contains structures and functions useful for critical sections.
|
||||
*/
|
||||
#ifndef _VN_CRITICALSECTION_H_
|
||||
#define _VN_CRITICALSECTION_H_
|
||||
|
||||
#include "vn/error.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Disable some warnings for Visual Studio with -Wall. */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4668)
|
||||
#pragma warning(disable:4820)
|
||||
#pragma warning(disable:4255)
|
||||
#endif
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if _WIN32
|
||||
CRITICAL_SECTION handle;
|
||||
#elif __linux__ || __APPLE__ || __CYGWIN__ || __QNXNTO__
|
||||
pthread_mutex_t handle;
|
||||
#else
|
||||
#error "Unknown System"
|
||||
#endif
|
||||
} VnCriticalSection;
|
||||
|
||||
/** \breif Initializes a VnCriticalSection structure.
|
||||
*
|
||||
* \param[in] criticalSection The VnCriticalSection structure to initialize.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnCriticalSection_initialize(VnCriticalSection *criticalSection);
|
||||
|
||||
/** \brief Disposes of a VnCriticalSection structure and associated resources.
|
||||
*
|
||||
* \param[in] criticalSection The associated VnCriticalSection structure.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnCriticalSection_deinitialize(VnCriticalSection *criticalSection);
|
||||
|
||||
/** \brief Attempt to enter a critical section.
|
||||
*
|
||||
* \param[in] criticalSection The associated VnCriticalSection structure.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnCriticalSection_enter(VnCriticalSection *criticalSection);
|
||||
|
||||
/** \brief Leave a critical section.
|
||||
*
|
||||
* \param[in] criticalSection The associated VnCriticalSection structure.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnCriticalSection_leave(VnCriticalSection *criticalSection);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
98
vnproglib/c/include/vn/xplat/event.h
Normal file
98
vnproglib/c/include/vn/xplat/event.h
Normal file
@ -0,0 +1,98 @@
|
||||
/** \file
|
||||
* {COMMON_HEADER}
|
||||
*
|
||||
* \section DESCRIPTION
|
||||
* This header file contains structures and functions useful events and signals.
|
||||
*/
|
||||
#ifndef _VNEVENT_H_
|
||||
#define _VNEVENT_H_
|
||||
|
||||
#include "vn/int.h"
|
||||
#include "vn/error.h"
|
||||
#include "vn/bool.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Disable some warnings for Visual Studio with -Wall. */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4668)
|
||||
#pragma warning(disable:4820)
|
||||
#pragma warning(disable:4255)
|
||||
#endif
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Structure representing an event. */
|
||||
typedef struct
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HANDLE handle;
|
||||
#elif (defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__)
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t condition;
|
||||
bool isTriggered;
|
||||
#else
|
||||
#error "Unknown System"
|
||||
#endif
|
||||
} VnEvent;
|
||||
|
||||
/** \brief Initializes a VnEvent structure.
|
||||
*
|
||||
* \param[in] event The VnEvent structure to initialize.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnEvent_initialize(VnEvent *event);
|
||||
|
||||
/** \brief Causes the calling thread to wait on an event until the event is signalled.
|
||||
*
|
||||
* If the event is signalled, the value E_SIGNALED will be returned.
|
||||
*
|
||||
* \param[in] event The associated VnEvent.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnEvent_wait(VnEvent *event);
|
||||
|
||||
/** \brief Causes the calling thread to wait on an event until the event is signalled.
|
||||
*
|
||||
* If the event is signalled, the value E_SIGNALED will be returned.
|
||||
*
|
||||
* \param[in] event The associated VnEvent.
|
||||
* \param[in] timeoutUs The number of microseconds to wait before the thread stops waiting on the event. If a timeout
|
||||
* does occur, the value E_TIMEOUT will be returned.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnEvent_waitUs(VnEvent *event, uint32_t timeoutUs);
|
||||
|
||||
/** \brief Causes the calling thread to wait on an event until the event is signalled.
|
||||
*
|
||||
* If the event is signalled, the value E_SIGNALED will be returned.
|
||||
*
|
||||
* \param[in] event The associated VnEvent.
|
||||
* \param[in] timeoutMs The number of milliseconds to wait before the thread stops waiting on the event. If a timeout
|
||||
* does occur, the value E_TIMEOUT will be returned.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnEvent_waitMs(VnEvent *event, uint32_t timeoutMs);
|
||||
|
||||
/** \brief Signals an event.
|
||||
*
|
||||
* \param[in] event The associated event.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnEvent_signal(VnEvent *event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
149
vnproglib/c/include/vn/xplat/serialport.h
Normal file
149
vnproglib/c/include/vn/xplat/serialport.h
Normal file
@ -0,0 +1,149 @@
|
||||
#ifndef VN_SERIALPORT_H
|
||||
#define VN_SERIALPORT_H
|
||||
|
||||
/** Cross-platform access to serial ports. */
|
||||
|
||||
#include "vn/int.h"
|
||||
#include "vn/error.h"
|
||||
#include "vn/bool.h"
|
||||
#include "vn/xplat/thread.h"
|
||||
#include "vn/xplat/criticalsection.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
/* Disable some warnings for Visual Studio with -Wall. */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4668)
|
||||
#pragma warning(disable:4820)
|
||||
#pragma warning(disable:4255)
|
||||
#endif
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/serial.h>
|
||||
#elif defined __APPLE__
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Type for listening to data received events from the VnSerialPort. */
|
||||
typedef void (*VnSerialPort_DataReceivedHandler)(void *userData);
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4820)
|
||||
#endif
|
||||
|
||||
/** \brief Provides access to a serial port. */
|
||||
typedef struct
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HANDLE handle;
|
||||
/* Windows appears to need single-thread access to read/write API functions. */
|
||||
VnCriticalSection readWriteCS;
|
||||
#elif (defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__)
|
||||
int handle;
|
||||
#else
|
||||
#error "Unknown System"
|
||||
#endif
|
||||
|
||||
bool purgeFirstDataBytesWhenSerialPortIsFirstOpened;
|
||||
|
||||
VnSerialPort_DataReceivedHandler dataReceivedHandler;
|
||||
|
||||
void *dataReceivedHandlerUserData;
|
||||
|
||||
VnThread serialPortNotificationsThread;
|
||||
|
||||
bool continueHandlingSerialPortEvents;
|
||||
|
||||
size_t numberOfReceiveDataDroppedSections;
|
||||
|
||||
VnCriticalSection dataReceivedHandlerCriticalSection;
|
||||
|
||||
char portName[50];
|
||||
|
||||
} VnSerialPort;
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/** \brief Initializes a VnSerialPort structure.
|
||||
*
|
||||
* \param[in] serialport The VnSerialPort structure to initialize.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnSerialPort_initialize(VnSerialPort *serialport);
|
||||
|
||||
/** \brief Opens a serial port.
|
||||
*
|
||||
* \param[in] serialport The associated VnSerialPort structure.
|
||||
* \param[in] portName The name of the serial port to open.
|
||||
* \param[in] baudrate The baudrate to open the serial port at.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnSerialPort_open(VnSerialPort *serialport, char const *portName, uint32_t baudrate);
|
||||
|
||||
/** \brief Closes the serial port.
|
||||
*
|
||||
* \param[in] serialport The associated VnSerialPort structure.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnSerialPort_close(VnSerialPort *serialport);
|
||||
|
||||
/** \brief Indicates if the serial port is open or not.
|
||||
*
|
||||
* \param[in] serialport The associated VnSerialPort structure.
|
||||
* \return <c>true</c> if the serial port is open; otherwise <c>false</c>. */
|
||||
bool VnSerialPort_isOpen(VnSerialPort *serialport);
|
||||
|
||||
/** \brief Reads data from a serial port.
|
||||
*
|
||||
* \param[in] serialport The associated VnSerialPort structure.
|
||||
* \param[in] buffer Buffer to place the read bytes.
|
||||
* \param[in] numOfBytesToRead The number of bytes to read from the serial port.
|
||||
* \param[out] numOfBytesActuallyRead The number of bytes actually read from the serial port.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnSerialPort_read(VnSerialPort *serialport, char *buffer, size_t numOfBytesToRead, size_t *numOfBytesActuallyRead);
|
||||
|
||||
/** \brief Writes data out of a serial port.
|
||||
*
|
||||
* \param[in] serialport The associated VnSerialPort.
|
||||
* \param[in] data The data to write out.
|
||||
* \param[in] numOfBytesToWrite The number of bytes to write out of the serial port.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnSerialPort_write(VnSerialPort *serialport, char const *data, size_t numOfBytesToWrite);
|
||||
|
||||
/** \brief Changes the baudrate the port is connected at.
|
||||
*
|
||||
* \param[in] serialport The associated VnSerialPort.
|
||||
* \param[in] baudrate The new baudrate.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnSerialPort_changeBaudrate(VnSerialPort *serialport, uint32_t baudrate);
|
||||
|
||||
/** \brief Allows registering for notification of data received events.
|
||||
*
|
||||
* \param[in] serialPort The associated VnSerialPort.
|
||||
* \param[in] handler The callback method to receive notifications.
|
||||
* \param[in] userData User supplied data that will be sent to the handler on callbacks.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnSerialPort_registerDataReceivedHandler(VnSerialPort *serialPort, VnSerialPort_DataReceivedHandler handler, void *userData);
|
||||
|
||||
/** \brief Allows unregistering for notification of data received events.
|
||||
*
|
||||
* \param[in] serialPort The associated VnSerialPort. */
|
||||
VnError VnSerialPort_unregisterDataReceivedHandler(VnSerialPort *serialPort);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
87
vnproglib/c/include/vn/xplat/thread.h
Normal file
87
vnproglib/c/include/vn/xplat/thread.h
Normal file
@ -0,0 +1,87 @@
|
||||
/** \file
|
||||
* {COMMON_HEADER}
|
||||
*
|
||||
* \section DESCRIPTION
|
||||
* This header file contains structures and functions useful working with threads.
|
||||
*/
|
||||
#ifndef _VN_THREAD_H_
|
||||
#define _VN_THREAD_H_
|
||||
|
||||
#include "vn/error.h"
|
||||
#include "vn/int.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Disable some warnings for Visual Studio with -Wall. */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4668)
|
||||
#pragma warning(disable:4820)
|
||||
#pragma warning(disable:4255)
|
||||
#endif
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Structure for working with threads. */
|
||||
typedef struct
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HANDLE handle;
|
||||
#elif defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__
|
||||
pthread_t handle;
|
||||
#else
|
||||
#error "Unknown System"
|
||||
#endif
|
||||
} VnThread;
|
||||
|
||||
/** \brief Function signature for a start routine for a thread. */
|
||||
typedef void (*VnThread_StartRoutine)(void*);
|
||||
|
||||
/** \brief Starts a new thread immediately which calls the provided start routine.
|
||||
*
|
||||
* \param[in] thread Associated VnThread structure.
|
||||
* \param[in] startRoutine The routine to be called when the new thread is started.
|
||||
* \param[in] routineData Pointer to data that will be passed to the routine on the new thread.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnThread_startNew(VnThread *thread, VnThread_StartRoutine startRoutine, void* routineData);
|
||||
|
||||
/** \brief Blocks the calling thread until the referenced thread finishes.
|
||||
*
|
||||
* \param[in] thread The associated VnThread.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnThread_join(VnThread *thread);
|
||||
|
||||
/** \brief Causes the calling thread to sleep the specified number of seconds.
|
||||
*
|
||||
* \param[in] numOfSecsToSleep The number of seconds to sleep. */
|
||||
void VnThread_sleepSec(uint32_t numOfSecsToSleep);
|
||||
|
||||
/** \brief Causes the calling thread to sleep the specified number of milliseconds
|
||||
*
|
||||
* \param[in] numOfMsToSleep The number of milliseconds to sleep. */
|
||||
void VnThread_sleepMs(uint32_t numOfMsToSleep);
|
||||
|
||||
/** \brief Causes the calling thread to sleep the specified number of microseconds
|
||||
*
|
||||
* \param[in] numOfUsToSleep The number of microseconds to sleep. */
|
||||
void VnThread_sleepUs(uint32_t numOfUsToSleep);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
73
vnproglib/c/include/vn/xplat/time.h
Normal file
73
vnproglib/c/include/vn/xplat/time.h
Normal file
@ -0,0 +1,73 @@
|
||||
/** \file
|
||||
* {COMMON_HEADER}
|
||||
*
|
||||
* \section DESCRIPTION
|
||||
* This header file contains structures and functions useful timing.
|
||||
*/
|
||||
#ifndef _VNTIME_H_
|
||||
#define _VNTIME_H_
|
||||
|
||||
#include "vn/int.h"
|
||||
#include "vn/error.h"
|
||||
#include "vn/enum.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Disable some warnings for Visual Studio with -Wall. */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4668)
|
||||
#pragma warning(disable:4820)
|
||||
#pragma warning(disable:4255)
|
||||
#endif
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \brief Provides simple timing capabilities. */
|
||||
typedef struct
|
||||
{
|
||||
#if _WIN32
|
||||
double pcFrequency;
|
||||
__int64 counterStart;
|
||||
#elif __linux__ || __APPLE__ ||__CYGWIN__ || __QNXNTO__
|
||||
double clockStart;
|
||||
#else
|
||||
#error "Unknown System"
|
||||
#endif
|
||||
} VnStopwatch;
|
||||
|
||||
/** \brief Initializes and starts a stopwatch.
|
||||
*
|
||||
* \param[in] stopwatch The VnStopwatch to initialize and start.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnStopwatch_initializeAndStart(VnStopwatch *stopwatch);
|
||||
|
||||
/** \brief Resets the stopwatch's timing.
|
||||
*
|
||||
* \param[in] stopwatch The associated VnStopwatch.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnStopwatch_reset(VnStopwatch *stopwatch);
|
||||
|
||||
/** \brief Determines the number of milliseconds elapsed since the last reset
|
||||
* of the stopwatch.
|
||||
*
|
||||
* \param[in] stopwatch The associated VnStopwatch.
|
||||
* \param[out] elapsedMs The elapsed time in milliseconds.
|
||||
* \return Any errors encountered. */
|
||||
VnError VnStopwatch_elapsedMs(VnStopwatch *stopwatch, float *elapsedMs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user