Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Sep 28, 2021
1 parent 15d8b9a commit 7608b5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 7 additions & 3 deletions tests/test_scenario/test_pid_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ def test_position_pid(default_world: Tuple[scenario.GazeboSimulator, scenario.Wo
assert world.insert_model(panda_urdf)
assert "panda" in world.model_names()

# Get the model and cast it to Gazebo
panda = world.get_model("panda").to_gazebo()

# Disable any velocity and torque limits of the model
_ = [j.set_velocity_limit(np.finfo(float).max) for j in panda.joints()]
_ = [j.set_max_generalized_force(np.finfo(float).max) for j in panda.joints()]

# Show the GUI
# import time
# gazebo.gui()
# gazebo.run(paused=True)
# time.sleep(3)

# Get the model and cast it to Gazebo
panda = world.get_model("panda").to_gazebo()

# Reset joint1 to its middle position
joint1 = panda.get_joint("panda_joint1").to_gazebo()
joint1_range = np.abs(joint1.position_limit().max - joint1.position_limit().min)
Expand Down
10 changes: 6 additions & 4 deletions tests/test_scenario/test_velocity_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def test_velocity_direct(
# Get the model and cast it to Gazebo
pendulum = world.get_model("pendulum").to_gazebo()

# Disable any velocity (and torque) limits of the model, otherwise the velocity
# cannot change too abruptly
_ = [j.set_velocity_limit(np.finfo(float).max) for j in pendulum.joints()]
_ = [j.set_max_generalized_force(np.finfo(float).max) for j in pendulum.joints()]

# Add some friction
assert pendulum.get_joint("pivot").to_gazebo().set_coulomb_friction(value=0.01)
assert pendulum.get_joint("pivot").to_gazebo().set_viscous_friction(value=0.2)
Expand Down Expand Up @@ -76,12 +81,9 @@ def test_velocity_direct(
# Check again
assert pivot.velocity() == pytest.approx(np.pi)

# Change direction abruptly.
# Due to existing joint velocity limits, it takes two steps to reach the target.
# Note: even by increasing the limit to its maximum value, two steps are necessary.
# Change direction abruptly
assert pivot.set_velocity_target(velocity=-np.pi)
assert gazebo.run()
assert gazebo.run()
assert pivot.velocity() == pytest.approx(-np.pi)

# Go in idle and make it swing
Expand Down

0 comments on commit 7608b5c

Please sign in to comment.