Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 91 additions & 57 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -254,94 +254,128 @@ module = [
"roboticstoolbox.backends.PyPlot.RobotPlot",
"roboticstoolbox.backends.PyPlot.RobotPlot2",
"roboticstoolbox.backends.PyPlot.EllipsePlot",
]
disallow_untyped_defs = true

# The to-do list for the typing pass. A module is listed here because it still
# has type errors; fix a module, delete its line, and mypy then holds it to
# zero. The list should only ever get shorter. A module that is not listed
# is checked, and must stay clean.
[[tool.mypy.overrides]]
module = [
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"roboticstoolbox.bin.rtbtool",
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"roboticstoolbox.blocks.arm",
"roboticstoolbox.blocks.mobile",
"roboticstoolbox.blocks.spatial",
"roboticstoolbox.blocks.uav",
"roboticstoolbox.blocks.quad_model",
"roboticstoolbox.tools.Ticker",
"roboticstoolbox.tools.data",
"roboticstoolbox.tools.jsingu",
"roboticstoolbox.tools.null",
"roboticstoolbox.tools.numerical",
"roboticstoolbox.tools.p_servo",
"roboticstoolbox.tools.params",
"roboticstoolbox.tools.plot",
"roboticstoolbox.tools.trchain",
"roboticstoolbox.tools.urdf.urdf",
"roboticstoolbox.tools.urdf.utils",
"roboticstoolbox.demo.eigdemo",
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"roboticstoolbox.demo.tripleangledemo",
"roboticstoolbox.demo.twistdemo",
"roboticstoolbox.bin._bintools",
"roboticstoolbox.bin.rtbtool",
"roboticstoolbox.models.DH.AL5D",
"roboticstoolbox.models.DH.Ball",
"roboticstoolbox.models.DH.Baxter",
"roboticstoolbox.models.DH.Cobra600",
"roboticstoolbox.models.DH.Coil",
"roboticstoolbox.models.DH.Hyper",
"roboticstoolbox.models.DH.Hyper3d",
"roboticstoolbox.models.DH.IRB140",
"roboticstoolbox.models.DH.Jaco",
"roboticstoolbox.models.DH.KR5",
"roboticstoolbox.models.DH.LWR4",
"roboticstoolbox.models.DH.Mico",
"roboticstoolbox.models.DH.Orion5",
"roboticstoolbox.models.DH.P8",
"roboticstoolbox.models.DH.Panda",
"roboticstoolbox.models.DH.Planar2",
"roboticstoolbox.models.DH.Planar3",
"roboticstoolbox.models.DH.Puma560",
"roboticstoolbox.models.DH.Sawyer",
"roboticstoolbox.models.DH.Stanford",
"roboticstoolbox.models.DH.TwoLink",
"roboticstoolbox.models.DH.UR10",
"roboticstoolbox.models.DH.UR3",
"roboticstoolbox.models.DH.UR5",
"roboticstoolbox.models.DH.Uprighttl",
"roboticstoolbox.models.ETS.GenericSeven",
"roboticstoolbox.models.ETS.Planar2",
"roboticstoolbox.models.ETS.Planar_Y",
"roboticstoolbox.models.URDF.AL5D",
"roboticstoolbox.models.URDF.Fetch",
"roboticstoolbox.models.URDF.Frankie",
"roboticstoolbox.models.URDF.FrankieOmni",
"roboticstoolbox.models.URDF.Jaco",
"roboticstoolbox.models.URDF.KinovaGen3",
"roboticstoolbox.models.URDF.LBR",
"roboticstoolbox.models.URDF.PR2",
"roboticstoolbox.models.URDF.Panda",
"roboticstoolbox.models.URDF.Puma560",
"roboticstoolbox.models.URDF.UR10",
"roboticstoolbox.models.URDF.UR3",
"roboticstoolbox.models.URDF.UR5",
"roboticstoolbox.models.URDF.URDFRobot",
"roboticstoolbox.models.URDF.Valkyrie",
"roboticstoolbox.models.URDF.YuMi",
"roboticstoolbox.models.URDF.px100",
"roboticstoolbox.models.URDF.px150",
"roboticstoolbox.models.URDF.rx150",
"roboticstoolbox.models.URDF.rx200",
"roboticstoolbox.models.URDF.vx300",
"roboticstoolbox.models.URDF.vx300s",
"roboticstoolbox.models.URDF.wx200",
"roboticstoolbox.models.URDF.wx250",
"roboticstoolbox.models.URDF.wx250s",
"roboticstoolbox.models.catalog",
"roboticstoolbox.ets.ET",
"roboticstoolbox.ets.ET2",
"roboticstoolbox.ets.ETS",
"roboticstoolbox.ets.ETS2",
"roboticstoolbox.ets._ET",
"roboticstoolbox.ets._ETS",
"roboticstoolbox.ets.fknm",
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"roboticstoolbox.mobile.ParticleFilter",
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"roboticstoolbox.models.DH.Planar2",
"roboticstoolbox.models.ETS.Frankie",
"roboticstoolbox.models.ETS.Omni",
"roboticstoolbox.models.ETS.Panda",
"roboticstoolbox.models.ETS.Puma560",
"roboticstoolbox.models.ETS.XYPanda",
"roboticstoolbox.models.URDF.URDFRobot",
"roboticstoolbox.models.catalog",
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"roboticstoolbox.robot.BaseRobot",
"roboticstoolbox.robot.DHFactor",
"roboticstoolbox.robot.DHLink",
"roboticstoolbox.robot.DHRobot",
"roboticstoolbox.robot.Dynamics",
"roboticstoolbox.robot.ELink",
"roboticstoolbox.robot.ERobot",
"roboticstoolbox.robot.Gripper",
"roboticstoolbox.robot.IK",
"roboticstoolbox.robot.Link",
"roboticstoolbox.robot.PoERobot",
"roboticstoolbox.robot.Robot",
"roboticstoolbox.robot.RobotKinematics",
"roboticstoolbox.robot.RobotPlottingMPL",
"roboticstoolbox.robot.RobotProto",
"roboticstoolbox.robot.frne",
"roboticstoolbox.robot",
]
disallow_untyped_defs = true

