Skyward boardcore
|
Driver class for VN100 IMU. More...
#include <VN100Serial.h>
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. | |
![]() | |
Sensor () | |
Sensor (Sensor &&other) | |
virtual | ~Sensor () |
void | sample () override |
Sample the sensor. | |
virtual VN100SerialData | getLastSample () |
![]() | |
virtual | ~AbstractSensor () |
SensorErrors | getLastError () |
Get last error for debugging purposes. Avoid silent fails. | |
![]() | |
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. | |
![]() | |
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 | |
![]() | |
using | DataType |
![]() | |
enum class | CRCOptions : uint8_t { CRC_NO = 0x00 , CRC_ENABLE_8 = 0x08 , CRC_ENABLE_16 = 0x10 } |
![]() | |
DataType | lastSample |
miosix::FastMutex | mutex |
![]() | |
SensorErrors | lastError = SensorErrors::NO_ERRORS |
![]() | |
USART & | usart |
Serial interface that is needed to communicate with the sensor via ASCII codes. | |
int | baudRate |
CRCOptions | crc |
PrintLogger | logger |
std::array< char, recvStringMaxDimension > | recvString |
Buffer used to store the string received from the sensor. | |
uint8_t | recvStringLength = 0 |
Actual strlen() of the recvString. | |
bool | isInit = false |
![]() | |
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. | |
Driver class for VN100 IMU.
Definition at line 51 of file VN100Serial.h.
Boardcore::VN100Serial::VN100Serial | ( | USART & | usart, |
int | baudrate, | ||
CRCOptions | crc, | ||
std::chrono::milliseconds | timeout ) |
Constructor.
usart | Serial bus used for the sensor. |
BaudRate | different from the sensor's default [9600, 19200, 38400, 57600, 115200, 128000, 230400, 460800, 921600]. |
crc | Checksum option. |
timeout | The maximum time that will be waited when reading from the sensor. |
Definition at line 30 of file VN100Serial.cpp.
|
overridevirtual |
Initialize the sensor.
Implements Boardcore::AbstractSensor.
Definition at line 36 of file VN100Serial.cpp.
|
overrideprotectedvirtual |
Sample action implementation.
Implements Boardcore::Sensor< VN100SerialData >.
Definition at line 124 of file VN100Serial.cpp.
|
overridevirtual |
Check if the sensor is working.
Implements Boardcore::AbstractSensor.
Definition at line 122 of file VN100Serial.cpp.