Skip to content

Commit 468be04

Browse files
authored
robustified 2 joint arm example (AtsushiSakai#402)
two joint arm point control example will no longer fail if target point is out of reach
1 parent d7cc364 commit 468be04

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ArmNavigation/two_joint_arm_to_point_control/two_joint_arm_to_point_control.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def two_joint_arm(GOAL_TH=0.0, theta1=0.0, theta2=0.0):
3737
"""
3838
while True:
3939
try:
40-
theta2_goal = np.arccos(
41-
(x**2 + y**2 - l1**2 - l2**2) / (2 * l1 * l2))
40+
if np.sqrt(x**2 + y**2) > (l1 + l2):
41+
theta2_goal = 0
42+
else:
43+
theta2_goal = np.arccos(
44+
(x**2 + y**2 - l1**2 - l2**2) / (2 * l1 * l2))
4245
theta1_goal = np.math.atan2(y, x) - np.math.atan2(l2 *
4346
np.sin(theta2_goal), (l1 + l2 * np.cos(theta2_goal)))
4447

0 commit comments

Comments
 (0)