-
Notifications
You must be signed in to change notification settings - Fork 194
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
remote_controlboard: Add timeout check in all data streamed by StateExt:o port #1833
Comments
By the way, I'm not sure yarp/src/libYARP_dev/src/devices/RemoteControlBoard/RemoteControlBoard.cpp Lines 1142 to 1151 in 5aa3f58
However, this previous check seems to defeat that purpose: yarp/src/libYARP_dev/src/devices/RemoteControlBoard/RemoteControlBoard.cpp Lines 1043 to 1046 in 5aa3f58
And it wasn't there at the time |
Is this a regression?
I briefly checked the code, and I was expecting this functionality to be provided by a check on the timeout similar to
getEncoders method. Furthermore, the now timestamp in the stateExtendedInput reader should not be initialized to now as done in
remote_controlboard ports.
|
I just made a test with the following C++ code: int main(int argc, char *argv[])
{
Network yarp;
if (!yarp.checkNetwork())
return -1;
Property p;
p.put("device", "remote_controlboard");
p.put("local", "/localPort");
p.put("remote", "/icubSim/left_arm");
double val = -1000000;
bool ret = false;
IEncoders *enc;
PolyDriver drv;
drv.open(p);
drv.view(enc);
ret = enc->getEncoder(0, &val);
yInfo() << "Ret " << ret << " val " << val;
return 0;
} Running it multiple times, only 2 cases happen:
So you get zeros because the vector is initialized to zero and the controlboard does not change them, since it has no updated values. And this is correct.
|
@barbalberto
Can you check getEncoders with one parameters, that is the method used by @PeterBowman and surprisingly seems to be missing the correct check (see in
|
I tested both and they work correctly, the timeout is not involved in this case. The function |
Ah, got it, the |
Thank you, @traversaro @barbalberto. I'm sorry, this is clearly a mistake from my part as our code actually did not perform a check for the return value of
I'm just wondering. Let's suppose that |
3 I suggest to move the timeout check inside the |
/**
* Read the position of all axes. This object receives encoders periodically
* from a YARP port. You should check the return value of the function to
* make sure that encoders have been received at least once and with the expected
* rate.
* @param encs pointer to the array that will contain the output
* @return true/false on success/failure. Failure means encoders have not been received
* from the server or that they are not being streamed with the expected rate.
*/
virtual bool getEncoders(double *encs) override;
/**
* Read the istantaneous speed of an axis.
* @param j axis number
* @param sp pointer to storage for the output
* @return true if successful, false ... otherwise.
*/
virtual bool getEncoderSpeed(int j, double *sp) override;
/**
* Read the instantaneous speed of all axes.
* @param spds pointer to storage for the output values
* @return guess what? (true/false on success or failure).
*/
virtual bool getEncoderSpeeds(double *spds) override;
/**
* Read the instantaneous acceleration of an axis.
* @param j axis number
* @param acc pointer to the array that will contain the output
*/
virtual bool getEncoderAcceleration(int j, double *acc) override;
/**
* Read the istantaneous acceleration of all axes.
* @param accs pointer to the array that will contain the output
* @return true if all goes well, false if anything bad happens.
*/
virtual bool getEncoderAccelerations(double *accs) override; Are missing the timeout check, adding it in Another question, is there any relationship between this fix and #1822? |
…d` to the `stateExtendedReader`. In this way every read has a timeout check that before was only in few functions like `getEncoders`. It fixes robotology#1833
…d` to the `stateExtendedReader`. In this way every read has a timeout check that before was only in few functions like `getEncoders`. It fixes robotology#1833
…d` to the `stateExtendedReader`. In this way every read has a timeout check that before was only in few functions like `getEncoders`. It fixes robotology#1833
Describe the bug
The
remote_controlboard
client device connects to an external/<prefix>/stateExt:o
port during its initialization, making it able to query robot status as streamed by acontrolboardwrapper2
device. However, it doesn't wait for the first messages to arrive, thus returning zeroes on the first request right after the device is created (e.g. with the usualPolyDriver
idiom). This is both incorrect and potentially dangerous since the corresponding methods (e.g.getEncoders
) will returntrue
and fill the output array with values that do not correspond to the actual robot state.To Reproduce
Launch a custom
controlboardwrapper2
implementation and move any of the robot joints out of the0.0
position. Then, instantiate aremote_controlboard
, pass the port names and ask for the encoder reads right away (i.e. no delays, no other instructions nor remote calls). Sample Python code:encoderValues
is filled if zeroes unless a small delay is applied right before the final call.Screenshots
@triccyx posted a nice screenshot at #1822 that illustrates the problem:
The joint starts at 10º, but
remote_controlboard
reports 0º.Configuration (please complete the following information):
Additional context
I wondered if something similar to the
isLive()
helper check could be of use here:yarp/src/libYARP_dev/src/devices/RemoteControlBoard/RemoteControlBoard.cpp
Lines 189 to 199 in 5aa3f58
The text was updated successfully, but these errors were encountered: