Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
petercorke committed May 9, 2021
2 parents c77faac + a8e5187 commit 338d960
Show file tree
Hide file tree
Showing 21 changed files with 1,311 additions and 1,130 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/future_testing.yml
@@ -0,0 +1,62 @@
name: build

on:
push:
branches: [ future ]

jobs:
unittest:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Checkout future branch
uses: actions/checkout@v2
with:
ref: future
path: rtb

- name: Checkout Swift
uses: actions/checkout@v2
with:
repository: jhavl/swift
path: swift

- name: Checkout Spatialmath
uses: actions/checkout@v2
with:
repository: petercorke/spatialmath-python
path: sm

- name: Checkout Spatialgeometry
uses: actions/checkout@v2
with:
repository: jhavl/spatialgeometry
path: sg

- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd sm
python -m pip install .
cd ../sg
python -m pip install .
cd ../swift
python -m pip install .
cd ../rtb/rtb-data
python -m pip install .
- name: Test with pytest
run: |
cd rtb
pip install .[dev,collision,vpython]
pip install pytest-timeout
pytest --timeout=50 --timeout_method thread -s
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Expand Up @@ -16,7 +16,7 @@ jobs:
max-parallel: 2
matrix:
os: [macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
110 changes: 0 additions & 110 deletions examples/swift2.py

This file was deleted.

57 changes: 28 additions & 29 deletions roboticstoolbox/backends/PyPlot/EllipsePlot.py
Expand Up @@ -9,9 +9,8 @@
import matplotlib.pyplot as plt


class EllipsePlot():

def __init__(self, robot, q, etype, opt='trans', centre=[0, 0, 0], scale=1):
class EllipsePlot:
def __init__(self, robot, q, etype, opt="trans", centre=[0, 0, 0], scale=1):

super(EllipsePlot, self).__init__()

Expand All @@ -21,10 +20,10 @@ def __init__(self, robot, q, etype, opt='trans', centre=[0, 0, 0], scale=1):
centre = base.getvector(centre, 2)
centre = np.array([centre[0], centre[1], 0])
except TypeError:
if centre != 'ee':
if centre != "ee":
raise ValueError(
'Centre must be a three vector or \'ee\' meaning'
'end-effector')
"Centre must be a three vector or 'ee' meaning" "end-effector"
)

self.ell = None
self.robot = robot
Expand All @@ -38,12 +37,12 @@ def __init__(self, robot, q, etype, opt='trans', centre=[0, 0, 0], scale=1):
else:
self.q = q

if etype == 'v':
if etype == "v":
self.vell = True
self.name = 'Velocity Ellipse'
elif etype == 'f':
self.name = "Velocity Ellipse"
elif etype == "f":
self.vell = False
self.name = 'Force Ellipse'
self.name = "Force Ellipse"

def draw(self):
self.make_ellipsoid()
Expand All @@ -52,33 +51,32 @@ def draw(self):
self.ax.collections.remove(self.ell)

self.ell = self.ax.plot_wireframe(
self.x, self.y, self.z, rstride=6,
cstride=6, color='#2980b9', alpha=0.2)
self.x, self.y, self.z, rstride=6, cstride=6, color="#2980b9", alpha=0.2
)

def draw2(self):
self.make_ellipsoid2()

if self.ell is not None:
self.ell[0].set_data(self.x, self.y)
else:
self.ell = self.ax.plot(
self.x, self.y, color='#2980b9')
self.ell = self.ax.plot(self.x, self.y, color="#2980b9")

def plot(self, ax=None):
if ax is None:
ax = self.ax

if ax is None:
fig = plt.figure()
ax = plt.axes(projection='3d')
ax = plt.axes(projection="3d")
self.ax = ax

self.draw()

def plot2(self, ax=None):
if ax is None:
ax = self.ax

if ax is None:
ax = plt.axes()
self.ax = ax
Expand All @@ -91,18 +89,18 @@ def make_ellipsoid(self):
"""

if self.opt == 'trans':
if self.opt == "trans":
J = self.robot.jacobe(self.q)[3:, :]
A = J @ J.T
elif self.opt == 'rot':
elif self.opt == "rot":
J = self.robot.jacobe(self.q)[:3, :]
A = J @ J.T

if not self.vell:
# Do the extra step for the force ellipse
A = np.linalg.inv(A)

if isinstance(self.centre, str) and self.centre == 'ee':
if isinstance(self.centre, str) and self.centre == "ee":
centre = self.robot.fkine(self.q).t
else:
centre = self.centre
Expand All @@ -121,8 +119,9 @@ def make_ellipsoid(self):
# transform points to ellipsoid
for i in range(len(x)):
for j in range(len(x)):
[x[i, j], y[i, j], z[i, j]] = \
np.dot([x[i, j], y[i, j], z[i, j]], rotation)
[x[i, j], y[i, j], z[i, j]] = np.dot(
[x[i, j], y[i, j], z[i, j]], rotation
)

self.x = x * self.scale + centre[0]
self.y = y * self.scale + centre[1]
Expand All @@ -134,13 +133,13 @@ def make_ellipsoid2(self):
"""

if self.opt == 'trans':
if self.opt == "trans":
J = self.robot.jacob0(self.q)[:2, :]
A = J @ J.T
elif self.opt == 'rot':
elif self.opt == "rot":
raise ValueError(
"Can not do rotational ellipse for a 2d robot plot."
" Set opt='trans'")
"Can not do rotational ellipse for a 2d robot plot." " Set opt='trans'"
)

# if not self.vell:
# # Do the extra step for the force ellipse
Expand All @@ -149,7 +148,7 @@ def make_ellipsoid2(self):
# except:
# A = np.zeros((2,2))

if isinstance(self.centre, str) and self.centre == 'ee':
if isinstance(self.centre, str) and self.centre == "ee":
centre = self.robot.fkine(self.q).t
else:
centre = self.centre
Expand All @@ -158,7 +157,7 @@ def make_ellipsoid2(self):
theta = np.linspace(0.0, 2.0 * np.pi, 50)
y = np.array([np.cos(theta), np.sin(theta)])
# RVC2 p 602
x = sp.linalg.sqrtm(A) @ y
# x = sp.linalg.sqrtm(A) @ y

x, y = base.ellipse(A, inverted=True, centre=centre[:2], scale=self.scale)
self.x = x
Expand Down

0 comments on commit 338d960

Please sign in to comment.