Skip to content

Commit 4319e43

Browse files
authored
Add parsing of warning message for sw limits (#1055)
1 parent a6345ce commit 4319e43

File tree

9 files changed

+89
-19
lines changed

9 files changed

+89
-19
lines changed

conf/iCubFindDependencies.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ checkandset_dependency(IPOPT)
6464
checkandset_dependency(OpenCV)
6565
checkandset_dependency(Qt5)
6666

67-
set(MINIMUM_REQUIRED_icub_firmware_shared_VERSION 1.44.1)
67+
set(MINIMUM_REQUIRED_icub_firmware_shared_VERSION 1.44.2)
6868

6969
if(icub_firmware_shared_FOUND AND ICUB_USE_icub_firmware_shared)
7070
if(icub_firmware_shared_VERSION VERSION_LESS ${MINIMUM_REQUIRED_icub_firmware_shared_VERSION})

src/libraries/icubmod/embObjLib/IethResource.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ bool IethResource::getEncoderTypeName(uint32_t jomoId, eOmc_position_t pos, std:
8181
return true;
8282
}
8383

84+
bool IethResource::getEntityControlModeName(uint32_t jomoId, eOenum08_t control_mode, std::string &controlModeName, eObool_t compact_string)
85+
{
86+
controlModeName.clear();
87+
return true;
88+
}
89+
8490

8591
// - end-of-file (leave a blank line after)----------------------------------------------------------------------------
8692

src/libraries/icubmod/embObjLib/IethResource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ namespace eth {
109109
*/
110110
virtual bool getEncoderTypeName(uint32_t jomoId, eOmc_position_t pos, std::string &encoderTypeName);
111111

112+
virtual bool getEntityControlModeName(uint32_t jomoId, eOenum08_t control_mode, std::string &controlModeName, eObool_t compact_string = eobool_true);
113+
112114
private:
113115
static const char * names[iethresType_numberof+1];
114116
};

src/libraries/icubmod/embObjLib/diagnosticInfoFormatter.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,16 @@ bool EntityNameProvider::getEncoderTypeName(uint32_t jomoId, eOmc_position_t pos
168168
}
169169

170170
return (m_MC_ethRes->getEncoderTypeName(jomoId, pos, encoderTypeName));
171-
}
171+
}
172+
173+
bool EntityNameProvider::getEntityControlModeName(uint32_t jomoId, eOenum08_t control_mode, std::string &controlModeName, eObool_t compact_string)
174+
{
175+
if (m_MC_ethRes == nullptr)
176+
{
177+
controlModeName = "N/A";
178+
return false;
179+
}
180+
181+
return (m_MC_ethRes->getEntityControlModeName(jomoId, control_mode, controlModeName, compact_string));
182+
}
183+
/**************************************************************************************************************************/

src/libraries/icubmod/embObjLib/diagnosticInfoParsers.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
#include "embot_core_binary.h"
1313
#include "serviceParser.h"
1414
#include <yarp/os/Time.h>
15-
#include <algorithm>
1615

16+
#include <algorithm>
17+
#include <sstream>
18+
#include <iomanip>
1719

1820
using namespace Diagnostic::LowLevel;
1921

20-
22+
constexpr uint32_t iCubDegreesPerRevolution = 65536;
23+
constexpr uint32_t degreesPerRevolution = 360;
24+
constexpr float iCubDegreesToDegreesFactor = static_cast<float>(degreesPerRevolution) / static_cast<float>(iCubDegreesPerRevolution);
25+
constexpr float degreesToICubDegreesFactor = static_cast<float>(iCubDegreesPerRevolution) / static_cast<float>(degreesPerRevolution);
2126

2227

2328
/**************************************************************************************************************************/
@@ -849,6 +854,26 @@ void MotionControlParser::parseInfo()
849854
m_dnginfo.baseInfo.finalMessage.append(str);
850855
} break;
851856

