@@ -313,6 +313,8 @@ bool RobotInterface::configureRobot(const yarp::os::Searchable& config)
313313 }
314314 }
315315
316+ m_motorTemperatures.resize (m_actuatedDOFs);
317+
316318 // open the device
317319 if (!m_robotDevice.open (options))
318320 {
@@ -363,6 +365,12 @@ bool RobotInterface::configureRobot(const yarp::os::Searchable& config)
363365 return false ;
364366 }
365367
368+ if (!m_robotDevice.view (m_motorInterface) || !m_motorInterface)
369+ {
370+ yError () << " [configureRobot] Cannot obtain IMotor interface" ;
371+ return false ;
372+ }
373+
366374 // resize the buffers
367375 m_positionFeedbackDeg.resize (m_actuatedDOFs, 0.0 );
368376 m_velocityFeedbackDeg.resize (m_actuatedDOFs, 0.0 );
@@ -482,9 +490,31 @@ bool RobotInterface::configureRobot(const yarp::os::Searchable& config)
482490 return false ;
483491 }
484492
493+ m_motorTemperatureThread = std::thread (&RobotInterface::readMotorTemperature, this );
494+
485495 return true ;
486496}
487497
498+ void RobotInterface::readMotorTemperature ()
499+ {
500+ m_motorTemperatureTreadIsRunning = true ;
501+
502+ while (m_motorTemperatureTreadIsRunning)
503+ {
504+ {
505+ std::lock_guard<std::mutex> lock (m_motorTemperatureMutex);
506+
507+ if (!m_motorInterface->getTemperatures (m_motorTemperatures.data ()))
508+ {
509+ yError () << " [RobotInterface::readMotorTemperature] Unable to get the motor temperatures." ;
510+ }
511+ }
512+
513+ // TODO GR you should load the time required for the read and close it
514+ yarp::os::Time::delay (m_motorTemperatureDt);
515+ }
516+ }
517+
488518bool RobotInterface::configureForceTorqueSensor (const std::string& portPrefix,
489519 const std::string& portInputName,
490520 const std::string& wholeBodyDynamicsPortName,
@@ -1096,6 +1126,12 @@ bool RobotInterface::setVelocityReferences(const iDynTree::VectorDynSize& desire
10961126
10971127bool RobotInterface::close ()
10981128{
1129+ m_motorTemperatureTreadIsRunning = false ;
1130+ if (m_motorTemperatureThread.joinable ())
1131+ {
1132+ m_motorTemperatureThread.join ();
1133+ }
1134+
10991135 // close all the ports
11001136 for (auto & wrench : m_leftFootMeasuredWrench)
11011137 wrench.port ->close ();
@@ -1119,11 +1155,18 @@ const iDynTree::VectorDynSize& RobotInterface::getJointPosition() const
11191155{
11201156 return m_positionFeedbackRad;
11211157}
1158+
11221159const iDynTree::VectorDynSize& RobotInterface::getJointVelocity () const
11231160{
11241161 return m_velocityFeedbackRad;
11251162}
11261163
1164+ iDynTree::VectorDynSize RobotInterface::getMotorTemperature () const
1165+ {
1166+ std::lock_guard lock (m_motorTemperatureMutex);
1167+ return m_motorTemperatures;
1168+ }
1169+
11271170const iDynTree::Wrench& RobotInterface::getLeftWrench () const
11281171{
11291172 return m_leftWrench;
0 commit comments