imu_imar
Public Member Functions | List of all members
imu_imar::iVRU_BB Class Reference

#include <Imar.hpp>

Public Member Functions

 iVRU_BB ()
 
 ~iVRU_BB ()
 
void welcome ()
 Dummy Welcome method. More...
 
bool open_port (const char *name)
 This method opens a serial port. More...
 
bool init_serial (const char *name, const int bauds)
 This method opens and configures a serial port. More...
 
bool write_serial (char *command, int nbytes)
 This method write values in the serial port. More...
 
bool read_serial (unsigned char *bufferpr, int nbytes)
 Function to read values from a serial port connection. More...
 
bool close_port ()
 Function to close an open serial port connection. More...
 
int getDescriptor ()
 Returns file decriptor. More...
 
int cbIsFull ()
 Returns if the circular buffer is full. More...
 
int cbIsEmpty ()
 Returns if the circular buffer is Empty. More...
 
bool cbIsSynchronized ()
 Returns if the driver is Synchronized. More...
 
void cbWritePckg (int nbytes, unsigned char *values)
 It writes information in the Cicular Buffer. More...
 
bool cbSynchronize ()
 It synchronizes the circular buffer. More...
 
bool cbCopyPckg (unsigned char *pckg, int len)
 It reads a information from the circular buffer. More...
 
bool cbReadValues ()
 It reads a IMU packages. More...
 
void cbPrintValues ()
 It prints the values stored in ImuData. More...
 
int cbNumberElements ()
 It gives the number of elements stored in the Circular Buffer. More...
 
int getPacketCounter ()
 It gives the package counter. More...
 
Eigen::Matrix< double, imu_imar::NUMAXIS, 1 > getAccelerometers ()
 It gets the Accelerometers values. More...
 
Eigen::Matrix< double, imu_imar::NUMAXIS, 1 > getGyroscopes ()
 It gets the Gyroscopes values. More...
 
Eigen::Quaternion< double > getAttitude ()
 It gets the attitude or orientation. More...
 
void cbCalculateAccIntegration (const float omega)
 
Eigen::Matrix< double, imu_imar::NUMAXIS, 1 > getVelocity ()
 
Eigen::Matrix< double, imu_imar::NUMAXIS, 1 > getPosition ()
 
unsigned short crc16 (unsigned char *data_p, int length)
 
unsigned int Crc16_0 (unsigned char const *pByte, unsigned Size)
 
void cbReset ()
 

Constructor & Destructor Documentation

◆ iVRU_BB()

imu_imar::iVRU_BB::iVRU_BB ( )

Print a welcome to stdout

Returns
nothing

Init the circular Buffer

◆ ~iVRU_BB()

imu_imar::iVRU_BB::~iVRU_BB ( )

Member Function Documentation

◆ cbCalculateAccIntegration()

void imu_imar::iVRU_BB::cbCalculateAccIntegration ( const float  omega)

Get the Acceleration

Remove the first elements from the buffer

Compute the FFT

Convert Acc to Displacement

Convert Acc to Velocity

Calculate the Inverse FFT

Fill the Vel and Displacement

◆ cbCopyPckg()

bool imu_imar::iVRU_BB::cbCopyPckg ( unsigned char *  pckg,
int  len 
)

It reads a information from the circular buffer.

The method reads raw information from the circular buffer.

Author
Javier Hidalgo Carrio.
Parameters
[out]*pckgpointer to buffer.
[in]lensize of the buffer
Returns
OK if everything is good, ERROR in other cases.

◆ cbIsEmpty()

int imu_imar::iVRU_BB::cbIsEmpty ( )

Returns if the circular buffer is Empty.

Author
Javier Hidalgo Carrio.
Returns
true if buffer is Empty false in other cases.

◆ cbIsFull()

int imu_imar::iVRU_BB::cbIsFull ( )

Returns if the circular buffer is full.

Author
Javier Hidalgo Carrio.
Returns
true if buffer is full false in other cases.

◆ cbIsSynchronized()

bool imu_imar::iVRU_BB::cbIsSynchronized ( )

Returns if the driver is Synchronized.

When the read pointer of the cicular buffer is synchronized with the SyncWord of the stream the driver is synchronized.

Author
Javier Hidalgo Carrio.
Returns
true if it is Synchronized false in other cases.

◆ cbNumberElements()

int imu_imar::iVRU_BB::cbNumberElements ( )

It gives the number of elements stored in the Circular Buffer.

Author
Javier Hidalgo Carrio.
Returns
Return the number of elements.

From read till the end

◆ cbPrintValues()

void imu_imar::iVRU_BB::cbPrintValues ( )

It prints the values stored in ImuData.

Author
Javier Hidalgo Carrio.
Returns
OK if everything is good, ERROR in other cases.

Inertial Values

◆ cbReadValues()

bool imu_imar::iVRU_BB::cbReadValues ( )

It reads a IMU packages.

The method reads the information in the circular buffer and gives the inertial information. It needs to be previously synchronized otherwise the values would be wrong. The values are stored in the ImuData variable.

Author
Javier Hidalgo Carrio.
Returns
OK if everything is good, ERROR in other cases.

Pckg counter

Pckg length

Accelerometers X

Accelerometers Y

