Go to the documentation of this file.
62 ROS_INFO(
"Creating XsControl object...");
64 assert(m_control != 0);
78 if (!rosPacket.second.empty())
82 cb->operator()(rosPacket.second, rosPacket.first);
95 if (
ros::param::get(
"~pub_quaternion", should_publish) && should_publish)
99 if (
ros::param::get(
"~pub_acceleration", should_publish) && should_publish)
103 if (
ros::param::get(
"~pub_angular_velocity", should_publish) && should_publish)
119 if (
ros::param::get(
"~pub_sampletime", should_publish) && should_publish)
123 if (
ros::param::get(
"~pub_temperature", should_publish) && should_publish)
127 if (
ros::param::get(
"~pub_pressure", should_publish) && should_publish)
139 if (
ros::param::get(
"~pub_free_acceleration", should_publish) && should_publish)
143 if (
ros::param::get(
"~pub_transform", should_publish) && should_publish)
147 if (
ros::param::get(
"~pub_positionLLA", should_publish) && should_publish)
151 if (
ros::param::get(
"~pub_velocity", should_publish) && should_publish)
163 int baudrateParam = 0;
165 ROS_INFO(
"Found baudrate parameter: %d", baudrateParam);
166 baudrate = XsBaud::numericToRate(baudrateParam);
169 bool checkDeviceID =
false;
170 std::string deviceId;
174 checkDeviceID =
true;
175 ROS_INFO(
"Found device ID parameter: %s.",deviceId.c_str());
182 std::string portName;
184 ROS_INFO(
"Found port name parameter: %s", portName.c_str());
186 ROS_INFO(
"Scanning port %s ...", portName.c_str());
187 if (!XsScanner::scanPort(mtPort, baudrate))
188 return handleError(
"No MTi device found. Verify port and baudrate.");
189 if (checkDeviceID && mtPort.deviceId().toString().c_str() != deviceId)
190 return handleError(
"No MTi device found with matching device ID.");
195 ROS_INFO(
"Scanning for devices...");
198 for (
auto const &portInfo : portInfoArray)
200 if (portInfo.deviceId().isMti() || portInfo.deviceId().isMtig())
204 if (portInfo.deviceId().toString().c_str() == deviceId)
222 ROS_INFO(
"Found a device with ID: %s @ port: %s, baudrate: %d", mtPort.deviceId().toString().toStdString().c_str(), mtPort.portName().toStdString().c_str(), XsBaud::rateToNumeric(mtPort.baudrate()));
224 ROS_INFO(
"Opening port %s ...", mtPort.portName().toStdString().c_str());
239 unsigned int enable_acceleration,
240 unsigned int enable_angular_velocity,
241 unsigned int enable_orientation)
245 ROS_INFO(
"Putting device into configuration mode...");
247 return handleError(
"Could not put device into configuration mode");
249 ROS_INFO(
"Configuring the device...");
256 if (enable_acceleration)
258 if (enable_angular_velocity)
260 if (enable_orientation)
265 throw std::runtime_error(
"No IMU device while configuring. Aborting.");
270 return handleError(
"Could not configure MTi device. Aborting.");
283 std::string filter_profile;
286 ROS_INFO(
"Setting filter profile to '%s'", filter_profile.c_str());
288 ROS_ERROR(
"Could not configure filter profile");
293 return handleError(
"Could not read device configuration");
297 return handleError(
"Could not put device into measurement mode");
303 return handleError(
"Failed to create a log file! (" + logFile +
")");
305 ROS_INFO(
"Created a log file: %s", logFile.c_str());
307 ROS_INFO(
"Recording to %s ...", logFile.c_str());
struct XsOutputConfiguration XsOutputConfiguration
XsDeviceId const & deviceId() const
Return the device ID of the device.
bool openPort(const XsString &portname, XsBaudRate baudrate, uint32_t timeout=0, bool detectRs485=false)
Open a communication channel on serial port with the given portname.
@ XDI_RateOfTurn
Rate of turn data in rad/sec.
ROSCPP_DECL bool get(const std::string &key, bool &b)
void registerCallback(PacketCallback *cb)
void closePort(const XsString &portname)
Close the serial port with the given portname.
XsResultValue createLogFile(const XsString &filename)
Create a log file for logging.
std::pair< ros::Time, XsDataPacket > RosXsDataPacket
std::list< PacketCallback * > m_callbacks
virtual XsString productCode() const
Return the product code of the device.
static XSNOEXPORT XsControl * construct()
void removeCallbackHandler(XsCallbackPlainC *cb, bool chain=true)
Remove a handler from the list.
@ XRV_OK
0: Operation was performed successfully
@ XDI_PacketCounter
Packet counter, increments every packet.
virtual bool stopRecording()
Stop recording incoming data.
@ XDI_Quaternion
Orientation in quaternion format.
RosXsDataPacket next(const std::chrono::milliseconds &timeout)
XdaCallback m_xdaCallback
A list of XsOutputConfiguration values.
struct XsPortInfo XsPortInfo
bool configureOutput(unsigned int sampling_frequency, unsigned int enable_acceleration, unsigned int enable_angular_velocity, unsigned int enable_orientation)
enum XsBaudRate XsBaudRate
Communication speed.
bool setOutputConfiguration(XsOutputConfigurationArray &config)
Set the output configuration for this device.
Contains a descriptor for opening a communication port to an Xsens device.
XSNOEXPORT void destruct()
bool handleError(std::string error)
void spinFor(std::chrono::milliseconds timeout)
virtual bool setOnboardFilterProfile(int profileType)
Sets the filter profile to use for computing orientations on the device.
void registerPublishers(ros::NodeHandle &node)
virtual bool startRecording()
Start recording incoming data.
XsDevice * device(const XsDeviceId &deviceId) const
Returns the XsDevice interface object associated with the supplied deviceId.
A list of XsPortInfo values.
virtual XSNOEXPORT bool readEmtsAndDeviceConfiguration()
virtual bool closeLogFile()
Close the log file.
virtual bool gotoConfig()
Put the device in config mode.
virtual bool gotoMeasurement()
Put this device in measurement mode.
T param(const std::string ¶m_name, const T &default_val)
@ XDI_Acceleration
Acceleration output in m/s2.
ROSCPP_DECL bool has(const std::string &key)
@ XDI_SampleTimeFine
Sample Time Fine.
XBR_Invalid
Not a valid baud rate.
void addCallbackHandler(XsCallbackPlainC *cb, bool chain=true)
Add a handler to the list.