# The to-do list for the typing pass. A module is listed here because it still
# has type errors; fix a module, delete its line, and mypy then holds it to
# zero. The list should only ever get shorter. A module that is not listed
# is checked, and must stay clean.
[[tool.mypy.overrides]]
module = [
"roboticstoolbox.mobile.ParticleFilter",
]
ignore_errors = true

[[tool.mypy.overrides]]
module = [
"roboticstoolbox.tools.DHFactor",
"roboticstoolbox.tools.Ticker",
"roboticstoolbox.tools.data",
"roboticstoolbox.tools.jsingu",
"roboticstoolbox.tools.numerical",
"roboticstoolbox.tools.trajectory",
"roboticstoolbox.tools.trchain",
"roboticstoolbox.tools.urdf.tests.test_urdf",
"roboticstoolbox.tools.urdf.urdf",
"roboticstoolbox.tools.DHFactor",
"roboticstoolbox.robot.DHFactor",
]
ignore_errors = true

Expand Down
17 changes: 17 additions & 0 deletions src/roboticstoolbox/backends/Connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class Connector(ABC):
#: True if the backend can render EllipsePlot objects.
supports_ellipse: bool = False

#: velocity and force ellipsoids shown by the teach pendant, set by it
_teach_vellipse: Any
_teach_fellipse: Any

def __init__(self) -> None:
super().__init__()

Expand Down Expand Up @@ -104,6 +108,19 @@ def remove(self, *args: Any, **kwargs: Any) -> Any:

pass

def _add_teach_panel(
self, robot: Any, q: Any, handle: Any = None, block: bool = True
) -> Any:
"""
Add the teach pendant controls for ``robot``, if the backend supports
them (see ``supports_teach``).

:return: True if the backend has already blocked until dismissed
"""
raise NotImplementedError(
f"{self.__class__.__name__} does not have a teach pendant"
)

@abstractmethod
def hold(self, *args: Any, **kwargs: Any) -> Any: # pragma nocover
"""
Expand Down
25 changes: 15 additions & 10 deletions src/roboticstoolbox/bin/rtbtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
$ rtbtool myscript.py
"""

from __future__ import annotations

from typing import Any

# import stuff
import argparse
import pathlib
Expand Down Expand Up @@ -51,7 +55,7 @@
_OPTIONS_ENVVAR = "RTB_OPTIONS"


