跳转到主要内容

从genmsg规范生成的Python存根生成器

项目描述

从genmsg规范生成的Python存根生成器

安装

如果您使用catkin并且需要CMake支持的genmypy生成器,请克隆存储库并将其添加到您的catkin工作空间。

cd /path/to/your/ws
git clone https://github.com/rospypi/genmypy.git

如果您不需要cmake支持,您也可以从pypi.org安装它

pip install genmypy

用法

catkin

genmypymessage_generation一起添加到CMakeLists.txt中的find_package。当构建msg/srv文件时,genmsg会自动找到genmypy

此外,请注意,您的包应该在package.xml中包含对genmypy的构建依赖,以确保catkin在构建您的包之前完成对genmypy的构建。

示例

  • CMakeLists.txt
    find_package(catkin REQUIRED COMPONENTS std_msgs message_generation genmypy)
  • package.xml
    <build_depend>genmypy</build_depend>

CLI

$ genmypy --help
Usage: genmypy [-h] {msg,srv,module} ...
positional arguments:
  {msg,srv,module}
    msg             Generate stub files from .msg files
    srv             Generate stub files from .srv files
    module          Generate __init__.pyi from a msg/srv directory

optional arguments:
  -h, --help        show this help message and exit

示例

# Message files
$ genmypy msg custom_msgs custom_msgs/msg/Custom.msg
$ genmypy msg std_msgs --out-dir out /opt/ros/noetic/share/std_msgs/msg/Header.msg
$ genmypy msg sensor_msgs --out-dir out \
    -Istd_msgs:/opt/ros/noetic/share/std_msgs/msg \
    -Isensor_msgs:/opt/ros/noetic/share/sensor_msgs/msg \
    /opt/ros/noetic/share/sensor_msgs/msg/PointCloud2.msg

# Service files
$ genmypy srv custom_msgs custom_msgs/srv/Custom.msg
$ genmypy srv nav_msgs --out-dir out \
    -Istd_msgs:/opt/ros/noetic/share/std_msgs/msg \
    -Isensor_msgs:/opt/ros/noetic/share/sensor_msgs/msg \
    /opt/ros/noetic/share/sensor_msgs/srv/SetCameraInfo.srv

# Module files
$ genmypy module custom_msgs/msg
$ genmypy module --module-finder py --out out \
    /opt/ros/noetic/lib/python2.7/dist-packages/std_msgs/msg/

genmypy msg / genmypy srv

Usage: genmypy {msg,srv} [-h] [--out-dir OUT_DIR]
                        [--include-path INCLUDE_PATH]
                        package files [files ...]

positional arguments:
  package               Package name of given files
  files                 Files to generate stubs

optional arguments:
  -h, --help            show this help message and exit
  --out-dir OUT_DIR     Output directory. If the option is unset, each stub
                        file will be generated in the same directory as each
                        input.
  --include-path INCLUDE_PATH, -I INCLUDE_PATH
                        Include paths for processing given files

genmypy 模块:

Usage: genmypy module [-h] [--out-dir OUT_DIR] package_dir

Positional arguments:
  package_dir        Package directory to create __init__.pyi

Optional arguments:
  -h, --help         show this help message and exit
  --out-dir OUT_DIR  Output directory. If the option is unset, __init__.pyi
                     will be generated in the same directory as package_dir.

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

genmypy-0.3.2.tar.gz (14.7 kB 查看哈希值)

上传时间

构建分布

genmypy-0.3.2-py2.py3-none-any.whl (14.8 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持