Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pycapacity/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def chebyshev_ball(A,b):
res = cvxopt.glpk.lp(c=c, G=G, h=h, options=solvers_opt)
return np.array(res[1][:-1]).reshape((-1,)), np.array(res[1][-1]).reshape((-1,))

def hspace_to_vertex(H,d):
def hspace_to_vertex(H,d, verbose = True):
"""
From half-space representation to the vertex representation

Expand All @@ -585,12 +585,12 @@ def hspace_to_vertex(H,d):
hd = HalfspaceIntersection(hd_mat,feasible_point)
hull = ConvexHull(hd.intersections)
except:
print("H2V: Convex hull issue: using QJ option! ")
if(verbose): print("H2V: Convex hull issue: using QJ option! ")
try:
hd = HalfspaceIntersection(hd_mat,feasible_point,qhull_options='QJ')
hull = ConvexHull(hd.intersections)
except:
print("H2V: Convex hull issue: using Q0 option! ")
if (verbose): print("H2V: Convex hull issue: using Q0 option! ")
hd = HalfspaceIntersection(hd_mat,feasible_point,qhull_options='Q0')
hull = ConvexHull(hd.intersections)
return hd.intersections.T, hull.simplices
Expand Down
10 changes: 8 additions & 2 deletions pycapacity/human.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ def joint_torques_polytope(N, F_min, F_max, tol=1e-5, options=None):
polytope object with the following attributes ``vertices``, half-plane representation ``H``, ``d``, (and ``face_indices`` and ``faces`` if option ``calculate_faces`` is set to ``True``)
"""
H, d = hyper_plane_shift_method(N, F_min, F_max)
vert, faces = hspace_to_vertex(H,d)
verbose = True
if options is not None and 'verbose' in options.keys() and options['verbose'] is False:
verbose = False
vert, faces = hspace_to_vertex(H,d, verbose)

# create the polytope object
poly = Polytope(vertices=vert, H=H, d=d)
Expand Down Expand Up @@ -183,7 +186,10 @@ def acceleration_polytope(J, N, M, F_min, F_max, tol=1e-5, options=None):
poly.face_indices = faces
else:
H,d = hyper_plane_shift_method(J.dot(np.linalg.inv(M).dot(N)),F_min,F_max)
vert, faces = hspace_to_vertex(H,d)
verbose = True
if options is not None and 'verbose' in options.keys() and options['verbose'] is False:
verbose = False
vert, faces = hspace_to_vertex(H,d, verbose)
# construct polytope object
poly = Polytope(vertices=vert, H=H, d=d)
poly.face_indices = faces
Expand Down
2 changes: 1 addition & 1 deletion pycapacity/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def find_vertices(self):

"""
if self.H is not None and self.d is not None:
# finding vertices of the polytope from the half-plane representation
# finding vertices of the polytope from the half-plane representation
self.vertices, self.face_indices = hspace_to_vertex(self.H,self.d)
else:
print("No half-plane representation of the polytope is available")
Expand Down
11 changes: 9 additions & 2 deletions pycapacity/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ def velocity_polytope(Jacobian, dq_max, dq_min, options = None):
polytope object with ``vertices``, halfspaces ``H`` and ``d`` (``face_indices`` and ``faces`` if option ``calculate_faces`` is set to True)
"""
H, d = hyper_plane_shift_method(Jacobian,dq_min,dq_max)
velocity_vertex, vel_faces = hspace_to_vertex(H,d)
verbose = True
if options is not None and 'verbose' in options.keys() and options['verbose'] is False:
verbose = False
velocity_vertex, vel_faces = hspace_to_vertex(H,d, verbose)

# create polytope
poly = Polytope(vertices=velocity_vertex, H=H, d=d)
Expand Down Expand Up @@ -300,7 +303,11 @@ def acceleration_polytope(J, M, t_max, t_min, t_bias= None, options = None):
t_max = t_max - t_bias

H, d = hyper_plane_shift_method(B,t_min, t_max)
vertex, faces = hspace_to_vertex(H,d)
verbose = True
if options is not None and 'verbose' in options.keys() and options['verbose'] is False:
verbose = False
vertex, faces = hspace_to_vertex(H,d, verbose)



# create polytope
Expand Down