Skip to content
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

gazebo_yarp_imu: add multipleanalogsensors interface #443

Merged
merged 2 commits into from
Oct 1, 2019

Conversation

Nicogene
Copy link
Member

@Nicogene Nicogene commented Sep 30, 2019

This PR add the multiple analog interface to the gazebo_yarp_imu plugin.

Please review code.

(TESTED)

@traversaro
Copy link
Member

cc @nunoguedelha @prashanthr05 can you have a look? Thanks!

@traversaro
Copy link
Member

Travis is failing due to #442 (TL;DR: we need to use YARP devel in the Travis script).

@Nicogene
Copy link
Member Author

Nicogene commented Oct 1, 2019

This path has been successfully tested with these patches:

robotology-legacy/icub-gazebo-legacy#71 and https://github.com/robotology/icub-main

iCubGui + inertial

ezgif com-video-to-gif(2)

iCubGui + WBD

ezgif com-video-to-gif(3)

@traversaro
Copy link
Member

Thanks a lot @Nicogene ! Do you think it is possible to keep the plugin compatible with the old configuration data? As we have a few models around that assume the old format and we also keep models in a repo that does not have master and devel branches, and it would be nice to offer a smooth transition path. A possible strategy is to check for a parameter that enables the parsing according to the new format, and instead fallback to the old format, printing a deprecation. As soon as we can start working on gazebo-yarp-plugins 3.4 , we can drop this old compatibility logic, and just use the new logic that you prepared. Furthermore, can you update the changelog?

@traversaro
Copy link
Member

For using the legacy behavior, we can just check if device inertial is present in the config file.

@prashanthr05
Copy link
Contributor

I think the documentation could include how to write a sample configuration file accounting for the new features and the usual table for specifying the required parameters must be updated.

Otherwise, the code lgtm!

@Nicogene
Copy link
Member Author

Nicogene commented Oct 1, 2019

Changes requested addressed, I updated the documentation and I added a fallback open in case you have an old version of the ini file

cc @traversaro @prashanthr05

yarp::sig::Vector m_imuData; //buffer for imu data
yarp::os::Stamp m_lastTimestamp; //buffer for last timestamp data
yarp::os::Semaphore m_dataMutex; //mutex for accessing the data
mutable yarp::os::Semaphore m_dataMutex; //mutex for accessing the data
std::string m_sensorName{"sensor_imu_gazebo"};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gazebo has a Sensor::Name method, I think we can use that one for both the sensor and the frame, at least for now. We can read it in the Load and then pass it to the device via the yarp parameters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I think it makes more sense (for eventual consistency with the real robot) to use the ::Name method, not the ScopedName that will contains also the model name and the world name.

Copy link
Member Author

@Nicogene Nicogene Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the _sensor->Name() check line 145 of IMU.cc, is it the one you are referring to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I was confused by the old code that used ScopedName instead, thanks!

if (!m_imuDriver.open(m_parameters)) {
yError() << "GazeboYarpIMU Plugin Load failed: error in opening yarp driver";
}
return;
Copy link
Contributor

@prashanthr05 prashanthr05 Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I assume we are inducing a wrong behavior with the return, by not attaching itself to the analog server?

Could you also please add tests for the addition of back-compatibility?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually inside this if statement there is the code as it was before, then if you have the old ini file it will open as device the ServerInertial and as subdevice the GazeboYarpIMU. No attach is required in this case as before.

Copy link
Contributor

@prashanthr05 prashanthr05 Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay..! Understood, what I mentioned is not necessary since we are dealing with ServerInertial. Thanks @Nicogene !

@traversaro
Copy link
Member

A few Travis build fails due to robotology/yarp#2086 , but the rest is green. @prashanthr05 if you can approve, then we can merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants