@@ -136,6 +136,7 @@ bool WalkingModule::configure(yarp::os::ResourceFinder &rf)
136136 m_dumpData = rf.check (" dump_data" , yarp::os::Value (false )).asBool ();
137137 m_maxInitialCoMVelocity = rf.check (" max_initial_com_vel" , yarp::os::Value (1.0 )).asFloat64 ();
138138 std::string goalSuffix = rf.check (" goal_port_suffix" , yarp::os::Value (" /goal:i" )).asString ();
139+ std::string walkingStatusSuffix = rf.check (" walking_status_suffix" , yarp::os::Value (" /status:o" )).asString ();
139140 m_skipDCMController = rf.check (" skip_dcm_controller" , yarp::os::Value (false )).asBool ();
140141 m_removeZMPOffset = rf.check (" remove_zmp_offset" , yarp::os::Value (false )).asBool ();
141142 m_maxTimeToWaitForGoal = rf.check (" max_time_to_wait_for_goal" , yarp::os::Value (1.0 )).asFloat64 ();
@@ -228,6 +229,14 @@ bool WalkingModule::configure(yarp::os::ResourceFinder &rf)
228229 return false ;
229230 }
230231
232+ std::string walkingStatusPort = " /" + getName () + walkingStatusSuffix;
233+ if (!m_walkingStatusPort.open (walkingStatusPort))
234+ {
235+ yError () << " [WalkingModule::configure] Could not open" << walkingStatusPort << " port." ;
236+ return false ;
237+ }
238+
239+
231240 // initialize the trajectory planner
232241 m_trajectoryGenerator = std::make_unique<TrajectoryGenerator>();
233242 yarp::os::Bottle &trajectoryPlannerOptions = rf.findGroup (" TRAJECTORY_PLANNER" );
@@ -568,6 +577,8 @@ bool WalkingModule::updateModule()
568577{
569578 std::lock_guard<std::mutex> guard (m_mutex);
570579
580+ int initialStatusStringLength = -1 ;
581+
571582 if (m_robotState == WalkingFSM::Preparing)
572583 {
573584 if (!m_robotControlHelper->getFeedbacksRaw (m_feedbackAttempts, m_feedbackAttemptDelay))
@@ -681,6 +692,14 @@ bool WalkingModule::updateModule()
681692 desiredUnicyclePosition = m_desiredUnyciclePositionPort.read (false );
682693 if (desiredUnicyclePosition != nullptr )
683694 {
695+ m_statusString = " " ;
696+ // take m_time cast to int do the modulus 3 and then append a string to m_statusString of 3 caracters where the first
697+ // modulo 3 is the number of = and the rest is the number of spaces
698+ m_statusString += std::string ((static_cast <int >(m_time) % 3 ), ' =' );
699+ m_statusString += std::string (3 - (static_cast <int >(m_time) % 3 ), ' ' );
700+ m_statusString += " " ;
701+ initialStatusStringLength = m_statusString.size ();
702+
684703 applyGoalScaling (*desiredUnicyclePosition);
685704 if (!setPlannerInput (*desiredUnicyclePosition))
686705 {
@@ -691,7 +710,16 @@ bool WalkingModule::updateModule()
691710 }
692711 else if (!m_firstRun && ((m_time - m_lastSetGoalTime) > m_maxTimeToWaitForGoal))
693712 {
713+ m_statusString = " " ;
714+ // take m_time cast to int do the modulus 3 and then append a string to m_statusString of 3 caracters where the first
715+ // modulo 3 is the number of = and the rest is the number of spaces
716+ m_statusString += std::string ((static_cast <int >(m_time) % 3 ), ' =' );
717+ m_statusString += std::string (3 - (static_cast <int >(m_time) % 3 ), ' ' );
718+ m_statusString += " " ;
719+ initialStatusStringLength = m_statusString.size ();
720+
694721 yWarning () << " [WalkingModule::updateModule] The goal has not been set for more than " << m_maxTimeToWaitForGoal << " seconds." ;
722+ m_statusString += " Walking TimeOut " ;
695723 yarp::sig::Vector dummy (3 , 0.0 );
696724 if (!setPlannerInput (dummy))
697725 {
@@ -1112,6 +1140,15 @@ bool WalkingModule::updateModule()
11121140 m_vectorsCollectionServer.sendData ();
11131141 }
11141142
1143+ auto & statusMsg = m_walkingStatusPort.prepare ();
1144+ if (m_statusString.size () == initialStatusStringLength)
1145+ {
1146+ m_statusString += " All Good" ;
1147+ }
1148+
1149+ statusMsg.clear ();
1150+ statusMsg.addString (m_statusString);
1151+ m_walkingStatusPort.write ();
11151152
11161153 propagateTime ();
11171154
@@ -1535,14 +1572,15 @@ bool WalkingModule::setPlannerInput(const yarp::sig::Vector &plannerInput)
15351572 {
15361573 yWarning () << " [WalkingModule::setPlannerInput] The motor temperature is over the limit." ;
15371574 std::vector<unsigned int > indeces = m_motorTemperatureChecker->getMotorsOverLimit ();
1538- std::string msg = " The following motors temperature are over the limits: " ;
1575+ std::string msg = " The following motors temperature is over the limits: " ;
15391576 for (auto index : indeces)
15401577 {
15411578 msg += m_robotControlHelper->getAxesList ()[index]
15421579 + " : Max temperature: "
1543- + std::to_string (m_motorTemperatureChecker->getMaxTemperature ()[index]) + " celsius ." ;
1580+ + std::to_string (m_motorTemperatureChecker->getMaxTemperature ()[index]) + " C ." ;
15441581 }
15451582 msg += " The trajectory will be set to zero." ;
1583+ m_statusString += msg;
15461584 yWarning () << msg;
15471585
15481586 m_plannerInput.zero ();
0 commit comments