Hello,
I am quite new to ROS. I have a logfile (format: .pcapng) and I want to write a node which receives the logged udp-packets (as a simulation; later, the node should receive these packets from a CAN). My problem is the following: I know how to write a subscriber-node, but how can I make the file publishing the packets (as messages) to a topic?
I have read something about ROS bags, but I am not sure whether they are the way to go. I would prefer some kind of programm with which I could play the file, so that I simply had to write the subscriber node.
Thanks!
↧
Publish to topic from file
↧
Unable to open rosbag files in C++
Hello,
I am trying to write a node to edit the timestamps in a bag file, using C++. The code I have written is attached below. I have tried to follow the template given in the rosbag C++ API, but I am unable to open any of the bag files I have, even though they run perfectly well when I play them back using rosbag play. Specifically, I am seeing the error message
terminate called after throwing an instance of 'rosbag::BagIOException'
what(): Error opening file: ~/catkin_ws/src/publish_text/launch/filtered.bag
I am not quite sure why exactly this is happening. Would greatly appreciate it if anyone had any suggestions!
Thanks. (Code from the main function of my code enclosed below)
ros::init(argc, argv, "postprocessing");
ros::NodeHandle nh("~");
std::string instr, outstr;
rosbag::Bag inbag, outbag;
if (nh.getParam("input_path", instr)) {
inbag.open(instr, rosbag::bagmode::Read);
} else {
ROS_ERROR("No input path provided, terminating\n");
exit(1);
}
if (!nh.getParam("output_path", outstr)) {
outbag.open(outstr, rosbag::bagmode::Write);
} else {
ROS_ERROR("No output path provided, terminating\n");
exit(1);
}
↧
↧
How to write to a ROS-bag in MATLAB?
Hello all,
I am new to using ROS at my university. What I would like to do seems simple: I would like to open a ROS bag in MATLAB, (which I can already do thanks to using https://github.com/bcharrow/matlab_rosbag).
After opening a bag, I would like to simply manipulate its contents, and then write/save it to a new ROS bag, in MATLAB.
Is there a way to do this simply? Thank you in advance.
FWIW I have access to MATLAB 2014 and 2015.
↧
Giving a directory to output file in a launcher. for (rosbag record and rostopic echo)
Hi,
I have been working by now in ROS by the command line and I have just started to work with launch files.
Some nodes I want to run are rosbag (record) and rostopic (echo). I have been finding templates of launchers for these nodes, that i have found useful. But the problem is that in both nodes (rosbag record and rostopic echo) we create output files, and i havent found a way to specify the output file directory.
Examples:
1)rosbag record launch:
2)rostopic echo launch
Question: Is there any way for any of them (rosbag record or rostopic echo) that you know for specify the output file directory??
For example in rosbag play we can specify the input file directory with:
in this example the input file directory is specified by "/home/user/Escritorio/main_bags/" and the filename by "2013-04-13-02-36-11.bag", I want to specify the directory too when I use output files not only when I use input. Could you please help me in any case rosbag record or rostopic echo (to a output file) if you know how to?
Thank you very much,
Pablo Payno
Error when introducing tags: #launch #roslaunch #rosbag #rostopic #rosbag_record #rostopic_echo #output #directory #output_directory #specify_directory #rosbag_output #rostopic_output
↧
Improving the speed of ros-python script
The python script that I'm running becomes significantly slower when I try to write images and data using cv2.imwrite(twice-for raw image and segmented images) and numpy.savetxt respectively.
The other possibility I explored was to publish the images using ros and save it into a rosbag file and extract the images later using image_view. However after this process, quite a few images were missing ( I tried to save the images simultaneously using cv2,imwrite for just processed images).
Please let me know if you have leads as to how to solve this problem.
-P
cv2.imwrite(raw_img_name,cv_image_orig);
np.savetxt(depth_data_raw, depth_image_raw)
cv2.imwrite(crop_img_name, crop_img);
# Publishing the cropped image to the Jetson
msg = Image()
msg.encoding = 'bgr8'
msg.height = crop_img.shape[0]
msg.width = crop_img.shape[1]
msg.step = crop_img.shape[1] * 3
msg.data = crop_img.tostring()
self.pub_seg.publish(msg)
↧
↧
active bag file
when i record a bag file , i need to end the record by myself with ctrl C.
this create a bag file with .active. i can't succeed to open it with rxbag.i tried rosbag reindex and that make a copy of that file which i also can't open with rxbag. how can i record a proper bag files?
↧
does rosbag guarantee data will be published correctly everytime ?
Assume i have a bag file and run it multiple times. In those times, is the data the same ? ( i mean is there any data lost?)
↧
Renaming a topic inside a bag file
When we record a bag file for example X.bag and it contains the topic data /a_topic
Is there any way to rename the topics name inside the X.bag /a_topic to /b_topic?
Best regards..
↧
Why is Python rosbag crashing?
I'm trying to read a ROS bag file to convert it's values.
I'm using the rosbag Python API.
I don't understand why the reading crashes at the end:
-0.262920607691 0.447809595374 -0.39638550589 -3.14159265357 0.726601225435 -2.87867204592
-0.265034838048 0.436386356356 -0.412905936714 -3.14159265357 0.721504033644 -2.87655781556
Traceback (most recent call last):
File "rosbag_read_write.py", line 20, in
for topic, msg, t in bag.read_messages(topics=['/joint_states']):
File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/bag.py", line 2329, in read_messages
yield self.seek_and_read_message_data_record((entry.chunk_pos, entry.offset), raw)
File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/bag.py", line 2459, in seek_and_read_message_data_record
raise ROSBagFormatException('Expecting OP_MSG_DATA, got %d' % op)
rosbag.bag.ROSBagFormatException: Expecting OP_MSG_DATA, got 6
Here is my script:
import sys
import rosbag
from ttk import *
from Tkinter import Tk
from tkFileDialog import askopenfilename
from tkFileDialog import asksaveasfile
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename(filetypes = ( ("ROS bag", "*.bag"),("All files", "*.*") ) )
print(filename)
bag = rosbag.Bag(filename)
topics = bag.get_type_and_topic_info()[1].keys()
types = []
for i in range(0,len(bag.get_type_and_topic_info()[1].values())):
types.append(bag.get_type_and_topic_info()[1].values()[i][0])
print types
for topic, msg, t in bag.read_messages(topics=['/joint_states']):
print msg.position[0], msg.position[1], msg.position[2], msg.position[3], msg.position[4], msg.position[5]
bag.close()
The bag file is [available here]( https://mega.nz/#!lEVjnAKZ!MBRLR6l32m4t6HUgUinUD9u2yfdh9X0hn3pNog8u1SY).
↧
↧
Convert a rosbag file to pcl?
I need to convert a 3D file which is now a rosbag file and I want it in a point cloud or any format where I can use the file in a viewing software (i.e. vectorworks).
Thanks for the assistance.
↧
ROS Bag File Point Cloud
Is their a way to open a .bag file in a application such as cloud compare, or mesh lab?
I am using a Kinect camera for mapping and I want to be able to view the 3d point cloud map created.
Thank you for your help.
P.S sorry for bad english.
Also, how do I capture one frame of a ros bag. I just one to store one frame of a point cloud scene from rviz.
↧
Read rosbag with javascript?
I'd like to use bag files as a generic output data format, but I'd also like to display text and numbers out of the bags in a javascript browser environment. It isn't necessary to handle arrays of binary data.
Is it possible to read a bag directly from javascript (using a library)?
Or what would be a good way to save data into a bag (which is easy with the rosbag api), then programmatically convert the bag to json, yaml, or less desirably a csv? It looks like from http://answers.ros.org/question/55037/is-there-a-way-to-save-all-rosbag-data-into-a-csv-or-text-file/ there are command lines to convert to csv, is there an api call to do the same thing?
↧
Can I play a rosbag to simulate data originally recorded from a remote ros master?
I have data recorded into a bag file on my "local" machine that was generated from a remote ros master. When I issue a rosbag play command on the file (which I checked and is ok), nothing happened. When I issue a rostopic echo for the data I'm looking for, I get "unable to communicate with master", which is true, I want to be able to work on the data at times when I don't have network access to the robot sensors generating it.
Is this possible? Is it possible some other way to simulate the robot? Do I need to temporarily set ros master to my local machine when I'm doing this? Or is this what Gazebo can be used for? (even though the data in the bag is relatively simple, just xyz positional data?)
Thanks
↧
↧
Is there a way to merge bag files?
I have data across multiple bag files, but I don't care about absolute timestamps, just relative time. I would like to merge the separate bag files into one bag file. For example, if I was recording images to a bag file, then later recorded more images to a different bag file, I would like to combine these bag files into a single one. Right now, I am playing them back and recording them into another bag file, but this seems clunky.
↧
Ros nodes and losing WIFI connection
We have a mobile device (an Odroid) with a camera that runs a ROS node that publishes the camera data. We interface the device by SSHing into it via its WiFi dongle. We want to record a dataset while moving outdoors, i.e. where the device loses its WiFi connection.
We try do this the following way:
ssh odroid@[odroid ip]
screen
roscore &
roslaunch my_pkg camera_node.launch
[ctrl-A, d] # detach the screen
screen
rosbag record /my_camera_topics
[ctrl-A, d] # detach the screen
[ctrl-D] # close SSH session
When we return to the WiFi area, we reconnect to the device via SSH, which has automatically re-established the network connection. We see both screens open and attaching to them shows that both the camera node and the rosbag recroding are still going on.
The problem is that the recording is incomplete. The rosbag simply ends at a point which we assume to coincide with the moment the device lost the network connection.
The ROS_IP environment variable is set to the (static) IP this device has, but the problem persists if ROS_IP is left unset.
How can we record complete datasets in this kind of scenario?
↧
segfault when reading rosbag
Hi all,
I'm trying to parse a rosbag file. According to the guide here, I wrote something like this:
rosbag::Bag bag;
std::vector topics;
std::cout << "Opening " << filename_ << std::endl;
bag.open(filename_.c_str(), rosbag::bagmode::Read);
std::cout << "Mode: " << bag.getMode() << std::endl;
topics.push_back(std::string("/Imu"));
topics.push_back(std::string("/joint_states"));
rosbag::View view(bag, rosbag::TopicQuery(topics));
foreach(rosbag::MessageInstance const m, view) {
std::cout << "Found message of type " << m.getDataType() << std::endl;
if(m.getDataType().compare("sensor_msgs/Imu") == 0) {
sensor_msgs::ImuConstPtr s = m.instantiate();
cout << "S = " << s << std::endl;
double ax = s->linear_acceleration.x;
}
The address printed by S is not NULL, but when I reach the last line to get the data, I get a SEGFAULT.
↧
How to display bag file in rviz
Hi all, I am new on ROS and Linux. I am trying to display point cloud using rviz with VLP-16. Before starting to see real time data, I wanted to see how pcap file can be converted into human-readable, and visible data. So I used pcap file (downloaded from www.velodynelidar.com) to convert to bag file as follows:
$ rosrun velodyne_driver velodyne_node _mol:=VLP16 _pcap:=/home/soowon/Documents/County_Fair.pcap _read_once:=true
On new terminal, to record pcap data into bag file:
$ rosrun rosbag record -O Countyfair.bag /velodyne_packets
ON new terminal, I used rosbag to play bag file that I just made:
$ rosbag play Countyfair.bag
Another new terminal, to open rviz:
$ rosrun rviz rviz
Problem starts from here.
1. I cannot see anything on the screen, even though I added PointCloud, PointCloud2. In rviz, it says "No tf data. Actual error: Fixed Frame [map] does not exist."
2. Not only that I want to see point cloud in rviz, my ultimate goal is acquiring xyz coordinates for each frame. Can you guys tell me where can I find this data?
Any advice? I would appreciate :)
↧
↧
Does rosbag record --split guarantee data continuity in any way?
I've created a system that records sensor data from a few sensors. I use a python script to call a launchfile with rosbag record on the topics I want. Two of these topics are images from cameras. To record for an extended amount of time, I call `self.process_rosbag=subprocess.Popen(roslaunch record.launch)` to start the process. Then when I'm done I call `self.process_rosbag.send_signal(subprocess.signal.SIGINT)` - it's my understanding that this should allow the bags to close cleanly, on their own time. However, I still see bags remaining active when I look at my data folder.
To try and remedy this, I added "--split --size=200" to my record call, in the recording launch file.However, I still get bags closing ungracefully, and worse, I seem to be missing 15 seconds of data between every split bag part. Is there any way to ensure bags are keep recording while files are split and closed? I can't find much documentation on the split parameter and any mention of it not recording contiguous bag files. Has anyone seen this before?
↧
read single message from bag-file (c++)
Hi,I'm new to this whole ROS stuff and have a problem which I can't solve on my own.
I want to read a single message from a given bag-file using c++11. To do this I read the short tutorial and cookbook for rosbag.
I get the message with iterating over all messages in the bag. But I want to know if there is a way to direct get the specified message (data)? The topic (m.getTopic()), timestamp (m.getTime()) and the structure of the message (m.MessageDefinition()) is known.
Thanks for your help.
↧
rosbag messaged out of order
I am receiving the message shown below: does this mean the the original messages are out of order or is this an issue with the bag file messages on play back. If this is a sync issue can I just increase queue size?
1456765838.141712524 WARN [/opt/ros/indigo/include/message_filters/sync_policies/approximate_time.h:187(sync_policies::ApproximateTime::checkInterMessageBound) [topics: /rosout, /camera/depth_registered/points, /camera/standalone_nodelet/bond] Messages of type 2 arrived out of order (will print only once)
↧