Skip to content

Commit 5da75f1

Browse files
committed
Merge branch 'master' of github.com:petercorke/robotics-toolbox-python
2 parents a0cbab5 + eafff14 commit 5da75f1

File tree

13 files changed

+604
-166
lines changed

13 files changed

+604
-166
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ orientation parallel to y-axis (O=+Y)).
110110
from spatialmath import SE3
111111

112112
T = SE3(0.8, 0.2, 0.1) * SE3.OA([0, 1, 0], [0, 0, -1])
113-
sol = robot.ikine_unc(T) # solve IK
114-
print(sol.q) # display joint angles
113+
sol = robot.ikine_min(T) # solve IK
114+
print(sol.q) # display joint angles
115115

116116
[-0.01044 7.876 1.557 -6.81 1.571 4.686 0.5169]
117117

examples/plot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
q = np.random.rand(100, 7)
1717

1818
# Plot the joint trajectory with a 50ms delay between configurations
19-
# panda.plot(q=q, backend='pyplot', dt=0.050, vellipse=True, fellipse=True)
20-
panda.plot(q=q, backend='pyplot', dt=0.050, vellipse=False, fellipse=False)
19+
panda.plot(q=q, backend='pyplot', dt=0.050, vellipse=True, fellipse=True)
20+
# panda.plot(q=q, backend='swift', dt=0.050, vellipse=False, fellipse=False)
21+
22+
# panda.plot(q=panda.qz, backend='swift')
23+
24+
# print(panda.qr)
25+
# print(panda.fkine(q=panda.qz))
2126

2227
# r = rp.models.ETS.GenericSeven()
2328

examples/rtb.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,23 @@
3131
help='specify script to run')
3232
parser.add_argument('--backend', '-b', default=None,
3333
help='specify graphics frontend')
34+
parser.add_argument('--color', '-c', default='neutral',
35+
help='specify terminal color scheme (neutral, lightbg, nocolor, linux), linux is for dark mode')
36+
parser.add_argument('--confirmexit', '-x', default=False,
37+
help='confirm exit')
38+
parser.add_argument('--prompt', '-p', default='>>> ',
39+
help='input prompt')
40+
parser.add_argument('--resultprefix', '-r', default=None,
41+
help='execution result prefix, include {} for execution count number')
42+
parser.add_argument('--showassign', '-a', default=False,
43+
help='display the result of assignments')
3444
args = parser.parse_args()
3545

3646
if args.backend is not None:
3747
print(f"Using matplotlub backend {args.backend}")
3848
plt.use(args.backend)
3949

40-
# load some models
50+
# load some robot models
4151
puma = models.DH.Puma560()
4252
panda = models.DH.Panda()
4353

@@ -68,12 +78,32 @@
6878
## drop into IPython
6979
import IPython
7080
from traitlets.config import Config
81+
from IPython.terminal.prompts import ClassicPrompts
82+
from IPython.terminal.prompts import Prompts
83+
from pygments.token import Token
84+
85+
class MyPrompt(Prompts):
86+
def in_prompt_tokens(self, cli=None):
87+
return [(Token.Prompt, args.prompt)]
88+
def out_prompt_tokens(self, cli=None):
89+
if args.resultprefix is None:
90+
# traditional behaviour
91+
return [
92+
(Token.OutPrompt, 'Out['),
93+
(Token.OutPromptNum, str(self.shell.execution_count)),
94+
(Token.OutPrompt, ']: '),
95+
]
96+
else:
97+
return [(Token.Prompt, args.resultprefix.format(self.shell.execution_count))]
7198

7299
# set configuration options, there are lots, see
73100
# https://ipython.readthedocs.io/en/stable/config/options/terminal.html
74101
c = Config()
75-
c.InteractiveShellEmbed.colors = "Linux"
76-
c.InteractiveShell.colors = 'Neutral'
77-
c.InteractiveShell.confirm_exit = False
102+
c.InteractiveShellEmbed.colors = args.color
103+
c.InteractiveShell.confirm_exit = args.confirmexit
104+
# c.InteractiveShell.prompts_class = ClassicPrompts
105+
c.InteractiveShell.prompts_class = MyPrompt
106+
if args.showassign:
107+
c.InteractiveShell.ast_node_interactivity = 'last_expr_or_assign'
78108

