Skip to content

Commit

Permalink
ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Dec 3, 2023
1 parent 45b0ec5 commit ba7b095
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion bindings/python/tsid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .tsid_pywrap import *
from .tsid_pywrap import * # noqa: F403
11 changes: 6 additions & 5 deletions demo/demo_quadruped.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
import time

import gepetto.corbaserver
import matplotlib.pyplot as plt
import numpy as np
import pinocchio as pin
import tsid
import plot_utils as plut
from numpy import nan
from numpy.linalg import norm as norm

import tsid

sys.path += [os.getcwd() + "/../exercizes"]
import matplotlib.pyplot as plt
import plot_utils as plut

np.set_printoptions(precision=3, linewidth=200, suppress=True)

Expand Down Expand Up @@ -57,8 +58,8 @@
],
pin.JointModelFreeFlyer(),
)
l = subprocess.getstatusoutput("ps aux |grep 'gepetto-gui'|grep -v 'grep'|wc -l")
if int(l[1]) == 0:
n = subprocess.getstatusoutput("ps aux |grep 'gepetto-gui'|grep -v 'grep'|wc -l")
if int(n[1]) == 0:
os.system("gepetto-gui &")
time.sleep(1)
cl = gepetto.corbaserver.Client()
Expand Down
7 changes: 4 additions & 3 deletions exercizes/ex_0_ur5_joint_space_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import numpy as np
import pinocchio as pin
import plot_utils as plut
import tsid
import ur5_conf as conf
from numpy import nan
from numpy.linalg import norm as norm

import tsid

print("".center(conf.LINE_WIDTH, "#"))
print(" Joint Space Inverse Dynamics - Manipulator ".center(conf.LINE_WIDTH, "#"))
print("".center(conf.LINE_WIDTH, "#"), "\n")
Expand Down Expand Up @@ -54,8 +55,8 @@
conf.path,
],
)
l = subprocess.getstatusoutput("ps aux |grep 'gepetto-gui'|grep -v 'grep'|wc -l")
if int(l[1]) == 0:
n = subprocess.getstatusoutput("ps aux |grep 'gepetto-gui'|grep -v 'grep'|wc -l")
if int(n[1]) == 0:
os.system("gepetto-gui &")
time.sleep(1)
gepetto.corbaserver.Client()
Expand Down
1 change: 0 additions & 1 deletion exercizes/ex_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import matplotlib.pyplot as plt
import numpy as np
import pinocchio as pin
import plot_utils as plut
import romeo_conf as conf
from numpy import nan
Expand Down
2 changes: 1 addition & 1 deletion exercizes/ex_3_biped_balance_with_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, master, name):
def get(self):
try:
return [float(self.s[i].get()) for i in range(3)]
except:
except ValueError:
print(
"could not convert string to float", [self.s[i].get() for i in range(3)]
)
Expand Down
4 changes: 2 additions & 2 deletions exercizes/ex_4_plan_LIPM_romeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

import ex_4_conf as conf
import matplotlib.pyplot as plt
from plot_utils import *

# from plot_utils import *

# import ex_4_long_conf as conf

Expand Down Expand Up @@ -155,7 +156,6 @@
plot_utils.plot_xy(
time, N, foot_length, foot_width, cop_ref, cop_x, cop_y, com_state_x, com_state_y
)
import matplotlib.pyplot as plt

plt.gca().set_xlim([cop_ref[0, 0] - 0.2, cop_ref[-1, 0] + 0.2])
plt.gca().set_ylim([cop_ref[0, 1] - 0.2, cop_ref[-1, 1] + 0.2])
Expand Down
4 changes: 2 additions & 2 deletions exercizes/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

def create_empty_figure(nRows=1, nCols=1, figsize=(7, 7), spinesPos=None, sharex=True):
f, ax = plt.subplots(nRows, nCols, figsize=figsize, sharex=sharex)
mngr = plt.get_current_fig_manager()
_mngr = plt.get_current_fig_manager()
# mngr.window.setGeometry(50,50,1080,720)

