Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::VN100Serial Class Reference

Driver class for VN100 IMU. More...

#include <VN100Serial.h>

Inheritance diagram for Boardcore::VN100Serial:
Collaboration diagram for Boardcore::VN100Serial:

Public Member Functions

 VN100Serial (USART &usart, int baudrate, CRCOptions crc, std::chrono::milliseconds timeout)
 Constructor.
 
bool init () override
 Initialize the sensor.
 
bool selfTest () override
 Check if the sensor is working.
 
- Public Member Functions inherited from Boardcore::Sensor< VN100SerialData >
 Sensor ()
 
 Sensor (Sensor &&other)
 
virtual ~Sensor ()
 
void sample () override
 Sample the sensor.
 
virtual VN100SerialData getLastSample ()
 
- Public Member Functions inherited from Boardcore::AbstractSensor
virtual ~AbstractSensor ()
 
SensorErrors getLastError ()
 Get last error for debugging purposes. Avoid silent fails.
 
- Public Member Functions inherited from Boardcore::VNCommonSerial
 VNCommonSerial (USART &usart, int baudrate, const char *sensorName, CRCOptions crc, const std::chrono::milliseconds timeout)
 Constructor.
 
 ~VNCommonSerial ()
 
bool closeAndReset ()
 Method to reset the sensor to default values and to close the connection. Used if you need to close and re initialize the sensor.
 
bool startHSIEstimator (uint8_t convergeRate)
 Start the real-time hard/soft iron calibration. The algorithm will continue until stopHSIEstimator() is called.
 
bool stopHSIEstimator ()
 Real-time hard/soft iron calibration algorithm is turned off.
 
std::string getHSIEstimatorValues ()
 
bool setMagnetometerCompensation (const Eigen::Matrix3f &c, const Eigen::Vector3f &b)
 Set custom compensation parameters for the magnetometer.
 
bool setAccelerometerCompensation (const Eigen::Matrix3f &c, const Eigen::Vector3f &b)
 Set custom compensation parameters for the accelerometer.
 
bool setGyroscopeCompensation (const Eigen::Matrix3f &c, const Eigen::Vector3f &b)
 Set custom compensation parameters for the gyroscope.
 
bool saveConfiguration ()
 Write the current register settings into non-volatile memory. Once the settings are stored in non-volatile (Flash) memory, the VN module can be power cycled or reset, and the register will be reloaded from non-volatile memory.
 
bool restoreFactorySettings ()
 Restore the VN module’s factory default settings and reset the module.
 

Protected Member Functions

VN100SerialData sampleImpl () override
 Sample action implementation.
 
- Protected Member Functions inherited from Boardcore::VNCommonSerial
uint8_t calculateChecksum8 (const uint8_t *message, int length)
 Calculate the 8bit checksum on the given array.
 
uint16_t calculateChecksum16 (const uint8_t *message, int length)
 Calculate the 16bit array on the given array.
 
bool verifyChecksum (char *command, int maxLength)
 Method to verify the crc validity of a command.
 
bool disableAsyncMessages (bool waitResponse)
 Disables the async messages that the sensor is default configured to send at 40Hz on startup.
 
bool setCrc (bool waitResponse=true)
 Sets the user selected crc method.
 
void configDefaultSerialPort ()
 Configures the default serial communication.
 
bool configUserSerialPort ()
 Configures the user defined serial communication.
 
bool verifyModelNumber (const char *expectedModelNumber)
 Verify the model number of the sensor.
 
template<typename T >
bool getBinaryOutput (T &binaryData, const char *const sampleCommand)
 Utility function used to retrieve the binary output from the sensor.
 
uint8_t checkErrorVN (const char *message)
 Check if the message received from the sensor contains an error.
 
bool sendStringCommand (std::string command)
 Sends the command to the sensor with the correct checksum added so '*' symbol is not needed at the end of the string as well as the '$' at the beginning of the command. This function takes into account the time needed for the command to reach the sensor. DO NOT USE THIS FUNCTION IF LOW EXECUTION TIME IS NEEDED (for example when sending the sample command).
 
bool recvStringCommand (char *command, int maxLength)
 Receives a command from the sensor but swaps the first
with a \0 to close the message.
 
bool writeRegister (const std::string &command)
 Utility function used to set a register on the sensor. This function relies on sendStringCommand: DO NOT USE THIS FUNCTION IF LOW EXECUTION TIME IS NEEDED.
 

Additional Inherited Members

- Public Types inherited from Boardcore::Sensor< VN100SerialData >
using DataType
 
- Public Types inherited from Boardcore::VNCommonSerial
enum class  CRCOptions : uint8_t { CRC_NO = 0x00 , CRC_ENABLE_8 = 0x08 , CRC_ENABLE_16 = 0x10 }
 
- Protected Attributes inherited from Boardcore::Sensor< VN100SerialData >
DataType lastSample
 
miosix::FastMutex mutex
 
- Protected Attributes inherited from Boardcore::AbstractSensor
SensorErrors lastError = SensorErrors::NO_ERRORS
 
- Protected Attributes inherited from Boardcore::VNCommonSerial
USARTusart
 Serial interface that is needed to communicate with the sensor via ASCII codes.
 
int baudRate
 
CRCOptions crc
 
PrintLogger logger
 
std::array< char, recvStringMaxDimensionrecvString
 Buffer used to store the string received from the sensor.
 
uint8_t recvStringLength = 0
 Actual strlen() of the recvString.
 
bool isInit = false
 
- Static Protected Attributes inherited from Boardcore::VNCommonSerial
static const int DEFAULT_BAUDRATE = 115200
 Default baudrate value for the usart communication.
 
static const uint8_t recvStringMaxDimension = 200
 Maximum size of the receiving string.
 

Detailed Description

Driver class for VN100 IMU.

Definition at line 51 of file VN100Serial.h.

Constructor & Destructor Documentation

◆ VN100Serial()

Boardcore::VN100Serial::VN100Serial ( USART & usart,
int baudrate,
CRCOptions crc,
std::chrono::milliseconds timeout )

Constructor.

Parameters
usartSerial bus used for the sensor.
BaudRatedifferent from the sensor's default [9600, 19200, 38400, 57600, 115200, 128000, 230400, 460800, 921600].
crcChecksum option.
timeoutThe maximum time that will be waited when reading from the sensor.

Definition at line 30 of file VN100Serial.cpp.

Member Function Documentation

◆ init()

bool Boardcore::VN100Serial::init ( )
overridevirtual

Initialize the sensor.

Returns
boolean value indicating whether the operation succeded or not

Implements Boardcore::AbstractSensor.

Definition at line 36 of file VN100Serial.cpp.

◆ sampleImpl()

VN100SerialData Boardcore::VN100Serial::sampleImpl ( )
overrideprotectedvirtual

Sample action implementation.

Implements Boardcore::Sensor< VN100SerialData >.

Definition at line 124 of file VN100Serial.cpp.

◆ selfTest()

bool Boardcore::VN100Serial::selfTest ( )
overridevirtual

Check if the sensor is working.

Returns
boolean indicating whether the sensor is correctly working or not

Implements Boardcore::AbstractSensor.

Definition at line 122 of file VN100Serial.cpp.


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