Go to the documentation of this file.
21 using namespace std::literals;
23 #if MRPT_HAS_xSENS_MT3
39 #define cmt3 (*static_cast<xsens::Cmt3*>(m_cmt3_ptr))
40 #define deviceId (*static_cast<CmtDeviceId*>(m_deviceId_ptr))
43 #if MRPT_HAS_xSENS_MT3
47 #pragma comment(lib, "SetupAPI.lib")
50 #endif // MRPT_HAS_xSENS_MT3
55 CIMUXSens::CIMUXSens()
62 m_deviceId_ptr(nullptr),
66 #if MRPT_HAS_xSENS_MT3
72 "MRPT has been compiled with 'BUILD_XSENS_MT3'=OFF, so this class "
82 #if MRPT_HAS_xSENS_MT3
97 #if MRPT_HAS_xSENS_MT3
101 std::this_thread::sleep_for(200ms);
108 unsigned int cont = 0;
116 res =
cmt3.waitForDataMessage(&packet);
125 mrpt::make_aligned_shared<CObservationIMU>();
133 obs->dataIsPresent[
IMU_YAW] =
true;
137 obs->dataIsPresent[
IMU_ROLL] =
true;
193 if (
cmt3.isPortOpen())
cmt3.closePort();
195 std::cerr <<
"[CIMUXSens::doProcess()] Error: No data "
196 "available [XRV_TIMEOUT]"
214 "MRPT has been compiled with 'BUILD_XSENS_MT3'=OFF, so this class "
224 #if MRPT_HAS_xSENS_MT3
226 if (
cmt3.getBaudrate(baudrate) ==
XRV_OK)
return true;
230 unsigned long portCount = 0;
231 unsigned short mtCount = 0;
235 std::cout <<
"Scanning for connected Xsens devices..." << std::endl;
237 portCount = portInfo.
length();
238 std::cout <<
"Done" << std::endl;
241 std::cout <<
"No xSens device found" << std::endl;
259 std::cout <<
"Using COM port "
260 << portInfo[0].m_portName <<
" at "
261 << portInfo[0].m_baudrate <<
" baud" << std::endl;
262 std::cout <<
"Opening port..." << std::endl;
265 res =
cmt3.openPort(portInfo[0].m_portName, portInfo[0].m_baudrate);
268 std::cerr <<
"COM Port could not be opened" << std::endl;
272 std::cout <<
"done" << std::endl;
276 <<
"Retrieving MotionTracker count (excluding attached Xbus Master(s))"
278 mtCount =
cmt3.getMtCount();
279 std::cout <<
"MotionTracker count: " << mtCount << std::endl;
284 std::cout <<
"Retrieving MotionTracker device ID" << std::endl;
286 std::cout <<
"Device ID at busId 1: " << (long)
deviceId
291 std::cerr <<
"Device ID could not be gathered" << std::endl;
307 #if MRPT_HAS_xSENS_MT3
311 if (
cmt3.isPortOpen())
return;
319 std::cerr <<
"Error Could not initialize the device" << std::endl;
323 std::cout <<
"xSens IMU detected and connected" << std::endl;
334 std::cerr <<
"An error ocurred when setting the device to config mode"
339 unsigned short sampleFreq;
340 sampleFreq =
cmt3.getSampleFrequency();
343 std::cout <<
"Configuring mode selection" << std::endl;
349 std::cerr <<
"An error ocurred when configuring the device"
360 <<
"An error ocurred when setting the device to measurement mode"
365 std::cout <<
"Getting initial TimeStamp" << std::endl;
370 res =
cmt3.waitForDataMessage(&packet);
378 std::cout <<
"Gathering data" << std::endl;
383 "MRPT has been compiled with 'BUILD_XSENS_MT3'=OFF, so this class "
396 configSource.
read_float(iniSection,
"pose_x", 0,
false),
397 configSource.
read_float(iniSection,
"pose_y", 0,
false),
398 configSource.
read_float(iniSection,
"pose_z", 0,
false),
mrpt::poses::CPose3D m_sensorPose
void doProcess()
This method will be invoked at a minimum rate of "process_rate" (Hz)
Structure for storing information about a serial port.
double m_pitch
The pitch (rotation around y-axis / right-left-line)
virtual ~CIMUXSens()
Destructor.
A class for interfacing XSens 3rd generation Inertial Measuring Units (IMUs), the "XSens MTi" model.
bool containsCalGyr(const uint16_t index=0) const
Check if data item contains Calibrated Gyroscope data.
void append(const T &item)
Adds an item to the end of the list.
@ XRV_OK
Operation was performed successfully.
@ IMU_PITCH
orientation pitch absolute value (global/navigation frame) (rad)
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...
@ IMU_ROLL_VEL
roll angular velocity (local/vehicle frame) (rad/sec)
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
@ IMU_ROLL
orientation roll absolute value (global/navigation frame) (rad)
Contains classes for various device interfaces.
CmtVector getCalGyr(const uint16_t index=0) const
Return the Calibrated Gyroscope component of a data item.
#define THROW_EXCEPTION(msg)
#define ASSERT_(f)
Defines an assertion mechanism.
This namespace contains representation of robot actions and observations.
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
mrpt::system::TTimeStamp m_timeStartTT
char m_portName[270]
The port name.
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
#define CMT_OUTPUTMODE_CALIB
A structure for storing device modes.
#define CMT_OUTPUTSETTINGS_ORIENTMODE_EULER
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection)
See the class documentation at the top for expected parameters.
@ IMU_PITCH_VEL
pitch angular velocity (local/vehicle frame) (rad/sec)
This class allows loading and storing values and vectors of different types from a configuration text...
@ IMU_Z_ACC
z-axis acceleration (local/vehicle frame) (m/sec2)
CmtEuler getOriEuler(const uint16_t index=0) const
Return the Orientation component of a data item as Euler angles.
double m_roll
The roll (rotation around x-axis / back-front-line)
std::shared_ptr< CObservationIMU > Ptr
CmtVector getCalAcc(const uint16_t index=0) const
Return the Calibrated Accelerometer component of a data item.
#define CMT_OUTPUTMODE_ORIENT
High-level communication class.
unsigned __int64 uint64_t
void appendObservation(const mrpt::serialization::CSerializable::Ptr &obj)
Like appendObservations() but for just one observation.
@ IMU_X_ACC
x-axis acceleration (local/vehicle frame) (m/sec2)
std::string m_sensorLabel
See CGenericSensor.
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
#define CMT_OUTPUTSETTINGS_TIMESTAMP_SAMPLECNT
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
uint32_t CmtOutputMode
An output mode bit-field.
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
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.
void initialize()
Turns on the xSens device and configure it for getting orientation data.
A structure containing MT data + timestamp and formatting information.
bool searchPortAndConnect()
Search the port where the sensor is located and connect to it.
bool cmtScanPorts(List< CmtPortInfo > &ports, uint32_t baudrate, uint32_t singleScanTimeout, uint32_t scanTries)
Scan COM ports for connected Xsens devices.
@ IMU_Y_ACC
y-axis acceleration (local/vehicle frame) (m/sec2)
uint32_t m_baudrate
The baudrate at which an Xsens device was detected.
uint32_t CmtDeviceId
The type of a Device Id.
#define CMT_OUTPUTSETTINGS_CALIBMODE_ACCGYR
@ IMU_YAW
orientation yaw absolute value (global/navigation frame) (rad)
uint64_t CmtOutputSettings
An output settings bit-field.
double m_yaw
The yaw (rotation around z-axis / down-up-line)
GLsizei const GLchar ** string
XsensResultValue
Xsens return values.
int m_COMbauds
This serial port will be attempted to be opened automatically when this class is first used to reques...
@ IMU_YAW_VEL
yaw angular velocity (local/vehicle frame) (rad/sec)
unsigned int m_toutCounter
Timeout counter (for internal use only)
uint32_t length(void) const
Returns the number of items currently in the list.
unsigned __int32 uint32_t
bool containsOriEuler(const uint16_t index=0) const
Check if data item contains Euler Orientation data.
double DEG2RAD(const double x)
Degrees to radians.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |