Skip to content

Commit

Permalink
set period in seconds + add small description
Browse files Browse the repository at this point in the history
  • Loading branch information
HosameldinMohamed committed Sep 27, 2022
1 parent 5fa0899 commit 28bdd1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
13 changes: 4 additions & 9 deletions xsensmt/XsensMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,24 @@ bool XsensMT::open(yarp::os::Searchable &config)
yWarning() << "xsensmt - Parameter \"frame_name\" not set. Using the same value as \"sensor_name\" for this parameter.";
}

yDebug() << "xsensmt - test - xsensmt_period, check xsensmt_period: " << config.check("xsensmt_period");
yDebug() << "xsensmt - test - xsensmt_period, xsensmt_period is string: " << config.find("xsensmt_period").isString();
yDebug() << "xsensmt - test - xsensmt_period, xsensmt_period is int: " << config.find("xsensmt_period").isInt32();
yDebug() << "xsensmt - test - xsensmt_period, xsensmt_period is float: " << config.find("xsensmt_period").isFloat64();

if (config.check("xsensmt_period") && ( config.find("xsensmt_period").isInt32() || config.find("xsensmt_period").isFloat64()))
{
m_outputPeriod = config.find("xsensmt_period").asFloat64();
}
else
{
m_outputPeriod = 10; // 10ms
yWarning() << "xsensmt - Parameter \"xsensmt_period\" not set. Using the value " << m_outputPeriod << " ms for this parameter.";
m_outputPeriod = 0.01; // 10ms
yWarning() << "xsensmt - Parameter \"xsensmt_period\" not set. Using the default value " << m_outputPeriod << " seconds for this parameter.";
}
m_outputFrequency = 1/m_outputPeriod * 1000;
m_outputFrequency = 1/m_outputPeriod;

std::string comPortString = config.check("serial", yarp::os::Value("/dev/ttyUSB0"), "File of the serial device.").asString().c_str();
int baudRate = config.check("baud", yarp::os::Value(115200), "Baud rate used by the serial communication.").asInt32();
m_timeoutInSecond = config.check("timeout", yarp::os::Value(0.1), "Timeout of the driver").asFloat64();

m_portInfo = XsPortInfo(comPortString, XsBaud::numericToRate(baudRate));

yInfo("xsensmt: Opening serial port %s with baud rate %d and output period %4.2f ms.", comPortString.c_str(), baudRate, m_outputPeriod);
yInfo("xsensmt: Opening serial port %s with baud rate %d and output period %4.4f seconds.", comPortString.c_str(), baudRate, m_outputPeriod);
if (!m_xsensDevice.openPort(m_portInfo))
{
yError("xsensmt: Could not open serial port.");
Expand Down
1 change: 1 addition & 0 deletions xsensmt/XsensMT.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace dev
* | timeout | double |seconds| 0.1 | No | If the device is not receiving any sensor measure for timeout seconds, it will start reporting an error. | - |
* | sensor_name | string | | sensor_imu_xsensmt | No | Name of the inertial sensor device. | |
* | frame_name | string | | set same as `sensor_name` | No | Sensor frame in which the measurements are expressed. |
* | xsensmt_period | double | seconds | 0.01 | No | Period of querying the Xsens MT* device | The frequency of publishing the information is determined by the device that attaches this one |
**/
class yarp::dev::XsensMT : public yarp::dev::IGenericSensor,
public yarp::dev::IPreciselyTimed,
Expand Down

0 comments on commit 28bdd1b

Please sign in to comment.