can't install rosbag package
Ubuntu 16.04 LTS Xenial ROS Kinetic
Linux novice, ROS novice.
Have a catkin workspace with some packages in it (robot_localization etc).
import rosbag
gives error
import error: no module named rosbag
so tried installing:
sudo apt-get update
sudo apt-get install python-rosbag
get error:
p@t:~$ sudo apt-get install python-rosbag
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python-rosbag : Depends: python-roslib but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
What should I do? How do i fix the import error?
Edit I'm sorry. I've been at this for months now. I didn't study for this. Frustration is making me go crazy.
$ which python returns "/usr/bin/python" now. I assume this is what it's supposed to be? $ grep -i anaconda /home/pieter/.bashrc returns "grep: /home/pieter.bashrc: No such file or directory" if that's still relevant
$ ~/folderimworkingin python file.py now returns with error ending in
File "/opt/ros/kinetic/lib/python2.7/dist-packages/genmsg/msg_loader.py", line 83, in get_msg_file
% (base_type, package, search_path), base_type, package, search_path)
genmsg.msg_loader.MsgNotFound: Cannot locate message [Header]: unknown package [std_msgs] on search path [{}]
So am I missing a message package now or?
Edit
pieter@turing:~/benchmarking$ rospack find std_msgs
/opt/ros/kinetic/share/std_msgs
Seems reasonable.
>>> import std_msgs
>>>
does not complain.
Python --version
returns 2.7.12 now (instead of 2.7.14).
File.py:
#import numpy as np
#import scipy.io
from bag import get_topic_data
testfile = "/home/pieter/benchmarking/bagfiles/2018-03-03-11-13-48.bag"
testdata = get_topic_data(testfile,"/android/imu")
#size = len(testdata)
#print(size)
with bag.py:
import rosbag
def get_topic_data(bagFile, topic):
all_msg = []
# Initialize rosbag object
bag = rosbag.Bag(bagFile)
for topic, msg, t in bag.read_messages(topics=[topic]):
all_msg = np.append(all_msg, msg)
return all_msg
bag file I think is accessible?:
https://github.com/PieterVanB/bagfile
I sympathise with you, but please refrain from making these types of comments.
@OperationCrossbow: did fixing the bag fix the issues you were having with your script?
@gvdhoorn installed the bagfixer, did catkin_make. source bashed, new terminal. says can't find "fix_bag_msg_def.py" even though it's executable and in the same folder as the input bag. But i'm googlin'.
It's not a catkin package, so
catkin_make
is not needed.You only need to clone the repository, go to the directory where your bag is and then do something like:
That's it.
[...] is the other args.
Btw: to run programs/scripts in the current directory, always prefix the name of the script or program with
./
. Otherwisebash
will not be able to find the program (unless it's on the path).@OperationCrossbow: any luck?
@gvdhoorn pieter@turing:~/benchmarking/bagfiles$ /catkin_ws/src/rosbag_fixer/fix_bag_msg_def.py --use-local-defs 2018-03-03-11-13-48.bag out.bag
returns: bash: /catkin_ws/src/rosbag_fixer/fix_bag_msg_def.py: No such file or directory
What am I missing?
You're specifying an absolute path. That starts at the root of your file system and looks for a directory
catkin_ws
in the root, instead of in your home directory. That won't work.You can either prefix with the path to ..