Skip to content

Commit b2826d7

Browse files
committed
fix iksolution printing
1 parent 844b73d commit b2826d7

File tree

1 file changed

+22
-8
lines changed
  • roboticstoolbox/robot

1 file changed

+22
-8
lines changed

roboticstoolbox/robot/IK.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,32 @@ class IKSolution:
5252
:param reason: The reason the IK problem failed if applicable
5353
"""
5454

55-
q: np.ndarray
55+
q: Union[np.ndarray, None]
5656
success: bool
57-
iterations: int
58-
searches: int
59-
residual: float
60-
reason: str
57+
iterations: int = 0
58+
searches: int = 0
59+
residual: float = 0.0
60+
reason: str = ""
6161

6262
def __str__(self):
63-
if self.success:
64-
return f"IKSolution: q={np.round(self.q, 4)}, success=True, iterations={self.iterations}, searches={self.searches}, residual={self.residual}"
63+
64+
if self.q is not None:
65+
q_str = np.round(self.q, 4)
66+
else:
67+
q_str = None
68+
69+
if self.iterations == 0 and self.searches == 0:
70+
# Check for analytic
71+
if self.success:
72+
return f"IKSolution: q={q_str}, success=True"
73+
else:
74+
return f"IKSolution: q={q_str}, success=False, reason={self.reason}"
6575
else:
66-
return f"IKSolution: q={np.round(self.q, 4)}, success=False, reason={self.reason}, iterations={self.iterations}, searches={self.searches}, residual={np.round(self.residual, 4)}"
76+
# Otherwise it is a numeric solution
77+
if self.success:
78+
return f"IKSolution: q={q_str}, success=True, iterations={self.iterations}, searches={self.searches}, residual={self.residual}"
79+
else:
80+
return f"IKSolution: q={q_str}, success=False, reason={self.reason}, iterations={self.iterations}, searches={self.searches}, residual={np.round(self.residual, 4)}"
6781

6882

6983
class IKSolver(ABC):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy