Skip to content

Commit 1d13a66

Browse files
committed
neo example
1 parent 67c49b2 commit 1d13a66

File tree

3 files changed

+24
-32
lines changed

3 files changed

+24
-32
lines changed

examples/mmc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import spatialmath as sm
88
import numpy as np
99
import qpsolvers as qp
10-
import time
1110

1211
# Launch the simulator Swift
1312
env = rtb.backend.Swift()

examples/neo.py

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import spatialmath as sm
88
import numpy as np
99
import qpsolvers as qp
10-
import time
1110

1211
# Launch the simulator Swift
1312
env = rtb.backend.Swift()
@@ -17,8 +16,6 @@
1716
panda = rtb.models.Panda()
1817

1918
# Set joint angles to ready configuration
20-
# panda.q = [
21-
# -0.5653, -0.1941, -1.2602, -0.7896, -2.3227, -0.3919, -2.5173, 0.0, 0.0]
2219
panda.q = panda.qr
2320

2421
# Number of joint in the panda which we are controlling
@@ -27,9 +24,9 @@
2724
# Make two obstacles with velocities
2825
s0 = rtb.Sphere(
2926
radius=0.05,
30-
base=sm.SE3(0.45, 0.4, 0.3)
27+
base=sm.SE3(0.52, 0.4, 0.3)
3128
)
32-
s0.v = [0.01, -0.2, 0, 0, 0, 0]
29+
s0.v = [0, -0.2, 0, 0, 0, 0]
3330

3431
s1 = rtb.Sphere(
3532
radius=0.05,
@@ -89,42 +86,38 @@
8986
Aeq = np.c_[panda.jacobe(), np.eye(6)]
9087
beq = v.reshape((6,))
9188

92-
# # The inequality constraints for joint limit avoidance
93-
# Ain = np.zeros((n + 6, n + 6))
94-
# bin = np.zeros(n + 6)
89+
# The inequality constraints for joint limit avoidance
90+
Ain = np.zeros((n + 6, n + 6))
91+
bin = np.zeros(n + 6)
9592

96-
# # The minimum angle (in radians) in which the joint is allowed to approach
97-
# # to its limit
98-
# ps = 0.05
93+
# The minimum angle (in radians) in which the joint is allowed to approach
94+
# to its limit
95+
ps = 0.05
9996

100-
# # The influence angle (in radians) in which the velocity damper
101-
# # becomes active
102-
# pi = 0.9
97+
# The influence angle (in radians) in which the velocity damper
98+
# becomes active
99+
pi = 0.9
103100

104-
# # Form the joint limit velocity damper
105-
# Ain[:n, :n], bin[:n] = panda.joint_velocity_damper(ps, pi, n)
106-
107-
Ain = None
108-
bin = None
101+
# Form the joint limit velocity damper
102+
Ain[:n, :n], bin[:n] = panda.joint_velocity_damper(ps, pi, n)
109103

104+
# For each collision in the scene
110105
for collision in collisions:
111106

107+
# Form the velocity damper inequality contraint for each collision
108+
# object on the robot to the collision in the scene
112109
c_Ain, c_bin = panda.link_collision_damper(
113-
collision, panda.q[:n], 0.3, 0.05,
110+
collision, panda.q[:n], 0.3, 0.05, 1.0,
114111
panda.elinks['panda_joint1'], panda.elinks['panda_hand_joint'])
115112

113+
# If there are any parts of the robot within the influence distance
114+
# to the collision in the scene
116115
if c_Ain is not None and c_bin is not None:
117116
c_Ain = np.c_[c_Ain, np.zeros((c_Ain.shape[0], 6))]
118117

119-
if Ain is None:
120-
Ain = c_Ain
121-
else:
122-
Ain = np.r_[Ain, c_Ain]
123-
124-
if bin is None:
125-
bin = np.array(c_bin)
126-
else:
127-
bin = np.r_[bin, c_bin]
118+
# Stack the inequality constraints
119+
Ain = np.r_[Ain, c_Ain]
120+
bin = np.r_[bin, c_bin]
128121

129122
# Linear component of objective function: the manipulability Jacobian
130123
c = np.r_[-panda.jacobm().reshape((n,)), np.zeros(6)]

roboticstoolbox/robot/ERobot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ def joint_velocity_damper(self, ps=0.05, pi=0.1, n=None, gain=1.0):
11431143
return Ain, Bin
11441144

11451145
def link_collision_damper(
1146-
self, shape, q=None, di=0.3, ds=0.05,
1146+
self, shape, q=None, di=0.3, ds=0.05, xi=1.0,
11471147
from_link=None, to_link=None):
11481148

11491149
if from_link is None:
@@ -1178,7 +1178,7 @@ def indiv_calculation(link, link_col, q):
11781178
dp = norm_h @ shape.v
11791179
l_Ain = np.zeros((1, n))
11801180
l_Ain[0, :n_dim] = norm_h @ Je
1181-
l_bin = (0.8 * (d - ds) / (di - ds)) + dp
1181+
l_bin = (xi * (d - ds) / (di - ds)) + dp
11821182
else:
11831183
l_Ain = None
11841184
l_bin = None

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