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
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ conda install rvc3python
There are a lot of dependencies and this might take a minute or so. You now have a very
powerful computing environment for robotics and computer vision.

To check everything installed and works correctly, run
```shell
rvctool --test
```
This is a quick, non-interactive check that prints package versions and exercises one
real code path per toolbox (RTB, MVTB, spatialgeometry, spatialmath, bdsim, and Open3D
if installed), reporting PASS/FAIL for each rather than just "it imported".

### Python version

`rvc3python` requires **Python 3.10 or later**.
Expand Down Expand Up @@ -129,13 +137,10 @@ for Python (RTB==1.3.1, MVTB==2.3.0, SG==1.3.0, SMTB==1.1.16, NumPy==2.5.2, SciP
func/object?? - show source code

Results of assignments will be displayed, use trailing ; to suppress

Python 3.12.8 | packaged by conda-forge
Type 'copyright', 'credits' or 'license' for more information
IPython 9.16.1 -- An enhanced Interactive Python. Type '?' for help.

Default numeric formatting: %.3g

>>>
>>>
```

This provides an interactive Python
Expand Down
61 changes: 61 additions & 0 deletions RVC3/bin/_bintools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
Shared helpers for RVC3 command-line tools.
"""

from __future__ import annotations

import argparse
import textwrap


def link(uri: str, label: str | None = None) -> str:
"""Return a terminal hyperlink escape sequence.

:param uri: target URL
:param label: display label, defaults to the URI itself
:return: OSC-8 hyperlink string
"""
# https://stackoverflow.com/questions/40419276/python-how-to-print-text-to-console-as-hyperlink
if label is None:
label = uri
escape_mask = "\033]8;{};{}\033\\{}\033]8;;\033\\"
return escape_mask.format("", uri, label)


class CustomHelpFormatter(argparse.HelpFormatter):
"""Argparse formatter that wraps at word boundaries on explicit newlines."""

def _split_lines(self, text: str, width: int) -> list[str]:
lines = text.splitlines()
wrapped: list[str] = []
for line in lines:
wrapped.extend(
textwrap.wrap(
line, width, break_long_words=False, break_on_hyphens=False
)
)
return wrapped


class CustomDefaultsHelpFormatter(
CustomHelpFormatter, argparse.ArgumentDefaultsHelpFormatter
):
"""Custom formatter that also appends default values in help output."""


class LineWrapRawTextHelpFormatter(argparse.RawDescriptionHelpFormatter):
"""Argparse formatter that reflows whitespace and wraps at 80 columns."""

def _split_lines(self, text: str, width: int) -> list[str]:
text = self._whitespace_matcher.sub(" ", text).strip()
return textwrap.wrap(text, 80)


class LineWrapRawTextDefaultsHelpFormatter(
LineWrapRawTextHelpFormatter, argparse.ArgumentDefaultsHelpFormatter
):
"""Line-wrapped formatter that also appends default values."""


RVC3_URL = "https://github.com/petercorke/RVC3-python"
RVC3_LINK = link(RVC3_URL, "Robotics, Vision & Control 3e: for Python")
Loading