GithubHelp home page GithubHelp logo

simple's Introduction

THIS IS NOT THE OFFICIAL ROSPY INDEX SERVER

rospy for pure Python

What is this for?

rospy packages without ROS installation. It can be run in a pure python virtualenv. It also supports tf2 and other binary packages.

Supported Python versions: 3.6, 3.7, 3.8

Support platforms: Linux, Windows, MacOSX

(Not all packages are tested.)

Note: If you're using Conda environment, be sure to take a look at RoboStack, which provides more ROS pre-built packages including non-Python packages and tools such as Rviz.

Install

virtualenv -p python3 venv
. ./venv/bin/activate
pip install --extra-index-url https://rospypi.github.io/simple/ rospy
pip install --extra-index-url https://rospypi.github.io/simple/ tf2_ros

Sample

import rospy
import std_msgs.msg


def callback(msg):
    print(msg)


rospy.init_node("hoge")
rospy.loginfo('start')
sub = rospy.Subscriber("sub", std_msgs.msg.String, callback)
pub = rospy.Publisher('pub', std_msgs.msg.Int16, queue_size=10)
rate = rospy.Rate(1)
while not rospy.is_shutdown():
    pub.publish(3)
    rate.sleep()

Enjoy!

Start a local pypi server

docker build -t localpypi .
docker run --rm -p 8000:8000 localpypi
virtualenv -p python3 venv
. ./venv/bin/activate
pip install --extra-index-url http://localhost:8000/index/ rospy

Development

build.py downloads packages from github.com, builds wheel files and generates a Python package server directory.

git submodule update --init --recursive
# create virtualenv for build packages
virtualenv -p python3 dev
. ./dev/bin/activate
pip install --extra-index-url https://rospypi.github.io/simple/ -e rospy-builder/
# build pure python packages
rospy-build build -d any
# build platform depended packages if you need
rospy-build build -d linux --native

To build index html files, use rospypi/index_builder.

pip3 install git+git://github.com/rospypi/index_builder.git
python3 -m index_builder local index/ any/ linux/
python -m http.server
virtualenv -p python3 venv
. ./venv/bin/activate
pip install --extra-index-url http://localhost:8000/index/ rospy

Generate Message Python Package