Accelerometers Z

Gyroscope X

Gyroscope Y

Gyroscope Z

Roll

Pitch

Yaw

Read the time field

Push the accelerometers readings to the FFT buffer

Check if the buffer is Synchronize

◆ cbReset()

void imu_imar::iVRU_BB::cbReset ( )

◆ cbSynchronize()

bool imu_imar::iVRU_BB::cbSynchronize ( )

It synchronizes the circular buffer.

The method synchronizes the cicular buffer seeking for the Synchronization Word defined by SYNC_WORD

Author
Javier Hidalgo Carrio.
Returns
OK if synchronization makes success. ERROR in other cases.

Jump one package ahead to be fully sync

The app must read new values again

◆ cbWritePckg()

void imu_imar::iVRU_BB::cbWritePckg ( int  nbytes,
unsigned char *  values 
)

It writes information in the Cicular Buffer.

The values previously read in the serial port are writen in the Circular Buffer.

Author
Javier Hidalgo Carrio.
Parameters
[in]nbytesnumber of bytes to read.
[in]valuespointer to char. Buffer to store the values read
Returns
void

◆ close_port()

bool imu_imar::iVRU_BB::close_port ( )

Function to close an open serial port connection.

This function closes the serial port connection.

Author
Javier Hidalgo Carrio.
Returns
OK if everything all right, ERROR on error.

Returns OK if no errors

◆ crc16()

unsigned short imu_imar::iVRU_BB::crc16 ( unsigned char *  data_p,
int  length 
)

◆ Crc16_0()

unsigned int imu_imar::iVRU_BB::Crc16_0 ( unsigned char const *  pByte,
unsigned  Size 
)

◆ getAccelerometers()

Eigen::Matrix< double, imu_imar::NUMAXIS, 1 > imu_imar::iVRU_BB::getAccelerometers ( )

It gets the Accelerometers values.

Author
Javier Hidalgo Carrio.
Returns
The Accelerometers.

◆ getAttitude()

Eigen::Quaternion< double > imu_imar::iVRU_BB::getAttitude ( )

It gets the attitude or orientation.

Author
Javier Hidalgo Carrio.
Returns
The attitude in a Quaternion form.

◆ getDescriptor()

int imu_imar::iVRU_BB::getDescriptor ( )

Returns file decriptor.

Author
Javier Hidalgo Carrio.
Returns
the fd value

◆ getGyroscopes()

Eigen::Matrix< double, imu_imar::NUMAXIS, 1 > imu_imar::iVRU_BB::getGyroscopes ( )

It gets the Gyroscopes values.

Author
Javier Hidalgo Carrio.
Returns
The Gyroscopes

◆ getPacketCounter()

int imu_imar::iVRU_BB::getPacketCounter ( )

It gives the package counter.

Author
Javier Hidalgo Carrio.
Returns
Return the incremental counter

◆ getPosition()

Eigen::Matrix< double, 3, 1 > imu_imar::iVRU_BB::getPosition ( )

◆ getVelocity()

Eigen::Matrix< double, 3, 1 > imu_imar::iVRU_BB::getVelocity ( )

◆ init_serial()

bool imu_imar::iVRU_BB::init_serial ( const char *  name,
const int  bauds 
)

This method opens and configures a serial port.

The method opens a serial port with descriptor file name and the bauds rate specified. The serial port is open set to no parity cheking 8databits, 1 stopbit and no hardware protocol.

Author
Javier Hidalgo Carrio.
Parameters
[in]*namepointer to char (C type string) with the descriptor file name
[out]baudsinteger value with the baud rate
Returns
OK is everything all right. ERROR on other cases.

Get the current options for the port

Set the baud rates to 57600

Input flags: Disable input processing: no parity checking or marking, no signals from break conditions, do not convert line feeds or carriage returns, and do not map upper case to lower case.

no output processing

don't convert line feeds

Select 8 data bits

◆ open_port()

bool imu_imar::iVRU_BB::open_port ( const char *  name)

This method opens a serial port.

The method opens a serial port with descriptor file name specified in the paramaters.

Author
Javier Hidalgo Carrio.
Parameters
[in]*namepointer to char (C type string) with the descriptor file name
Returns
OK is everything all right. ERROR on other cases.

◆ read_serial()

bool imu_imar::iVRU_BB::read_serial ( unsigned char *  bufferpr,
int  nbytes 
)

Function to read values from a serial port connection.

This function read nbytes from the open serial port

Author
Javier Hidalgo Carrio.
Parameters
[out]bufferprpointer to char. Buffer to store the values read
[in]nbytesnumber of bytes to read.
Returns
OK if everything all right, ERROR on error.

◆ welcome()

void imu_imar::iVRU_BB::welcome ( )

Dummy Welcome method.

Dummy Welcome methods.

Author
Javier Hidalgo Carrio.
Returns
void

◆ write_serial()

bool imu_imar::iVRU_BB::write_serial ( char *  command,
int  nbytes 
)

This method write values in the serial port.

Write values in the serial port

Author
Javier Hidalgo Carrio.
Parameters
[in]*commadpointer to array of values
[out]nbytesnumber of byte to write
Returns
OK is everything all right. ERROR on other cases.

The documentation for this class was generated from the following files: