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

Provide a way for plugins to explicitly disable implicitly created network wrappers server #585

Closed
traversaro opened this issue Nov 19, 2021 · 5 comments

Comments

@traversaro
Copy link
Member

traversaro commented Nov 19, 2021

See #569 for a recap on this in situation. In a nutshell, now we have the GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS option that just disable all implicitly created network wrappers server, as we would expect that gazebo-yarp-plugins will work in the future. However users that are migrating to the new nws/nwc system, are actually requiring the GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS option to be ON, as they do not want to launch at all the implicit network wrappers.

However, for various reason having models that use gazebo-yarp-plugins compiled with a non-standard flag enabled is problematic for a various of reason:

  • First of all, it prevents people to use the same gazebo-yarp-plugins to simulate both models that still needs to be migrated to use nws/nwc structure and models that already use the new nws/nwc structure but required GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS to be ON
  • Secondly, it prevents users that get gazebo-yarp-plugins via binaries (for example conda binaries) to simulate the new models

To avoid this situation, I guess the easier way to avoid this problem is to provide users a way to explicity disable at runtime the instantiation of implicity created network wrappers servers, for example a disableImplicitNetworkWrapper option. This option will be ignored if GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS option is ON and when it will be ON by default, but it will help a lot in this transition period to simulate with the same gazebo-yarp-plugins both new and old models.

@Nicogene
Copy link
Member

The thing that confused me a little bit about GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS is that it should actually disable implicit network wrappers, like for example:

#ifndef GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS
netWrapper = "analogServer";
#endif // GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS
// Add my gazebo device driver to the factory.
::yarp::dev::Drivers::factory().add(new ::yarp::dev::DriverCreatorOf< ::yarp::dev::GazeboYarpForceTorqueDriver>
("gazebo_forcetorque", netWrapper.c_str(), "GazeboYarpForceTorqueDriver"));

But it is doing more than that, it disable also the explicit wrapper instantiation from ini files see:

#ifndef GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS
yarp::os::Bottle wrapper_group = m_parameters.findGroup("WRAPPER");
if(wrapper_group.isNull())
{
yCDebug(GAZEBOCONTROLBOARD) <<"[WRAPPER] group not found in config file";
}
if(m_parameters.check("ROS"))
{
std::string ROS;
ROS = std::string ("(") + m_parameters.findGroup("ROS").toString() + std::string (")");
wrapper_group.append(yarp::os::Bottle(ROS));
}
m_wrapper.open(wrapper_group);

#ifndef GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS
///////////////////////////
//Open the wrapper, forcing it to be a "RGBDSensorWrapper"
wrapper_properties.put("device","RGBDSensorWrapper");
if(wrapper_properties.check("subdevice"))
{
yCError(GAZEBODEPTH) << "RGBDSensorWrapper: Do not use 'subdevice' keyword here since the only supported subdevice is <gazebo_depthCamera>. \
Please remove the line 'subdevice " << wrapper_properties.find("subdevice").asString().c_str() << "' from your config file before proceeding";
return;
}
if(!m_cameraWrapper.open(wrapper_properties) )
{
yCError(GAZEBODEPTH)<<"GazeboYarpDepthCamera Plugin failed: error in opening yarp wrapper";
return;
}
#endif

#ifndef GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS
/*
* Open the driver wrapper
*/
//Retrieve wrapper properties
::yarp::os::Bottle MASwrapperProp = m_parameters.findGroup("WRAPPER");
if(MASwrapperProp.isNull())
{
yWarning("GazeboYarpIMU : [WRAPPER] group not found in config file, maybe you are using the old version of the ini file, please update icub-gazebo\n");
yWarning("GazeboYarpIMU : trying to open it with the legacy behaviour device-subdevice");
legacy_behaviour = true;
}
if (legacy_behaviour) {
m_parameters.put(YarpIMUScopedName.c_str(), m_scopedSensorName.c_str());
m_parameters.put("sensor_name",_sensor->Name());
if (!m_imuDriver.open(m_parameters)) {
yError() << "GazeboYarpIMU Plugin Load failed: error in opening yarp driver";
}
return;
}
//Open the driver wrapper
if (!m_MASWrapper.open(MASwrapperProp))
{
yError() << "GazeboYarpIMU Plugin Load failed: error in opening the yarp wrapper";
}
/*
* Open the old wrapper
*/
//Retrieve wrapper properties
::yarp::os::Bottle AdditionalWrapperProp = m_parameters.findGroup("ADDITIONAL_WRAPPER");
if(AdditionalWrapperProp.isNull())
{
yError("GazeboYarpIMU : [ADDITIONAL_WRAPPER] group not found in config file\n");
return;
}
//Open the driver wrapper
if (!m_AdditionalWrapper.open(AdditionalWrapperProp))
{
yError() << "GazeboYarpIMU Plugin Load failed: error in opening the yarp wrapper";
}

#ifndef GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS
//Open the wrapper
//Force the wrapper to be of type "analogServer" (it make sense? probably no)
wrapper_properties.put("device","analogServer");
if( !m_forcetorqueWrapper.open(wrapper_properties) ) {
yError()<<"GazeboYarpForceTorque Plugin failed: error in opening yarp driver wrapper";
return;
}
#endif // GAZEBO_YARP_PLUGINS_DISABLE_IMPLICIT_NETWORK_WRAPPERS

I would re-enable the open of the wrappers, also when the implicit wrapper is disabled

@traversaro
Copy link
Member Author

traversaro commented Nov 22, 2021

I think this is the source of the confusion. What you are calling explicit network wrapper is what we are calling (me and @ste93, see #569) the implicit network wrapper (we are calling it implicit, as it is always create whenever the Gazebo plugin is created). However, we can clarify ourself on teams. If I am not wrong, what you are calling implicit created device are only created if you are using the command line tool yarpdev, so they do not play a role here as they are never created by a Gazebo simulation.

I would re-enable the open of the wrappers, also when the implicit wrapper is disabled

But in this case we would not solve the problem listed in #585, if I am not wrong.

@Nicogene
Copy link
Member

Yes what confuse me is the term "implicit" but for sure we can continue F2F or T2T.

If I am not wrong, what you are calling implicit created device are only created if you are using the command line tool yarpdev, so they do not play a role here as they are never created by a Gazebo simulation.

Yes for me implicit is that, but it is just a matter of agree on the nomeclature, and maybe write it somewhere

@ste93
Copy link
Contributor

ste93 commented Nov 22, 2021

yep, I will be at cris wednesday if you want f2f, otherwise I'm always available on teams

@traversaro
Copy link
Member Author

Fixed by #586 .

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

No branches or pull requests

3 participants