if spinesPos is not None:
Expand Down Expand Up @@ -307,7 +307,7 @@ def plotNdQuantityPerSolver(
ax[nRows // 2, 0].set_ylabel(title)
if SHOW_LEGENDS:
# leg = ax[0,0].legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.)
leg = ax[0, 0].legend(loc="best")
_leg = ax[0, 0].legend(loc="best")
# leg.get_frame().set_alpha(LEGEND_ALPHA)
return ax

Expand Down
3 changes: 1 addition & 2 deletions exercizes/tsid_biped.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
import pinocchio as pin

import tsid


Expand Down Expand Up @@ -176,8 +177,6 @@ def __init__(self, conf, viewer=pin.visualize.MeshcatVisualizer):
conf.urdf, [conf.path], pin.JointModelFreeFlyer()
)
if viewer == pin.visualize.GepettoVisualizer:
import gepetto.corbaserver

launched = subprocess.getstatusoutput(
"ps aux |grep 'gepetto-gui'|grep -v 'grep'|wc -l"
)
Expand Down
14 changes: 7 additions & 7 deletions exercizes/tsid_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import gepetto.corbaserver
import numpy as np
import numpy.matlib as matlib
import pinocchio as se3

import tsid


Expand All @@ -23,13 +23,13 @@ def __init__(self, conf, viewer=True):
robot = self.robot
self.model = model = robot.model()
try:
# q = se3.getNeutralConfiguration(model, conf.srdf, False)
# q = se3.getNeutralConfiguration(model, conf.srdf, False)
se3.loadReferenceConfigurations(model, conf.srdf, False)
q = model.referenceConfigurations["default"]
# q = model.referenceConfigurations["half_sitting"]
except:
# q = model.referenceConfigurations["half_sitting"]
except Exception:
q = conf.q0
# q = np.array(np.zeros(robot.nv)).T
# q = np.array(np.zeros(robot.nv)).T
v = np.zeros(robot.nv)

assert model.existFrame(conf.ee_frame_name)
Expand Down Expand Up @@ -93,10 +93,10 @@ def __init__(self, conf, viewer=True):
conf.path,
],
)
l = subprocess.getstatusoutput(
n = subprocess.getstatusoutput(
"ps aux |grep 'gepetto-gui'|grep -v 'grep'|wc -l"
)
if int(l[1]) == 0:
if int(n[1]) == 0:
os.system("gepetto-gui &")
time.sleep(1)
gepetto.corbaserver.Client()
Expand Down
6 changes: 2 additions & 4 deletions exercizes/ur5_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
@author: student
"""

import os
from os.path import join

import numpy as np
from example_robot_data.robots_loader import getModelPath

np.set_printoptions(precision=3, linewidth=200, suppress=True)
LINE_WIDTH = 60
Expand Down Expand Up @@ -53,9 +54,6 @@
EE_SPHERE_COLOR = (1, 0.5, 0, 0.5)
EE_REF_SPHERE_COLOR = (1, 0, 0, 0.5)

from os.path import join

from example_robot_data.robots_loader import getModelPath

urdf = "ur_description/urdf/ur5_robot.urdf"
path = getModelPath(urdf)
Expand Down
6 changes: 2 additions & 4 deletions exercizes/ur5_reaching_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
@author: student
"""

import os
from os.path import join

import numpy as np
from example_robot_data.robots_loader import getModelPath

np.set_printoptions(precision=3, linewidth=200, suppress=True)
LINE_WIDTH = 60
Expand Down Expand Up @@ -53,9 +54,6 @@
EE_SPHERE_COLOR = (1, 0.5, 0, 0.5)
EE_REF_SPHERE_COLOR = (1, 0, 0, 0.5)

from os.path import join

from example_robot_data.robots_loader import getModelPath

urdf = "ur_description/urdf/ur5_robot.urdf"
path = getModelPath(urdf)
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_Constraint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import pinocchio as se3

import tsid

print("")
Expand Down
4 changes: 2 additions & 2 deletions tests/python/test_Contact.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import copy
import os

import numpy as np
import pinocchio as se3

import tsid

print("")
print("Test Contact")
print("")

tol = 1e-5
import os

filename = str(os.path.dirname(os.path.abspath(__file__)))
path = filename + "/../models/romeo"
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_ContactPoint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import copy
import os

import numpy as np
import pinocchio as se3

import tsid

print("")
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_Gravity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

import numpy as np
import pinocchio as se3

import tsid

print("")
Expand Down
8 changes: 5 additions & 3 deletions tests/python/test_Tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import numpy as np
import pinocchio as pin
import tsid

# Get robot model generator module
from generator import create_7dof_arm
from numpy.linalg import norm

import tsid

print("")
print("Test Task COM")
print("")
Expand Down Expand Up @@ -278,8 +282,6 @@
print("Test Task Joint Posture (Uncommon joints)")
print("")

# Get robot model generator module
from generator import create_7dof_arm

# Get robot model
(
Expand Down

0 comments on commit ba7b095

Please sign in to comment.