Skip to content

Commit ce506c2

Browse files
committed
Added status port
At the moment we publish only the current timestamp
1 parent 3cdfdcd commit ce506c2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

devices/YarpRobotLoggerDevice/include/BipedalLocomotion/YarpRobotLoggerDevice.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ class YarpRobotLoggerDevice : public yarp::dev::DeviceDriver,
213213
Procedure Call port. */
214214
yarp::os::Port m_rpcPort; /**< Remote Procedure Call port. */
215215

216+
std::string m_statusPortName{"/status:o"};
217+
yarp::os::BufferedPort<yarp::os::Bottle> m_statusPort; /**< Port used to send the status of the
218+
device. */
219+
216220
void lookForNewLogs();
217221
void lookForExogenousSignals();
218222

devices/YarpRobotLoggerDevice/src/YarpRobotLoggerDevice.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,13 @@ bool YarpRobotLoggerDevice::open(yarp::os::Searchable& config)
355355
return false;
356356
}
357357

358+
std::string statusPortFullName = portPrefix + m_statusPortName;
359+
if (!m_statusPort.open(statusPortFullName))
360+
{
361+
log()->error("{} Unable to open the status port named: {}.", logPrefix, statusPortFullName);
362+
return false;
363+
}
364+
358365
log()->info("{} Logger configuration completed.", logPrefix);
359366
if (needsAttach)
360367
{
@@ -2342,6 +2349,12 @@ void YarpRobotLoggerDevice::run()
23422349
m_vectorCollectionRTDataServer.sendData();
23432350
}
23442351

2352+
// We send the current timestamp in the status port
2353+
yarp::os::Bottle& status = m_statusPort.prepare();
2354+
status.clear();
2355+
status.addFloat64(time);
2356+
m_statusPort.write();
2357+
23452358
m_previousTimestamp = t;
23462359
m_firstRun = false;
23472360

@@ -2565,6 +2578,8 @@ bool YarpRobotLoggerDevice::detachAll()
25652578
bool YarpRobotLoggerDevice::close()
25662579
{
25672580
m_rpcPort.close();
2581+
m_statusPort.close();
2582+
25682583
// stop all the video thread
25692584
for (auto & [ cameraName, writer ] : m_videoWriters)
25702585
{

0 commit comments

Comments
 (0)