Skip to content

Commit 9f3b9bc

Browse files
author
ergocub
committed
Add publish of the temperature warning
1 parent 2cdc0ad commit 9f3b9bc

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

src/WalkingModule/include/WalkingControllers/WalkingModule/Module.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ namespace WalkingControllers
129129

130130
yarp::os::Port m_rpcPort; /**< Remote Procedure Call port. */
131131
yarp::os::BufferedPort<yarp::sig::Vector> m_desiredUnyciclePositionPort; /**< Desired robot position port. */
132+
yarp::os::BufferedPort<yarp::os::Bottle> m_walkingStatusPort; /**< Desired robot position port. */
133+
std::string m_statusString;
132134

133135
bool m_newTrajectoryRequired; /**< if true a new trajectory will be merged soon. (after m_newTrajectoryMergeCounter - 2 cycles). */
134136
size_t m_newTrajectoryMergeCounter; /**< The new trajectory will be merged after m_newTrajectoryMergeCounter - 2 cycles. */

src/WalkingModule/src/Module.cpp

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)