在 Python 3 中导入 Rosbag [英] Importing Rosbag in Python 3

查看:193
本文介绍了在 Python 3 中导入 Rosbag的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 Python 3 中读取 rosbag 文件.
我安装了 ROS2 (Eloquent Elusor),它应该支持 Python 3.

I'm trying to read rosbag files from Python 3.
I installed ROS2 (Eloquent Elusor), which should support Python 3.

当我跑步时

import rosbag
bag = rosbag.Bag('test.bag')

从 Python 2.7 开始,它可以工作.
当我在 Python 3 中尝试相同时,我得到:

from Python 2.7, it works.
When I try the same in Python 3, I get:

ModuleNotFoundError: No module named 'rosbag'

我也尝试过:sudo apt install python-rosbagsudo apt install python3-rospkgpip3 install rospkg,但它们没有帮助.

I also tried things like: sudo apt install python-rosbag, sudo apt install python3-rospkg and pip3 install rospkg, but they don't help.

我应该怎么做才能从 Python 3 打开 rosbag 文件?

What should I do to open a rosbag file from Python 3?


这是调用pip3 install rospkg后的输出:

Requirement already satisfied: rospkg in ./rosbag-env/lib/python3.6/site-packages
Requirement already satisfied: catkin-pkg in ./rosbag-env/lib/python3.6/site-packages (from rospkg)
Requirement already satisfied: distro in ./rosbag-env/lib/python3.6/site-packages (from rospkg)
Requirement already satisfied: PyYAML in ./rosbag-env/lib/python3.6/site-packages (from rospkg)
Requirement already satisfied: pyparsing in ./rosbag-env/lib/python3.6/site-packages (from catkin-pkg->rospkg)
Requirement already satisfied: python-dateutil in ./rosbag-env/lib/python3.6/site-packages (from catkin-pkg->rospkg)
Requirement already satisfied: docutils in ./rosbag-env/lib/python3.6/site-packages (from catkin-pkg->rospkg)
Requirement already satisfied: six>=1.5 in ./rosbag-env/lib/python3.6/site-packages (from python-dateutil->catkin-pkg->rospkg)

推荐答案

我写了一个纯 python3 模块来导入 rosbag 数据.它是独立的 - 无需安装 ROS.它仅适用于选定的消息类型子集,但它应该作为一个示例,您可以按照该示例解压您感兴趣的消息类型:https://github.com/event-driven-robotics/importRosbag

I've written a pure python3 module for importing rosbag data. It's standalone - no ROS installation required. It only works for a selected subset of the message types but it should serve as an example which you can follow to unpack the message types that you're interested in: https://github.com/event-driven-robotics/importRosbag

这篇关于在 Python 3 中导入 Rosbag的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