857+
case eoerror_value_MC_joint_software_limit:
858+
{
859+
uint16_t joint_num = m_dnginfo.param16;
860+
int8_t ref_controlmode = m_dnginfo.param64 & 0x00ff;
861+
int32_t position_feedback = (m_dnginfo.param64 & 0xffffffff00000000) >> 32;
862+
float position_feedback_converted = static_cast<float>(position_feedback) * iCubDegreesToDegreesFactor;
863+
std::string ref_controlmode_str = {};
864+
m_entityNameProvider.getEntityControlModeName(joint_num, static_cast<eOenum08_t>(ref_controlmode), ref_controlmode_str, false);
865+
866+
m_entityNameProvider.getAxisName(joint_num, m_dnginfo.baseInfo.axisName);
867+
868+
std::stringstream ss;
869+
ss << " " << m_dnginfo.baseMessage
870+
<< " (Joint=" << m_dnginfo.baseInfo.axisName
871+
<< " (NIB=" << joint_num
872+
<< "), Position_feedback=" << std::fixed << std::setprecision(4) << position_feedback_converted
873+
<< ", Ref_controlmode=" << ref_controlmode_str << ")";
874+
m_dnginfo.baseInfo.finalMessage.append(ss.str());
875+
876+
} break;
852877
case EOERROR_VALUE_DUMMY:
853878
{
854879
m_dnginfo.baseInfo.finalMessage.append(": unrecognised eoerror_category_MotionControl error value.");

src/libraries/icubmod/embObjLib/diagnosticLowLevelFormatter_hid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class Diagnostic::LowLevel::EntityNameProvider
7474
public:
7575
bool getAxisName(uint32_t entityId, std::string &axisName);
7676
bool getEncoderTypeName(uint32_t jomoId, eOmc_position_t pos, std::string &encoderTypeName);
77+
bool getEntityControlModeName(uint32_t jomoId, eOenum08_t control_mode, std::string &controlModeName, eObool_t compact_string = eobool_true);
7778
};
7879

7980

src/libraries/icubmod/embObjLib/hostTransceiver.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,18 +1053,20 @@ void HostTransceiver::eoprot_override_sk(void)
10531053
void cpp_protocol_callback_incaseoferror_in_sequencenumberReceived(EOreceiver *r)
10541054
{
10551055
const eOreceiver_seqnum_error_t * err = eo_receiver_GetSequenceNumberError(r);
1056+
char ipv4str[32] = {};
1057+
eo_common_ipv4addr_to_string(err->remipv4addr, ipv4str, sizeof(ipv4str));
1058+
std::string ipv4str_s(ipv4str);
10561059
long long unsigned int exp = err->exp_seqnum;
10571060
long long unsigned int rec = err->rec_seqnum;
10581061
long long unsigned int timeoftxofcurrent = err->timeoftxofcurrent;
1059-
long long unsigned int timeoftxofprevious = err->timeoftxofprevious;
1060-
char *ipaddr = (char*)&err->remipv4addr;
1061-
//printf("\nERROR in sequence number from IP = %d.%d.%d.%d\t Expected: \t%llu,\t received: \t%llu\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3], exp, rec);
1062-
char errmsg[256] = {0};
1063-
snprintf(errmsg, sizeof(errmsg), "hostTransceiver()::parse() detected an ERROR in sequence number from IP = %d.%d.%d.%d. Expected: %llu, Received: %llu, Missing: %llu, Prev Frame TX at %llu us, This Frame TX at %llu us",
1064-
ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3],
1065-
exp, rec, rec-exp,
1066-
timeoftxofprevious, timeoftxofcurrent);
1067-
yError() << errmsg;
1062+
long long unsigned int timeoftxofprevious = err->timeoftxofprevious;
1063+
yError() << "hostTransceiver()::parse() detected an ERROR in sequence number from IP ="
1064+
<< ipv4str_s
1065+
<< "Expected:" << exp
1066+
<< "- Received:" << rec
1067+
<< "- Missing:" << (rec - exp)
1068+
<< "- Prev Frame TX at" << timeoftxofprevious << "us"
1069+
<< "- This Frame TX at" << timeoftxofcurrent << "us";
10681070
}
10691071

10701072

