Skip to content

Commit

Permalink
Merge pull request #400 from robotology/fix/force_positive_sdf_random…
Browse files Browse the repository at this point in the history
…ization

Fix positivity option of model randomizations
  • Loading branch information
diegoferigo authored Oct 3, 2021
2 parents 71bc86f + ac0b447 commit 1b1ed90
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/gym_ignition/randomizers/model/sdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ def sample(self, pretty_print=False) -> str:
else:
raise ValueError("Distribution not recognized")

if data.force_positive:
sample = max(sample, 0.0)

# Update the value
if data.method is Method.Absolute:

Expand All @@ -318,6 +315,9 @@ def sample(self, pretty_print=False) -> str:
else:
raise ValueError("Method not recognized")

if data.force_positive:
data.element.text = str(max(float(data.element.text), 0.0))

return etree.tostring(self._root, pretty_print=pretty_print).decode()

def new_randomization(self) -> RandomizationDataBuilder:
Expand Down

0 comments on commit 1b1ed90

Please sign in to comment.