-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add latest fault state to motor status data structure #224
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mfussi66, welcome to your first PR in icub-firmware
.
The code is nice and clean. I would however ask you to two further efforts so that your first PR is just perfect.
A. Make the code safer to run by adding a protection vs potential deferencing a NULL pointer by applying the changes in here:
- eOmc_motor_status_t *mstatus = NULL;
- mstatus = eo_entities_GetMotorStatus(eo_entities_GetHandle(), id);
- mstatus->mc_fault_state = descriptor.code;
+ eOmc_motor_status_t *mstatus = eo_entities_GetMotorStatus(eo_entities_GetHandle(), id);
+ if(NULL != mstatus)
+ {
+ mstatus->mc_fault_state = descriptor.code;
+ }
It may seem pedantic but if you look at the code which use eo_entities_GetMotorStatus()
you will see that the resulting pointer is always checked vs NULL. See for instance:
icub-firmware/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOtheMotionController.c
Lines 2482 to 2485 in 9073802
if(NULL != (mstatus = eo_entities_GetMotorStatus(eo_entities_GetHandle(), jId))) | |
{ | |
MController_get_motor_state(jId, mstatus); | |
} |
or:
icub-firmware/emBODY/eBcode/arch-arm/embobj/plus/board/EOappEncodersReader.c
Lines 1928 to 1932 in 9073802
eOmc_motor_status_t *ms = eo_entities_GetMotorStatus(eo_entities_GetHandle(), j); | |
eOmc_joint_status_t *js = eo_entities_GetJointStatus(eo_entities_GetHandle(), j); | |
uint64_t amo_measure = s_eo_theappencreader.amodiag.vals[j]; | |
uint64_t mot_current = (NULL != ms) ? ms->basic.mot_current : 0; |
B. Do some tests on the iCubGenova02
robot.
The reason is that in you PR of icub-main
you now ask to broadcast as regulars a data structure eOmc_motor_status_t
which is 4 bytes bigger than the previous one eOmc_motor_status_basic_t
.
Now, in iCubGenova02
and other similar robot we have a ems
board which manages 12 joints/motors plus skin patches. The free space in the payload of the UDP packet going to yarprobotinterface is almost over. I think that 4*12 = 48 bytes are still OK, but ... better to test the code on a true robot anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mfussi66, I have approved the previous changes on the code as they were OK.
But you also need to do the tests on the robot so I have copied the request in here again
B. Do some tests on the iCubGenova02 robot.
The reason is that in you PR of icub-main you now ask to broadcast as regulars a data structure eOmc_motor_status_t which is 4 bytes bigger than the previous one eOmc_motor_status_basic_t.Now, in iCubGenova02 and other similar robot we have a ems board which manages 12 joints/motors plus skin patches. The free space in the payload of the UDP packet going to yarprobotinterface is almost over. I think that 4*12 = 48 bytes are still OK, but ... better to test the code on a true robot anyway.
However, I also add another change request.
I have noticed, better late than never, that you set the value of eOmc_motor_status_t::mc_fault_state
to be a given value of eOerror_code_t
when you send up a diagnostics message but...
- You don't initialize the value of
eOmc_motor_status_t::mc_fault_state
to be a neutral value which in theEoError.h
file is indicated to beextern const eOerror_code_t eoerror_code_dummy
(equal to0xffffffff
). The default value for it at startup is 0 which unluckily correspond to be a error of categoryeoerror_category_System
and valueeoerror_value_SYS_unspecified
which will print the string "SYS: unspecified code. It may be that EOtheErrorManager is still called with a NULL eOerrmanDescriptor_t* param". So, we need to initialize at startup the value for eacheOmc_motor_status_t::mc_fault_state
to beeoerror_code_dummy
otherwise the GUI will see the above string even when nothing has happened. - You don't reset the value of
eOmc_motor_status_t::mc_fault_state
when the error condition goes away. The reset value iseoerror_code_dummy
.
I will show you where to put code which:
- sets the correct values of
eOmc_motor_status_t::mc_fault_state
at startup, - clear the values of
eOmc_motor_status_t::mc_fault_state
when the error condition is not present anymore.
…ommented out functions
…ts for each joint
Hi @mfussi66, the changes in the code seem OK. I also know that your further tests on your setup and on So, let me attach some results for you: testfault-2021-12-14_12.59.25.mp4Figure. Tests on a dedicated setup which demonstrates how the Figure. Tests on |
This PR aims to complement the work done to address: robotology/community#561 , in which the feature request involved communicating the latest fault to the
yarpmotorgui
.To address it, the error code is stored in the free space of the struct
motor_status_t
, right after the diagnostics function sends the error towards theyarplogger
.The data is retrieved by embObjMotionControl upon periodical request of the
yarpmotorgui
, whenever a fault is detected.The fault states that can be communicated are the following:
which belong to the
motion controller
category.Here below is a little demo of the
yarpmotorgui
displaying a hardware limit fault:144848405-89251081-02d5-4b19-8fec-f6ed8a2310ff.mp4
Related PR:
icub-firmware-shared: robotology/icub-firmware-shared#52
icub-main: icub-main: robotology/icub-main#779