23 #include <boost/bind.hpp> 25 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ // will fail outside of gcc/clang 26 #define HOST_LITTLE_ENDIAN 28 #define HOST_BIG_ENDIAN 123 std::map<std::string, std::string>
toMap()
const;
155 std::map<std::string, unsigned int>
toMap()
const;
164 Accelerometer = (1 << 0),
165 Gyroscope = (1 << 1),
166 Magnetometer = (1 << 2),
167 Barometer = (1 << 3),
185 Quaternion = (1 << 0),
187 AngleUnertainty = (1 << 2),
188 BiasUncertainty = (1 << 3),
199 float angleUncertainty[3];
202 float biasUncertainty[3];
217 std::string generateString(
const Packet &p, uint8_t code);
235 std::string generateString(
bool write,
unsigned int to);
243 Imu(
const std::string &device,
bool verbose);
291 void idle(
bool needReply =
true);
330 void setIMUDataRate(uint16_t decimation,
const std::bitset<4> &sources);
396 Imu(
const Imu &) =
delete;
401 std::size_t
handleByte(
const uint8_t& byte,
bool& found);
426 std::function<void(const Imu::IMUData &)>
428 std::function<void(const Imu::FilterData &)>
void setIMUDataRate(uint16_t decimation, const std::bitset< 4 > &sources)
setIMUDataRate Set imu data rate for different sources.
uint32_t comNumReadOverruns
uint32_t comNumWriteOverruns
uint32_t imuPacketsDropped
void getDeviceInfo(Imu::Info &info)
getDeviceInfo Get hardware information about the device.
command_error Generated when device replies with NACK.
void setHardIronOffset(float offset[3])
setHardIronOffset Set the hard-iron bias vector for the magnetometer.
std::string deviceOptions
Lot number - appears to be unused.
std::string modelNumber
Model name.
void runOnce()
runOnce Poll for input and read packets if available.
void connect()
connect Open a file descriptor to the serial device.
std::string modelName
Firmware version.
io_error(const std::string &desc)
static constexpr uint8_t kSyncLSB
static constexpr uint8_t kSyncMSB
int pollInput(unsigned int to)
int writePacket(const Packet &p, unsigned int to)
void enableFilterStream(bool enabled)
enableFilterStream Enable/disable streaming of estimation filter data.
uint32_t totalIMUMessages
std::vector< uint8_t > buffer_
io_error Generated when a low-level IO command fails.
void enableBiasEstimation(bool enabled)
enableBiasEstimation Enable gyroscope bias estimation
Imu & operator=(const Imu &)=delete
const std::string device_
void calcChecksum()
Calculate the packet checksum. Sets the checksum variable.
DiagnosticFields struct (See 3DM documentation for these fields)
bool isIMUData() const
True if this packet corresponds to an imu data message.
uint16_t biasUncertaintyStatus
uint16_t quaternionStatus
void getDiagnosticInfo(Imu::DiagnosticFields &fields)
getDiagnosticInfo Get diagnostic information from the IMU.
Imu::DiagnosticFields fields
ROSLIB_DECL std::string command(const std::string &cmd)
void sendPacket(const Packet &p, unsigned int to)
std::deque< uint8_t > queue_
std::function< void(const Imu::FilterData &)> filterDataCallback_
Called with IMU data is ready.
FilterData Estimator readings produced by the sensor.
std::string lotNumber
Serial number.
enum imu_3dm_gx4::Imu::@0 state_
Called when filter data is ready.
uint32_t usbNumReadOverruns
uint8_t filterStreamEnabled
struct imu_3dm_gx4::Imu::Info __attribute__
bool termiosBaudRate(unsigned int baud)
virtual ~Imu()
~Imu Destructor
int ackErrorCodeFor(const Packet &command) const
Extract the ACK code from this packet.
uint32_t usbNumWriteOverruns
IMUData IMU readings produced by the sensor.
void disconnect()
disconnect Close the file descriptor, sending the IDLE command first.
void getFilterDataBaseRate(uint16_t &baseRate)
getFilterDataBaseRate Get the filter data base rate (should be 500)
timeout_error Generated when read or write times out, usually indicates device hang up...
std::map< std::string, unsigned int > toMap() const
Convert to map of human readable strings and integers.
void ping()
ping Ping the device.
std::string toString() const
Make a 'human-readable' version of the packet.
uint32_t filterPacketsDropped
uint16_t angleUncertaintyStatus
std::function< void(const Imu::IMUData &)> imuDataCallback_
void receiveResponse(const Packet &command, unsigned int to)
Imu Interface to the Microstrain 3DM-GX4-25 IMU.
bool isFilterData() const
True if this packet corresponds to a filter data message.
std::size_t handleByte(const uint8_t &byte, bool &found)
void setFilterDataCallback(const std::function< void(const Imu::FilterData &)> &)
Set the onboard filter data callback.
static constexpr uint8_t kHeaderLength
void setSoftIronMatrix(float matrix[9])
setSoftIronMatrix Set the soft-iron matrix for the magnetometer.
void setFilterDataRate(uint16_t decimation, const std::bitset< 4 > &sources)
setFilterDataRate Set estimator data rate for different sources.
void resume()
resume Resume the device.
void getIMUDataBaseRate(uint16_t &baseRate)
getIMUDataBaseRate Get the imu data base rate (should be 1000)
void setIMUDataCallback(const std::function< void(const Imu::IMUData &)> &)
Set the IMU data callback.
uint32_t numIMUParseErrors
void enableMeasurements(bool accel, bool magnetometer)
enableMeasurements Set which measurements to enable in the filter
void selectBaudRate(unsigned int baud)
selectBaudRate Select baud rate.
void enableIMUStream(bool enabled)
enableIMUStream Enable/disable streaming of IMU data
void sendCommand(const Packet &p, bool readReply=true)
Imu(const std::string &device, bool verbose)
Imu Constructor.
Info Structure generated by the getDeviceInfo command.
void idle(bool needReply=true)
idle Switch the device to idle mode.
Packet(uint8_t desc=0)
Constructor.
std::string serialNumber
Model number.