robotology / gazebo-fmi

FMI import plugins for the Gazebo Simulator.
GNU Lesser General Public License v3.0
24 stars 5 forks source link

Multiple instance of FMU #31

Closed triccyx closed 5 years ago

triccyx commented 6 years ago

It seems that the plugin is not able to load multiple FMUs from .sdf file. Only the first is loaded. Consider the following sdf (only the interesting part of the file):

 <plugin name="fmi_actuator_plugin" filename="libFMIActuatorPlugin.so">
            <actuator>
                <name>myactuator1</name> 
                <joint>L_AK_R</joint> 
                <fmu>MotorTransmissionAKR.fmu</fmu>
                <actuatorInputName>actuatorInput</actuatorInputName>
                <jointPositionName>jointPosition</jointPositionName>
                <jointVelocityName>jointVelocity</jointVelocityName>
                <jointAccelerationName>jointAcceleration</jointAccelerationName>
                <jointTorqueName>jointTorque</jointTorqueName>
            </actuator>

            <actuator>
                <name>myactuator2</name> 
                <joint>L_AK_P</joint> 
                <fmu>MotorTransmissionAKP.fmu</fmu>
                <actuatorInputName>actuatorInput</actuatorInputName>
                <jointPositionName>jointPosition</jointPositionName>
                <jointVelocityName>jointVelocity</jointVelocityName>
                <jointAccelerationName>jointAcceleration</jointAccelerationName>
                <jointTorqueName>jointTorque</jointTorqueName>
            </actuator>

Only the first FMU is loaded.

traversaro commented 6 years ago

I guess that is kind of expected, for simulating multiple actuators you can load multiple plugins:

 <plugin name="fmi_actuator_plugin1" filename="libFMIActuatorPlugin.so">
            <actuator>
                <name>myactuator1</name> 
                <joint>L_AK_R</joint> 
                <fmu>MotorTransmissionAKR.fmu</fmu>
                <actuatorInputName>actuatorInput</actuatorInputName>
                <jointPositionName>jointPosition</jointPositionName>
                <jointVelocityName>jointVelocity</jointVelocityName>
                <jointAccelerationName>jointAcceleration</jointAccelerationName>
                <jointTorqueName>jointTorque</jointTorqueName>
            </actuator>
</plugin>
 <plugin name="fmi_actuator_plugin2" filename="libFMIActuatorPlugin.so">
            <actuator>
                <name>myactuator2</name> 
                <joint>L_AK_P</joint> 
                <fmu>MotorTransmissionAKP.fmu</fmu>
                <actuatorInputName>actuatorInput</actuatorInputName>
                <jointPositionName>jointPosition</jointPositionName>
                <jointVelocityName>jointVelocity</jointVelocityName>
                <jointAccelerationName>jointAcceleration</jointAccelerationName>
                <jointTorqueName>jointTorque</jointTorqueName>
            </actuator>
</plugin>

However, silently failing is indeed bad and confusing. We should either add support for multiple actuators in a single plugin, or print an error if more than one actuator element is a child of the plugin tag.

triccyx commented 6 years ago

I would also add a message to confirm the load of the actuator.

traversaro commented 6 years ago

I would also add a message to confirm the load of the actuator.

That make sense as well.

triccyx commented 6 years ago

I can confirm that now, multi instantiate the plugin, make all working

triccyx commented 5 years ago

In order to obtain the result is necessary to change: private: FMUActuatorProperties actuator; to private: std::vector<FMUActuatorProperties> actuators;

And all the related code in

class FMIActuatorPlugin

traversaro commented 5 years ago

This was fixed in https://github.com/robotology/gazebo-fmi/pull/56 , but is probably still not implemented for the single body fluid dynamics plugin.