23 #if MRPT_HAS_xSENS_MT3
40 #define cmt3 (*static_cast<xsens::Cmt3*>(m_cmt3_ptr))
41 #define deviceId (*static_cast<CmtDeviceId*>(m_deviceId_ptr))
45 #if MRPT_HAS_xSENS_MT3
46 #ifdef MRPT_OS_WINDOWS
48 #if defined(_MSC_VER) || defined(__BORLANDC__)
49 #pragma comment (lib,"SetupAPI.lib")
57 CIMUXSens::CIMUXSens( ) :
64 m_deviceId_ptr (NULL),
68 #if MRPT_HAS_xSENS_MT3
73 THROW_EXCEPTION(
"MRPT has been compiled with 'BUILD_XSENS_MT3'=OFF, so this class cannot be used.");
83 #if MRPT_HAS_xSENS_MT3
96 #if MRPT_HAS_xSENS_MT3
108 unsigned int cont = 0;
116 res =
cmt3.waitForDataMessage(&packet);
124 CObservationIMUPtr obs = CObservationIMU::Create();
132 obs->dataIsPresent[
IMU_YAW] =
true;
136 obs->dataIsPresent[
IMU_ROLL] =
true;
175 double AtDO = AtUI * 10000.0;
191 if(
cmt3.isPortOpen() )
194 std::cerr <<
"[CIMUXSens::doProcess()] Error: No data available [XRV_TIMEOUT]" << std::endl;
209 THROW_EXCEPTION(
"MRPT has been compiled with 'BUILD_XSENS_MT3'=OFF, so this class cannot be used.");
218 #if MRPT_HAS_xSENS_MT3
225 unsigned long portCount = 0;
226 unsigned short mtCount = 0;
229 std::cout <<
"Scanning for connected Xsens devices..." << std::endl;
231 portCount = portInfo.
length();
232 std::cout <<
"Done" << std::endl;
233 if (portCount == 0) {
234 std::cout <<
"No xSens device found" << std::endl;
250 std::cout <<
"Using COM port " << portInfo[0].m_portName <<
" at " << portInfo[0].m_baudrate <<
" baud" << std::endl;
251 std::cout <<
"Opening port..." << std::endl;
253 res =
cmt3.openPort(portInfo[0].m_portName , portInfo[0].m_baudrate);
255 std::cerr <<
"COM Port could not be opened" << std::endl;
259 std::cout <<
"done" << std::endl;
262 std::cout <<
"Retrieving MotionTracker count (excluding attached Xbus Master(s))" << std::endl;
263 mtCount =
cmt3.getMtCount();
264 std::cout <<
"MotionTracker count: " << mtCount << std::endl;
269 std::cout <<
"Retrieving MotionTracker device ID" << std::endl;
271 std::cout <<
"Device ID at busId 1: " << (long)
deviceId << std::endl;
273 std::cerr <<
"Device ID could not be gathered" << std::endl;
289 #if MRPT_HAS_xSENS_MT3
293 if(
cmt3.isPortOpen())
302 std::cerr <<
"Error Could not initialize the device" << std::endl;
306 std::cout <<
"xSens IMU detected and connected" << std::endl;
314 std::cerr <<
"An error ocurred when setting the device to config mode" << std::endl;
318 unsigned short sampleFreq;
319 sampleFreq =
cmt3.getSampleFrequency();
322 std::cout <<
"Configuring mode selection" << std::endl;
327 std::cerr <<
"An error ocurred when configuring the device" << std::endl;
335 std::cerr <<
"An error ocurred when setting the device to measurement mode" << std::endl;
339 std::cout <<
"Getting initial TimeStamp" << std::endl;
344 res =
cmt3.waitForDataMessage(&packet);
352 std::cout <<
"Gathering data" << std::endl;
356 THROW_EXCEPTION(
"MRPT has been compiled with 'BUILD_XSENS_MT3'=OFF, so this class cannot be used.");
368 configSource.
read_float( iniSection,
"pose_x", 0,
false ),
369 configSource.
read_float( iniSection,
"pose_y", 0,
false ),
370 configSource.
read_float( iniSection,
"pose_z", 0,
false ),
377 #ifdef MRPT_OS_WINDOWS
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
void appendObservation(const mrpt::utils::CSerializablePtr &obj)
Like appendObservations() but for just one observation.
std::string m_sensorLabel
See CGenericSensor.
A class for interfacing XSens 3rd generation Inertial Measuring Units (IMUs), the "XSens MTi" model.
void doProcess()
This method will be invoked at a minimum rate of "process_rate" (Hz)
mrpt::system::TTimeStamp m_timeStartTT
mrpt::poses::CPose3D m_sensorPose
bool searchPortAndConnect()
Search the port where the sensor is located and connect to it.
int m_COMbauds
This serial port will be attempted to be opened automatically when this class is first used to reques...
virtual ~CIMUXSens()
Destructor.
void initialize()
Turns on the xSens device and configure it for getting orientation data.
void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection)
See the class documentation at the top for expected parameters.
unsigned int m_toutCounter
Timeout counter (for internal use only)
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
This class allows loading and storing values and vectors of different types from a configuration text...
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
High-level communication class.
void append(const T &item)
Adds an item to the end of the list.
uint32_t length(void) const
Returns the number of items currently in the list.
A structure containing MT data + timestamp and formatting information.
bool containsOriEuler(const uint16_t index=0) const
Check if data item contains Euler Orientation data.
bool containsCalGyr(const uint16_t index=0) const
Check if data item contains Calibrated Gyroscope data.
bool containsCalAcc(const uint16_t index=0) const
Check if data item contains Calibrated Accelerometer data.
CmtTimeStamp getRtc(const uint16_t index=0) const
Return the RTC of the packet.
CmtVector getCalGyr(const uint16_t index=0) const
Return the Calibrated Gyroscope component of a data item.
CmtVector getCalAcc(const uint16_t index=0) const
Return the Calibrated Accelerometer component of a data item.
CmtEuler getOriEuler(const uint16_t index=0) const
Return the Orientation component of a data item as Euler angles.
uint32_t CmtDeviceId
The type of a Device Id.
#define CMT_OUTPUTSETTINGS_CALIBMODE_ACCGYR
#define CMT_OUTPUTSETTINGS_ORIENTMODE_EULER
uint64_t CmtOutputSettings
An output settings bit-field.
#define CMT_OUTPUTMODE_CALIB
uint32_t CmtOutputMode
An output mode bit-field.
#define CMT_OUTPUTMODE_ORIENT
#define CMT_OUTPUTSETTINGS_TIMESTAMP_SAMPLECNT
GLsizei const GLchar ** string
@ IMU_X_ACC
x-axis acceleration (local/vehicle frame) (m/sec2)
@ IMU_PITCH_VEL
pitch angular velocity (local/vehicle frame) (rad/sec)
@ IMU_PITCH
orientation pitch absolute value (global/navigation frame) (rad)
@ IMU_YAW
orientation yaw absolute value (global/navigation frame) (rad)
@ IMU_Z_ACC
z-axis acceleration (local/vehicle frame) (m/sec2)
@ IMU_ROLL_VEL
roll angular velocity (local/vehicle frame) (rad/sec)
@ IMU_YAW_VEL
yaw angular velocity (local/vehicle frame) (rad/sec)
@ IMU_Y_ACC
y-axis acceleration (local/vehicle frame) (m/sec2)
@ IMU_ROLL
orientation roll absolute value (global/navigation frame) (rad)
char BASE_IMPEXP * strcpy(char *dest, size_t destSize, const char *source) MRPT_NO_THROWS
An OS-independent version of strcpy.
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
#define THROW_EXCEPTION(msg)
Contains classes for various device interfaces.
This namespace contains representation of robot actions and observations.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
bool cmtScanPorts(List< CmtPortInfo > &ports, uint32_t baudrate, uint32_t singleScanTimeout, uint32_t scanTries)
Scan COM ports for connected Xsens devices.
unsigned __int32 uint32_t
unsigned __int64 uint64_t
A structure for storing device modes.
double m_yaw
The yaw (rotation around z-axis / down-up-line)
double m_pitch
The pitch (rotation around y-axis / right-left-line)
double m_roll
The roll (rotation around x-axis / back-front-line)
Structure for storing information about a serial port.
uint32_t m_baudrate
The baudrate at which an Xsens device was detected.
char m_portName[32]
The port name.
XsensResultValue
Xsens return values.
@ XRV_TIMEOUT
A timeout occurred.
@ XRV_OK
Operation was performed successfully.
@ XRV_TIMEOUTNODATA
Operation aborted because of no data read.