Project

General

Profile

Actions

Bug #360

closed

Possibly wrong check of tag <period>

Added by Gianluca Corsini over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal

Description

If I understood correctly, the tag <period> is used as the running period for the updater_thread, which updates all the motors.
If so, it is a property of the whole plugin and not related to a specific <rotor>.
Therefore, it should be specified outside the tag <rotors>, similarly to the following:

    <plugin name="mrsim" filename="mrsim-gazebo.so">
      <link>base</link>
      <period>1e-3</period>
      <rotors>
        <noise>0.03</noise>
        <cf>6.5e-4</cf>
        <ct>1e-5</ct>
        <rotor><joint spin="cw">rotor-1</joint></rotor>
        <rotor><joint spin="ccw">rotor-2</joint></rotor>
        <rotor><joint spin="cw">rotor-3</joint></rotor>
        <rotor><joint spin="ccw">rotor-4</joint></rotor>
      </rotors>
    </plugin>

Keeping that in mind, by looking at line 244, it seems that the tag <period> is never going to be found.

Indeed, the ElementPtr r is used, which is either pointing to the tag <rotors>, if this tag is present, or to nothing, otherwise.
In this last case, the code might run into an undefined behavior since the pointer has no prior initialization, and the code is trying to run the method HasElement.

Therefore, I think line 244 should be fixed as follows:

1000000 * (sdf->HasElement("period") ? sdf->Get<double>("period") : 1e-3);

@Anthony Mallet, is it correct what I am saying?

Actions

Also available in: Atom PDF