This commit is contained in:
r.koeppe
2024-05-14 02:14:13 +02:00
parent 0052d3984b
commit 2d22ccd2d6
1423 changed files with 354055 additions and 7 deletions

View 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

View 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

View 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