-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fix FT sensors name after some tests #240
Fix FT sensors name after some tests #240
Conversation
Thanks a lot for catching this error! Unfortunatly, I am afraid the current proposed fix may be problematic. TL;DRThe sensor name should be the same between simulated and real robots, and on the real robots the name of the sensor are Long explanation:Why the name of the sensor must be the same between simulated and real robots? The main reason is that the sensor name is used in downstream code to select the sensor you want to read, for example: // Snippet of code to read just the two sensor on the left foot of iCub
// Note: this would be drastically simplified if using the `multipleanalogsensorsclientremapper` device proposed in https://github.com/robotology/yarp/pull/2881 was
// Create client
std::string robotPortPrefix = "icub"; // or icubSim for simulated robots, this is tipically passed via an option
std::string localPortPrefix = "localCode"
yarp::os::Property client_options;
client_options.put("device","multipleanalogsensorsclient");
client_options.put("remote","/" + robotPortPrefix + "/left_leg/FT");
client_options.put("local", "/" + localCode + "/" + robotPortPrefix + "/left_leg/FT");
yarp::os::PolyDriver clientDevice;
bool ok = clientDevice.open(client_options);
// Handle if ok is not true <..>
// Create remapper
yarp::os::Property remapper_options;
remapper_options.put("device","multipleanalogsensorsremapper");
yarp::os::Bottle sixAxisForceTorqueSensorsNames;
yarp::os::Bottle& sixAxisForceTorqueSensorsList = sixAxisForceTorqueSensorsNames.addList();
sixAxisForceTorqueSensorsList.addString("l_foot_rear_ft_sensor");
sixAxisForceTorqueSensorsList.addString("l_foot_front_ft_sensor");
remapper_options.put("SixAxisForceTorqueSensorsNames",sixAxisForceTorqueSensorsNames.get(0));
yarp::os::PolyDriver remapperDevice;
ok = remapperDevice.open(remapper_options);
// Handle if ok is not true <..>
// Attach remapper to the client
yarp::dev::IMultipleWrapper* imultiwrap=nullptr;
ok = remapperDevice.view(imultiwrap);
// Handle if ok is not true <..>
yarp::dev::PolyDriverList driverList;
driverList.push(&clientDevice, "left_legs_fts");
ok = imultiwrap->attachAll(driverList);
// Handle if ok is not true <..>
// At this point, you can read FT sensors
yarp::dev::ISixAxisForceTorqueSensors* isixaxis=nullptr;
ok = remapperDevice.view(isixaxis);
// Handle if ok is not true <..>
yarp::sig::Vector measure(6).
for(int ftIdx=0; ftIdx < isixaxis->getNrOfSixAxisForceTorqueSensors(); ftIdx++)
{
std::string sensorName;
isixaxis->getSixAxisForceTorqueSensorName(ftIdx, sensorName);
isixaxis->getSixAxisForceTorqueSensorMeasure(ftIdx, measure);
std::string << "The measure of FT sensor " << sensorName << " is " << measure.toString() << std::endl;
} In this snippet of code, what identifies the sensors you want to read are the identifiers specified in:
if this identifiers are different between real robot and simulated robot, it is impossible (or quite complex) to write code that works with minimal modifications in both the real robot and the simulated robot. |
This may be also interesting for @mfussi66 that is working on documenting how to access iCub's sensors. |
To be more clear, what I think we should fix is to align the sensor name between real and simulated robot for example in https://github.com/robotology/icub-models/blob/b209ab84411c6a64e297a3bc98146a2f576d7984/iCub/robots/iCubGazeboV3/model.urdf#L1670 . At the moment, I think we are not specifying the sensorName in the simmechanics-to-urdf configuration, and so the sensor name is defaulting to be the joint one, see https://github.com/robotology/simmechanics-to-urdf#forcetorque-sensors-parameters-keys-of-elements-of-forcetorquesensors for the documenation on this. Another option is to align the real robot sensor name to the model sensor name. The important thing is that there is a match between the two names. |
I agree w/ @traversaro analysis, part of the work of the refactoring was for aligning simulated and real robots configurations, unfortunately for the models we are forced to put as For this reason also on the real robot we specified the frame name w/o the suffix: From my understanding for the urdf models (both of iCub and ergoCub) we have to use the name w/o the suffix For this reason, probably we should:
This could be annoying for the users because probably would have to change their code, I don't know if you have a better solution. |
For a long time I have not be a big fan of using a different sensor name and frame name, but if this is what we are doing on the real robot, can't we do exactly the same on the simulated robot? (I found the answer myself: we can do that, but we need to modify gazebo-yarp-plugins: https://github.com/robotology/gazebo-yarp-plugins/blob/725ebe4687fced370766b0024b7929fdceebf2b6/plugins/forcetorque/src/ForceTorqueDriver.cpp#L68 ).
I think we already discussed this but I can't recall, why we can't have both a sensor and a joint called |
Apparently the sensor names were changed in #228, but I do not find any related discussion, probably I did not looked carefully to the changes. |
I recall that I had issues in the past when I tried to visualized the ft on rviz, I don't recall if it was just a problem for computing the tf or the model was not loaded in gazebo for this clash, but this test can be done quickly. This problem was the reason why I had to fix the frame exportation in the URDF in simmechanics_to_urdf: |
If it does not take a long time, I would try to understand why we can't just change sensorName to l_arm_ft_sensor, as that would be by far the easiest solution if it works. |
Looking into internal discussion, I think I remember now. The problem is not in the URDF spec by itself, but rather by the Gazebo/SDF extension to URDF. Specifically, at the moment it is perfectly fine in URDF itself to have: <link name="link1" />
<joint name="ft_sensor" type="fixed">
<parent link="link1"/>
<child link="link2"/>
</joint>
<link name="ft_sensor" /> However, when you write a Gazebo extension you extend the content of a link or joint with Gazebo-specific information with a tag called
the attribute |
If that is the best solution, let's go for that, even if I prefer to avoid the change of sensor name of FT from l_arm_ft_sensor to l_arm_ft as we used Just to recap the different options, we have:
|
Anyhow, I agree that this PR just discovered a problem that was already there, so I do not think that there is anything blocking it from being merged. @martinaxgloria can you just update the changelog to describe this change? Thanks! |
For this I opened robotology/gazebo-yarp-plugins#654 . |
As discussed in chat, this repo does not have a CHANGELOG. Merging. |
Today I tried to import both
iCubV2.5
andiCubV3
models in gazebo for the first time after updatingicub-models
tov2.1.0
release (hence after #239) and I obtained the same errors for both, resulting in gazebo crashing:Inspecting the changes introduced after the refactoring of FT sensors, I found out that
sensorName
does not contain the suffix_sensor
for both the left and right legs and the FT does not stream temperature data.After the changes introduced with this PR, I managed to make the yarprobotinterface run.
cc @Nicogene @traversaro @pattacini