def env_arguments(parser):
def env_arguments(parser: Any) -> Any:
"""Return command-line style options from the environment.

:param parser: argument parser used for error reporting
Expand All @@ -69,7 +73,7 @@
parser.error(f"invalid {_OPTIONS_ENVVAR}: {exc}")


def parse_arguments():
def parse_arguments() -> Any:
parser = argparse.ArgumentParser(
description="Robotics Toolbox shell",
formatter_class=LineWrapRawTextDefaultsHelpFormatter,
Expand Down Expand Up @@ -180,7 +184,7 @@
]


def make_banner():
def make_banner() -> Any:
# banner template
# https://patorjk.com/software/taag/#p=display&f=Cybermedium&t=Robotics%20Toolbox%0A

Expand Down Expand Up @@ -218,12 +222,12 @@
return banner


def examples_path():
def examples_path() -> Any:
# Repository layout: <root>/src/roboticstoolbox/bin/rtbtool.py
return pathlib.Path(__file__).resolve().parents[3] / "examples"


def startup():
def startup() -> None:
plt.ion()


Expand Down Expand Up @@ -271,7 +275,7 @@
return n_passed == len(checks)


def main():
def main() -> None:
args, ipython_args = parse_arguments()

if args.test:
Expand Down Expand Up @@ -317,10 +321,11 @@

# set default backend for Robot.plot
if args.swift:
Robot.default_backend = "swift"
# an attribute that shadows the class method, see findings
Robot.default_backend = "swift" # type: ignore[method-assign,assignment]

Check warning on line 325 in src/roboticstoolbox/bin/rtbtool.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/roboticstoolbox/bin/rtbtool.py#L325

'Robot' may be undefined, or defined from star imports: roboticstoolbox, spatialgeometry, spatialmath, spatialmath.base (F405)

# set matrix printing mode for spatialmath
SE3._ansimatrix = args.ansi
SE3._ansimatrix = args.ansi # type: ignore[name-defined] # from the star import

Check warning on line 328 in src/roboticstoolbox/bin/rtbtool.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/roboticstoolbox/bin/rtbtool.py#L328

'SE3' may be undefined, or defined from star imports: roboticstoolbox, spatialgeometry, spatialmath, spatialmath.base (F405)

# set default matplotlib backend
if args.backend is not None:
Expand All @@ -343,10 +348,10 @@

# drop into IPython
class MyPrompt(Prompts):
def in_prompt_tokens(self, cli=None):
def in_prompt_tokens(self, cli: Any = None) -> Any:
return [(Token.Prompt, args.prompt)]

def out_prompt_tokens(self, cli=None):
def out_prompt_tokens(self, cli: Any = None) -> Any:
if args.resultprefix is None:
# traditional behaviour
return [
Expand Down
14 changes: 7 additions & 7 deletions src/roboticstoolbox/blocks/mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ class Unicycle(ContinuousBlock):

def __init__(
self,
w=1,
speed_max=np.inf,
accel_max=np.inf,
steer_max=np.inf,
w: float = 1,
speed_max: Any = np.inf,
accel_max: Any = np.inf,
steer_max: Any = np.inf,
# a=0, implement this, RVC2 p111, change output and deriv
x0=None,
**blockargs,
):
x0: Any = None,
**blockargs: Any,
) -> None:
r"""

:param w: vehicle width, defaults to 1
Expand Down
14 changes: 9 additions & 5 deletions src/roboticstoolbox/demo/eigdemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@

"""

from __future__ import annotations

from typing import Any

import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from math import pi, sin, cos


def eigdemo(A):
def eigdemo(A: Any) -> None:

print("matrix A =")
print(A)
Expand All @@ -31,7 +35,7 @@
s = np.max(np.abs(e))

fig, ax = plt.subplots()
plt.axis([-s, s, -s, s])
plt.axis((-s, s, -s, s))
plt.grid(True)
plt.title("Eigenvector demonstration")
plt.xlabel("x")
Expand All @@ -51,7 +55,7 @@

print("\nto exit: type q, or close the window")

def animate(theta):
def animate(theta: Any) -> Any:

x = np.r_[cos(-theta), sin(-theta)]
y = A @ x
Expand All @@ -76,15 +80,15 @@
plt.show(block=True)


def main():
def main() -> None:
# eigdemo() prints 位1/位2 -- on Windows, stdout defaults to the legacy
# cp1252 console codepage (which can't encode 位) whenever it isn't a
# real console, e.g. piped/redirected output. reconfigure() (3.7+)
# forces UTF-8 regardless.
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")

def help():
def help() -> None:

Check warning on line 91 in src/roboticstoolbox/demo/eigdemo.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/roboticstoolbox/demo/eigdemo.py#L91

Redefining built-in 'help'
print("eigdemo # uses default matrix [1 2; 3 4]")
print("eigdemo a b c d # uses matrix [a b; c d]")
sys.exit(0)
Expand Down
Loading
Loading