79109
IPython.embed(config=c)

roboticstoolbox/backends/ROS/ROS.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def hold(self):
101101
def add(
102102
self, ob):
103103
"""
104-
105104
"""
106105

107106
super().add()

roboticstoolbox/models/list.py

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,50 +34,57 @@ def list(keywords=None, dof=None, mtype=None):
3434
# module = importlib.import_module(
3535
# '.' + os.path.splitext(file)[0], package='bdsim.blocks')
3636

37-
table = ANSITable(
38-
Column("class", headalign="^", colalign="<"),
39-
Column("model", headalign="^", colalign="<"),
40-
Column("manufacturer", headalign="^", colalign="<"),
41-
Column("model type", headalign="^", colalign="<"),
42-
Column("DoF", colalign="<"),
43-
Column("config", colalign="<"),
44-
Column("keywords", headalign="^", colalign="<"),
45-
border="thin"
46-
)
47-
48-
if mtype is not None:
49-
categories = [mtype]
50-
else:
51-
categories = ['DH', 'URDF', 'ETS']
52-
for category in categories:
53-
group = m.__dict__[category]
54-
for cls in group.__dict__.values():
55-
if isinstance(cls, type) and issubclass(cls, Robot):
56-
# we found a Robot subclass, instantiate it
57-
robot = cls()
58-
try:
59-
config = robot.config()
60-
except Exception: # pragma nocover
61-
config = ""
62-
63-
# apply filters
64-
if keywords is not None:
65-
if len(set(keywords) & set(robot.keywords)) == 0:
66-
continue
67-
if dof is not None and robot.n != dof:
68-
continue # pragma nocover
69-
70-
# add the row
71-
table.row(
72-
cls.__name__,
73-
robot.name,
74-
robot.manufacturer,
75-
category,
76-
robot.n,
77-
config,
78-
', '.join(robot.keywords)
79-
)
80-
print(str(table).encode('utf8', errors='replace').decode('utf8'))
37+
def make_table(border):
38+
table = ANSITable(
39+
Column("class", headalign="^", colalign="<"),
40+
Column("model", headalign="^", colalign="<"),
41+
Column("manufacturer", headalign="^", colalign="<"),
42+
Column("model type", headalign="^", colalign="<"),
43+
Column("DoF", colalign="<"),
44+
Column("config", colalign="<"),
45+
Column("keywords", headalign="^", colalign="<"),
46+
border=border
47+
)
48+
49+
if mtype is not None:
50+
categories = [mtype]
51+
else:
52+
categories = ['DH', 'URDF', 'ETS']
53+
for category in categories:
54+
group = m.__dict__[category]
55+
for cls in group.__dict__.values():
56+
if isinstance(cls, type) and issubclass(cls, Robot):
57+
# we found a Robot subclass, instantiate it
58+
robot = cls()
59+
try:
60+
config = robot.config()
61+
except Exception: # pragma nocover
62+
config = ""
63+
64+
# apply filters
65+
if keywords is not None:
66+
if len(set(keywords) & set(robot.keywords)) == 0:
67+
continue
68+
if dof is not None and robot.n != dof:
69+
continue # pragma nocover
70+
71+
# add the row
72+
table.row(
73+
cls.__name__,
74+
robot.name,
75+
robot.manufacturer,
76+
category,
77+
robot.n,
78+
config,
79+
', '.join(robot.keywords)
80+
)
81+
82+
print(str(table))
83+
84+
try:
85+
make_table('thin')
86+
except UnicodeEncodeError:
87+
make_table('ascii')
8188

8289

8390
if __name__ == "__main__": # pragma nocover

0 commit comments

Comments
 (0)