@@ -1082,17 +1084,22 @@ void cpp_protocol_callback_incaseoferror_invalidFrame(EOreceiver *r)
10821084
{
10831085
const eOreceiver_invalidframe_error_t * err = eo_receiver_GetInvalidFrameError(r);
10841086
char errmsg[256] = {0};
1085-
char *ipaddr = (char*)&err->remipv4addr;
1087+
char ipv4str[32] = {};
1088+
eo_common_ipv4addr_to_string(err->remipv4addr, ipv4str, sizeof(ipv4str));
1089+
std::string ipv4str_s(ipv4str);
10861090
tmpStructROPframeHeader_t *header = (tmpStructROPframeHeader_t*)err->ropframe;
10871091
long long unsigned int ageofframe = header->ageofframe;
10881092
long long unsigned int sequencenumber = header->sequencenumber;
10891093
uint16_t ropframesize = 0;
10901094
eo_ropframe_Size_Get(err->ropframe, &ropframesize);
1091-
//snprintf(errmsg, sizeof(errmsg), "hostTransceiver()::parse() detected an ERROR of type INVALID FRAME from IP = TBD");
1092-
snprintf(errmsg, sizeof(errmsg), "hostTransceiver()::parse() detected an ERROR of type INVALID FRAME from IP = %d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
1093-
yError() << errmsg;
1094-
snprintf(errmsg, sizeof(errmsg), "hostTransceiver()::parse() detected: ropframesize = %d, ropsizeof = %d, ropsnumberof = %d, ageoframe = %llu, sequencenumber = %llu", ropframesize, header->ropssizeof, header->ropsnumberof, ageofframe, sequencenumber);
1095-
yDebug() << errmsg;
1095+
1096+
yError() << "hostTransceiver()::parse() detected an ERROR of type INVALID FRAME from IP =" << ipv4str_s;
1097+
yError() << "hostTransceiver()::parse() detected:"
1098+
<< "ropframesize =" << ropframesize
1099+
<< "ropsizeof =" << static_cast<int>(header->ropssizeof)
1100+
<< "ropnumberof =" << static_cast<int>(header->ropsnumberof)
1101+
<< "ageofframe =" << ageofframe
1102+
<< "sequencenumber =" << sequencenumber;
10961103

10971104
}
10981105

src/libraries/icubmod/embObjMotionControl/embObjMotionControl.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,22 @@ bool embObjMotionControl::getEncoderTypeName(uint32_t jomoId, eOmc_position_t po
18311831
}
18321832
}
18331833

1834+
bool embObjMotionControl::getEntityControlModeName(uint32_t entityId, eOenum08_t control_mode, std::string &controlModeName, eObool_t compact_string)
1835+
{
1836+
controlModeName.clear();
1837+
1838+
if ((entityId>= 0) && (entityId< _njoints))
1839+
{
1840+
controlModeName = eomc_controlmode2string(control_mode, compact_string);
1841+
return true;
1842+
}
1843+
else
1844+
{
1845+
controlModeName = eomc_controlmode2string(eomc_ctrlmval_unknownError, compact_string);
1846+
return false;
1847+
}
1848+
}
1849+
18341850
///////////// PID INTERFACE
18351851
bool embObjMotionControl::setPidRaw(const PidControlTypeEnum& pidtype, int j, const Pid &pid)
18361852
{

src/libraries/icubmod/embObjMotionControl/embObjMotionControl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ class yarp::dev::embObjMotionControl: public DeviceDriver,
459459
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata);
460460
virtual bool getEntityName(uint32_t entityId, std::string &entityName);
461461
virtual bool getEncoderTypeName(uint32_t jomoId, eOmc_position_t pos, std::string &encoderTypeName) override;
462+
virtual bool getEntityControlModeName(uint32_t entityId, eOenum08_t control_mode, std::string &controlModeName, eObool_t compact_string) override;
462463

463464
///////// PID INTERFACE /////////
464465
virtual bool setPidRaw(const PidControlTypeEnum& pidtype, int j, const Pid &pid) override;

0 commit comments

Comments
 (0)