git clone https://github.com/rospypi/simple.git
cd simple
virtualenv -p python3 venv
. ./venv/bin/activate
pip install --extra-index-url https://rospypi.github.io/simple/ -e rospy-builder/
mkdir msgs
(cd msgs; git clone https://github.com/ros/std_msgs.git)
(cd msgs; git clone https://github.com/ros/common_msgs.git)
# (cd msgs; any repository that is depended on your message)
rospy-build genmsg your_package_path -s msgs/
# ex.rospy-build genmsg ros_tutorials/rospy_tutorials/ -s msgs/

simple's People

Contributors

bonprosoft avatar otamachan avatar sergeant-wizard avatar supern1ck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

simple's Issues

ModuleNotFoundError for Rospy --> Roscpp>=1.15.11

Problem & Diagnosis

Our Github Actions started to fail as of last week due to: ModuleNotFoundError: No module named 'roscpp.srv' when importing rospy.

To confirm I also tested this with a new local virtualenv by installing pip install --extra-index-url https://rospypi.github.io/simple/ rospy roscpp which also leads to the same error.

We've had to revert to roscpp==1.15.7.post0 for it to work again.

Solution:

pip install --extra-index-url https://rospypi.github.io/simple/ rospy roscpp==1.15.7.post0

Generating messages (on Windows): '-r' or '-s'?

While trying to follow the instructions for generating messages at the end of the readme, I'm confused about the command lines shown.

The first example uses -s:

rospy-build genmsg your_package_path -s msgs/

the second example (commented, and right below it), uses -r:

# ex.rospy-build -g ros_tutorials/rospy_tutorials/ -r msgs/

rospy-build doesn't seem to accept -r, only -s. But -s is the "path to packages.yaml", which I don't have (or at least I believe I don't have it).

Could you perhaps clarify?

Wrong mapping in `_CV_TYPES`?

Hey!

thanks for this awesome repo!

I had problems converting a 16UC1 depth image with cv_bridge installed through this repo. I am using it like

frame = cv_bridge_instance.imgmsg_to_cv2(
    ros_image, desired_encoding="passthrough"
) 

Luckily, I could track down the issue to a wrongly initialized dict here:


I changed this and the following 4 lines to

"16UC1": cv2.CV_16UC1,
"16UC2": cv2.CV_16UC1,
"16UC3": cv2.CV_16UC1,
"16UC4": cv2.CV_16UC1,

and now the above call returns the correct depth image.

About fixing the issue, I couldn't pin down whether this is a auto-generated file or manually and whether this is a bug in this repo or the original https://github.com/ros-perception/vision_opencv/tree/rolling/cv_bridge
But I would assume these regex are somewhat related:
https://github.com/ros-perception/vision_opencv/blob/c620dd9210bae632ebb442a63f34e9e0d469c57b/cv_bridge/src/cv_bridge.cpp#L106

Thanks,
-Nick

Install not possible on OSX Monterey 12.6

Hello!

I was delighted to find your package today, but was unable to install it. The command

pip install --extra-index-url https://rospypi.github.io/simple/ tf2_ros

Does not install properly, with the following message:

`Running setup.py install for tf2-py ... error
error: subprocess-exited-with-error

× Running setup.py install for tf2-py did not run successfully.
│ exit code: 1
╰─> [27 lines of output]
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-3.10
creating build/lib.macosx-10.9-universal2-3.10/tf2_py
copying geometry2/tf2_py/src/tf2_py/init.py -> build/lib.macosx-10.9-universal2-3.10/tf2_py
running build_ext
building '_tf2' extension
creating build/temp.macosx-10.9-universal2-3.10
creating build/temp.macosx-10.9-universal2-3.10/geometry2
creating build/temp.macosx-10.9-universal2-3.10/geometry2/tf2
creating build/temp.macosx-10.9-universal2-3.10/geometry2/tf2/src
creating build/temp.macosx-10.9-universal2-3.10/geometry2/tf2_py
creating build/temp.macosx-10.9-universal2-3.10/geometry2/tf2_py/src
creating build/temp.macosx-10.9-universal2-3.10/roscpp_core
creating build/temp.macosx-10.9-universal2-3.10/roscpp_core/rostime
creating build/temp.macosx-10.9-universal2-3.10/roscpp_core/rostime/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_ERROR_CODE_HEADER_ONLY -Igeometry2/tf2/include -Iroscpp_core/cpp_common/include -Iroscpp_core/rostime/include -Istubs/include -I/Users/markus/Documents/Exjobb/Python/USV_Simulering_1/usv_sim_venv/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c geometry2/tf2/src/buffer_core.cpp -o build/temp.macosx-10.9-universal2-3.10/geometry2/tf2/src/buffer_core.o -std=c++11
In file included from geometry2/tf2/src/buffer_core.cpp:32:
In file included from geometry2/tf2/include/tf2/buffer_core.h:35:
In file included from geometry2/tf2/include/tf2/transform_storage.h:39:
roscpp_core/rostime/include/ros/time.h:58:10: fatal error: 'boost/math/special_functions/round.hpp' file not found
#include <boost/math/special_functions/round.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/local/opt/llvm/bin/clang' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> tf2-py

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.`

I have reinstalled boost but that does not resolve the issue.

Best,
Markus

Windows Python 3 Error; fix available upstream?

When running with Python 3 and Windows 10, I encountered this previously-reported rospy error specific to Windows:

ros/ros_comm#1819

I see the (small) fix was merged into ros/roscomm:melodic-devel on Jan 8, 2020, but it is not available in rospypi yet because simple/roslz4/ross_comm is tagged to d93fcae, which dates from Nov 16, 2019.

Would it be possible to advance the version, which I hope would solve this problem?

sensor_msgs: missing point_cloud2?

On recent installs of sensor_msgs, it appears the point_cloud2.py utility file is missing.

For feature parity with 'native' installs of sensor_msgs, it would be great if this could be added.

Is there a specific reason point_cloud2.py is not included in the rospypi distribution?

unable to install rospy-builder in my own project

I'd like to start building ROS message types in my own project, but when I try and install rospy-builder, I get this error:

(env) $ pip install --extra-index-url https://rospypi.github.io/simple/ rospy-builder
Looking in indexes: https://pypi.org/simple, https://rospypi.github.io/simple/
Collecting rospy-builder
  Downloading https://github.com/rospypi/simple/raw/any/rospy-builder/rospy_builder-0.5.0-py2.py3-none-any.whl (7.3 kB)
Requirement already satisfied: click in ./env/lib/python3.7/site-packages (from rospy-builder) (7.0)
Requirement already satisfied: gitpython in ./env/lib/python3.7/site-packages (from rospy-builder) (3.0.5)
Requirement already satisfied: setuptools in ./env/lib/python3.7/site-packages (from rospy-builder) (49.6.0)
Requirement already satisfied: catkin-pkg in ./env/lib/python3.7/site-packages (from rospy-builder) (0.4.22)
ERROR: Could not find a version that satisfies the requirement dataclasses<1,>=0.7 (from rospy-builder) (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
ERROR: No matching distribution found for dataclasses<1,>=0.7 (from rospy-builder)

I am running Python 3.7.8

(env) $ cat .python-version 
3.7.8

I see in my checked out copy of this repo that rospy-builder/setup.py has this code:

if sys.version_info < (3, 7):
    install_requires.append("dataclasses>=0.7,<1")

so I'm a bit confused. Is the version uploaded to pypi outdated?

Thanks!

Support for python version > 3.8

I would like to make a request for support for versions >3.8. While trying to install on python 3.11 for some packages like roslz4, tf2-py the installation fails. I would be happy to help if someone could guide on how to go about it. Thank you

import rosbag

Hi
when I run pip install --extra-index-url https://rospypi.github.io/simple/ rosbag
everything is installed but when I run the python code with import rosbag, the code falls in the loop.
Did you ever see this case?

Problems following "development of this repository"

Hello,

I am excited to use this repo, its so much better than having to use catkin or klunking around with rosbridge and roslibpy.

I wanted to make sure I was able to compile the code myself, but when I tried to follow the directions I realized two things:

  1. They don't mention you need to run git submodule update --init --recursive first - I wanted to create a PR to add it to README.md, but I'm not exactly sure where it should go.

  2. Once past that, I ran rospy-build build, but got this error:

creating dist
Creating tar archive
removing 'cv_bridge-1.13.0.post0' (and everything under it)
copy
usage:  [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or:  --help [cmd1 cmd2 ...]
   or:  --help-commands
   or:  cmd --help

error: invalid command 'bdist_wheel'

Any thoughts on that? Also, I'm just wondering, how does this project track different ros-releases, melodic/noetic/etc?

Thanks, looking forward to using this project!

ros_comm/rosbag on Windows

Following the instructions on Windows (7 in this case, but I don't believe that matters) and installing rosbag leads to import errors complaining about Cryptodome and gnupg. Somehow pip did not pick up on those being needed.

Installing them (using pip install pycryptodomex gnupg made things work.

(note: installing pycryptodome is not enough, as it doesn't place the module/package in the expected directory)

ImportError: DLL load failed: The specified module could not be found (when import tf2_ros)

On Windows 10, Python 3.7.6, amd64, after installing tf2_ros (pip install --extra-index-url https://rospypi.github.io/simple/ tf2_ros), I get the following error when trying to run import tf2_ros


(venv) C:\>python -c "import tf2_ros"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\venv\lib\site-packages\tf2_ros\__init__.py", line 38, in <module>
    from tf2_py import *
  File "C:\venv\lib\site-packages\tf2_py\__init__.py", line 38, in <module>
    from ._tf2 import *
ImportError: DLL load failed: The specified module could not be found.

I didn't have this error on another laptop (with the same specs) so I'm puzzled why this error occurs.
Thanks!

tf2_sensor_msgs support

Hey great asset to have, I'm currently installing the whl files onto our cluster for bag file processing.

How hard would it be to add the tf2_sensor_msgs to rospy simple?

send rospy-build genmsg to a different directory

if I have a folder structure like this:

repo/foo_msgs
  +-msg/
  +-package.xml

and I run the following from repo/:

rospy-build genmsg foo_msgs/

I end up with the following directory structure, which seems counter intuitive to me:

repo/foo_msgs
  +-foo_msgs/
       +-msg/
       +-__init__.py
  +-msg/
  +-package.xml
  +-setup.py

I'm not a python packaging or ROS expert, but interleaving the output with the source directory seems really confusing to me.

Is there a best practice so I can get the generated/nested foo_msg/ folder somewhere where I can easily import it in my code just like std_msg?

Release packages from master branch

Currently binary packages are released to rospypi.github.io/simple only when a new tag is added to this repository.
It may be useful that binary packages are also released to rospy.github.io/simple/_pre(or something that is not the main path), when the master branch is updated so that users can try the pre-released packages easily.

Collaboration with RoboStack project?

Hi there,

This project looks very interesting, great work! I just came across it by chance. Do you happen to know our RoboStack project? It offers ROS packages based on Conda, so similar to your project you can install ROS packages in a conda virtual environment. It would be great to have a chat if/how we can join forces :).

Best, Tobias

/cc @wolfv @traversaro

How to open a rosbag stream

Hey,

I have a rosbag as BytesIO and would like to make a Bag object out of it.
In bag.py it says

        @param f: filename of bag to open or a stream to read from
        @type  f: str or file

which needs to satisfy isinstance(f, io.IOBase), but when i pass the BytesIO object i get:

Traceback (most recent call last):
  File "/home/zft-jr19f/Zft/workspace/control-station/venv/lib/python3.8/site-packages/rosbag/bag.py", line 1433, in _open
    if 'b' not in self._file.mode and not isinstance('', bytes):
AttributeError: '_io.BytesIO' object has no attribute 'mode'

Minimal example would be:

from io import BytesIO
import rosbag

f = open("some_bag.bag", "rb")
data = BytesIO(f.read())
bag = rosbag.Bag(data)

What kind of object am I supposed to pass to rosbag.Bag() to make this work? Right now I'm saving the ByteIO object first and then read it in again via filename,

with open(filename, "wb") as f:
    f.write(data.read())
bag = rosbag.Bag(filename)

which works, but I'd like to skip the file saving step.

Thanks!

win10 python3 error?

Hi:
I install rosbag in win10 with "pip install --extra-index-url https://rospypi.github.io/simple rospy rosbag". It can be installed in win10, anaconda.
Then when I use the command "import rosbag", I get the error "AttributeError: module 'socketserver' has no attribute 'ForkingMixIn'".
So I want to know this package can run in win10?

Thank you very much.

tcpros_base.py:160: too many values to unpack

With a Python 3.8.5 venv and rospy installed from rospypi, termination of scripts can result in the following traceback:

Traceback (most recent call last):
  File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\...\venv_rospypi\lib\site-packages\rospy\impl\tcpros_base.py", line 160, in run
    (e_errno, msg) = e.args
ValueError: too many values to unpack (expected 2)

On that system, e.args is actually a 3-tuple: errno, function, msg. Upstream rospy seems to handle that (from here):

except IOError as e:
    (e_errno, msg, *_) = e.args

(although I don't believe msg will actually contain the message in that case)

This was fixed in ros/ros_comm#2050 in rospy.

Is that not included in the rospy distributed by rospypi?

libpython ImportError when importing PyKDL in Python 3.7, 3.6 with Conda env

Thanks for setting this up! It's been super helpful to have lightweight ROS options.

I'm trying to install PyKDL in Conda environments using Python 3.7 and Python 3.6 with

pip install --extra-index-url https://rospypi.github.io/simple/_pre PyKDL

which runs fine, but then I get:

>>> import PyKDL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/trevor/anaconda3/envs/py37-test/lib/python3.7/site-packages/PyKDL/__init__.py", line 1, in <module>
    from .PyKDL import *
ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

I've found three ways to resolve this at the moment, but I don't think any of them actually address the issue:

  1. Using a Conda environment with Python 3.8, the error doesn't occur. Might be related to https://docs.python.org/3/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build.
  2. Modifying LD_LIBRARY_PATH to include ~/anaconda3/envs/py37-test/lib before running any code.
  3. Cloning the package and building from source with python setup.py bdist_wheel, then installing the wheel file with pip install dist/PyKDL-1.4.post2-cp37-cp37m-linux_x86_64.whl.

I'm not sure if this is possible to easily fix, or even worth fixing, but I figured for anyone else who's attempting to use Conda and python 3.6/3.7, it might be helpful to see their options.

"No matching distribution found for sip<5.0.0 (from PyKDL->tf2_geometry_msgs)"

On Windows 10, Python 3.8.3 amd64, I get the following error when trying to install tf2_geometry_msgs:

(venv_rospy38) C:\Users\user>pip install --extra-index-url https://rospypi.github.io/simple/ tf2_geometry_msgs
Looking in indexes: https://pypi.org/simple, https://rospypi.github.io/simple/
Collecting tf2_geometry_msgs
  Using cached https://github.com/rospypi/simple/raw/any/tf2-geometry-msgs/tf2_geometry_msgs-0.6.5.post0-py2.py3-none-any.whl (3.2 kB)
Requirement already satisfied: geometry-msgs in c:\users\user\venv_rospy38\lib\site-packages (from tf2_geometry_msgs) (1.13.0)
Collecting PyKDL
  Using cached https://github.com/rospypi/simple/raw/Windows_3.8/pykdl/PyKDL-1.4.post1-cp38-cp38-win_amd64.whl (295 kB)
Requirement already satisfied: tf2-ros in c:\users\user\venv_rospy38\lib\site-packages (from tf2_geometry_msgs) (0.6.5)
Requirement already satisfied: rospy in c:\users\user\venv_rospy38\lib\site-packages (from tf2_geometry_msgs) (1.15.7)
Requirement already satisfied: genpy<2000 in c:\users\user\venv_rospy38\lib\site-packages (from geometry-msgs->tf2_geometry_msgs) (0.6.12)
ERROR: Could not find a version that satisfies the requirement sip<5.0.0 (from PyKDL->tf2_geometry_msgs) (from versions: 5.0.0, 5.0.1, 5.1.0, 5.1.1, 5.1.2, 5.2.0, 5.3.0)
ERROR: No matching distribution found for sip<5.0.0 (from PyKDL->tf2_geometry_msgs)

Trying pip install "sip<5.0.0" fails with a similar error.

Is this a Python 3.8 problem?


Edit: forgot to say: 💯 🍶 👍. This project has made running the odd Python publishers/subscribers/service server on a Windows machine so much more convenient.

Is it possible to start a roscore using rospypi from Python code?

First of all, I admire the project! I was wondering whether it is possible to start a roscore from code using rospypi.
This is possible using standard rospy (taken from https://answers.ros.org/question/215600/how-can-i-run-roscore-from-python/):

import roslaunch
uuid = roslaunch.rlutil.get_or_generate_uuid(options_runid=None, options_wait_for_master=False)
roslaunch.configure_logging(uuid)
launch = roslaunch.parent.ROSLaunchParent(uuid, roslaunch_files=[], is_core=True)
launch.start()
#  --- your code ---
launch.shutdown()

Is something similar also possible using rospypi?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.