Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all 475 articles
Browse latest View live

How do I write a C++ code to record variable location of robot in rosbag file?

$
0
0
I have written a code to record in rosbag file. But if the rosbag file starts, then the robot does not move because of sequential way of code. Here is that part of code : i=system("rosbag record -a"); while(ros::ok()) { //Declares the message to be sent geometry_msgs::Twist msg; msg.linear.x=3; msg.angular.z=-0.3; //Publish the message pub.publish(msg); //Delays until it is time to send another message rate.sleep(); } I need to record in rosbag file while simultaneously moving the robot, then after sometime close the file. How to do that?

Access specific message in rosbag file

$
0
0
I can get all the messages in my `rosbag` file through this loop: BOOST_FOREACH(rosbag::MessageInstance const m, view) { //... } My `rosbag` file is a record of images from the Kinect. And I'm trying to get the images from it. Knowing the size of rosbag, how could I use `rosbag::MessageInstance` and `view` to get a specific message (or image) without going through all the messages. EDIT: I did a "mecanical" solution but I don't really like it: I ask the user to choose a number which will correspond to his message (image) knowing the size of the rosbag file. then I run `BOOST_FOREACH` loop till I get to the message and extract it.

How to send rosbag file to server?

$
0
0
I am working on Gazebo 2.2.2 with two robots in an Gazebo environment. One of them is server while another is client. I need to send the rosbag file recorded by client to server so that server can do computations based on the data of the file. How do I send .bag file to the server? If not .bag file, then can I send .txt file from client to server? I am using ROS Indigo on Ubunut 14.04.

Writing a rosbag in MATLAB

$
0
0
Hi Everyone, I'm trying read a rosbag it into MATLAB, create a new topic based on the messages in the bag then write all of the messages out (including those from the old bag file) to a new bag file. I am able to accomplish reading of the bag file using the following [MATLAB toolkit](http://www.mathworks.com/hardware-support/robot-operating-system.html?requestedDomain=www.mathworks.com). But this toolkit does not appear to support writing rosbags. My questions are as follows. 1. Is anyone aware of a MATLAB tool that would allow me to write message to a rosbag in MATLAB? 2. I'm considering trying to write my own robag writer in MATLAB is there any reason that this would be a bad idea? My apologies for repeating [this](http://answers.ros.org/question/222225/how-to-write-to-a-ros-bag-in-matlab/) question but there weren't any answers with useful information. Thanks, ~ John

Message Serialization for Rosbags

$
0
0
Hi Everyone, My ultimate goal, is to read read a rosbag it into MATLAB, create a new topic based on the messages in the bag then write all of the messages out (including those from the old bag file) to a new bag file. After some searching I am unable to find any support for writing to a rosbag in the [MATLAB Toolkit](http://www.mathworks.com/hardware-support/robot-operating-system.html?requestedDomain=www.mathworks.com). I'm considering writing my own ros bag writer and I've found the following that I believe will help. 1. [Rosbag format documentation](http://wiki.ros.org/Bags/Format/2.0) 2. [Java library for rosbags](https://bitbucket.org/aaron_sims/jrosbag/src/9af69489db72fa785eaa11834322075ef87c6d78?at=master) (jrosbag) that seems to handle all of the details of indexes and chunks etc. Using jrosbag I think I can write out the bag messages as long as I am able to convert the MATLAB version of the messages into properly serialized binary. My questions are as follows... - How are are the various ros messages serialized? the rosbag format documentation doesn't give this information, and I haven't been able to find any documentation on the wiki. - Does this seem reasonable, are there any reasons this approach wouldn't allow me to add new topics to a rosbag? Thanks, ~ John

Issue extracting images from bagfile

$
0
0
I recorded a bagfile which contains rgb and depth images: path: kinectrgbdepthnew.bag version: 2.0 duration: 6.7s start: Jun 23 2016 14:55:41.10 (1466686541.10) end: Jun 23 2016 14:55:47.85 (1466686547.85) size: 395.9 MB messages: 386 compression: none [386/386 chunks] types: sensor_msgs/Image [060021388200f6f0f447d0fcd9c64743] topics: /camera/depth/image 193 msgs : sensor_msgs/Image /camera/rgb/image_raw 193 msgs : sensor_msgs/Image But when I try to extract the rgb images I don't get all the images, it stops for this example at frame0062.jpg and if I keep openni2 running it starts saving images in live from frame0063.. [ INFO] [1466686708.317537964]: Saved image frame0062.jpg [rosbag-1] process has finished cleanly log file: /home/jros/.ros/log/977b5f76-3941-11e6-8b71-5c260a35b6aa/rosbag-1*.log [ INFO] [1466686708.452904753]: Saved image frame0063.jpg I don't know why it doesn't save all the frames and why it starting color stream automatically

extracting depth image from .bag file

$
0
0
I want to extract depth image from .bag file just like [the tutorial](http://answers.ros.org/question/9652/extracting-images-from-rosbag/). But when I run `$ roslaunch export.launch` , the error occurred as below: SUMMARY ======== PARAMETERS * /rosdistro * /rosversion NODES / extract (image_view/extract_images) rosbag (rosbag/play) ROS_MASTER_URI=http://localhost:11311 core service [/rosout] found process[rosbag-1]: started with pid [9394] process[extract-2]: started with pid [9405] [ INFO] [1413444044.771603283]: Initialized sec per frame to 0.100000 [ERROR] [1413444046.270973202]: Client [/extract] wants topic /camera/depth/disparity to have datatype/md5sum [sensor_msgs/Image/060021388200f6f0f447d0fcd9c64743], but our version has [stereo_msgs/DisparityImage/04a177815f75271039fa21f16acad8c9]. Dropping connection. pls help me to resolve it.Thanks.

Extract a topic from bag file and save it to another bag file

$
0
0
Hi to all, I have a *.bag file which contains different topics and I would like to extract only a specific topic and record it in a new bag file. Is it possible? I've read about a solution which enable users to extract a topic and save its content in a CSV file, but the problem is that I need to have another *.bag file and not CSV. Is there any solution? Thank you!!

save file in different directory - launch file

$
0
0
That's my launch file. I want to change the directory where the `rosbag` file is saved, with `cwd` I have only choice between node and home `cwd="ROS_HOME|node"` I have to record a very big file with thousands of images from depth and rgb. So i want to save the `rosbag` file in a different location.

Problem with bag file

$
0
0
hii, I wrote a bagfile . when i do rosbag info i do get the topic list but the duration is zero sec.The start and end time are same. Here is the info listed path: record.bag version: 2.0 **duration: 0.0s** start: Jan 01 1970 05:53:37.58 (1417.58) end: Jan 01 1970 05:53:37.58 (1417.58) size: 3.8 GB messages: 20883 compression: none [1887/1887 chunks] types: geometry_msgs/PoseStamped [d3812c3cbc69362b77dc0b19b345f8f5] sensor_msgs/PointCloud2 [1158d486dd51d683ce2f1be655c3c181] topics: /gps_pose 7125 msgs : geometry_msgs/PoseStamped /lidar_2d 3028 msgs : sensor_msgs/PointCloud2 /lidar_3d 1886 msgs : sensor_msgs/PointCloud2 /lidar_four_plane_scanner_layer1 2211 msgs : sensor_msgs/PointCloud2 /lidar_four_plane_scanner_layer2 2211 msgs : sensor_msgs/PointCloud2 /lidar_four_plane_scanner_layer3 2211 msgs : sensor_msgs/PointCloud2 /lidar_four_plane_scanner_layer4 2211 msgs : sensor_msgs/PointCloud2 I wrote the rosbag file using rosbag class . Why is this error can anyone help me out.

How to deal with deleted message types in bag migration?

$
0
0
I have a bag with a topic that is no longer used, which uses a type which is no longer used. `rosbag check` will interpret this as a moved message type, and prompt me to enter the new location of the message type. If instead of moving this message type, I just want to ignore this message type, is there a way to do this? I realize I could use `rosbag filter` if necessary to remove this topic beforehand, but if there's another solution that doesn't involve creating an extra bag in the middle, I'd prefer that solution.

Problems with rosbag file containing the Russian letter.

$
0
0
Hello, when you try to open rosbag file containing Russian letters I receive an error: File "/opt/ros/jade/lib/python2.7/dist-packages/genpy/dynamic.py", line 168, in generate_dynamic tmp_file.file.write(full_text.encode()) nicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 5900: ordinal not in range(128) The code is taken from the standard sampl to rosbag api: import rosbag bag = rosbag.Bag('mission_2016-03-01-11-44-34.bag') cnt = 0 for topic, msg, t in bag.read_messages(): print(msg) bag.close() Is it possible to solve this problem without changing the ROS files?

jade - rosbag play with remap

$
0
0
Hi, I would like to play a bag file with rosbag and remap the topics (e.g.: /myTopic:=/playback/myTopic). I tried with **launch file**: `` and from **command line** also ( rosbag play mybag.bag /myTopic:=/playback/myTopic ) The play starts without any error with both ways, I can see a new topic: myNamespace/clock (or /clock if I start it from command line), but all of the recorded topics are replayed on their original name (e.g. /myTopic) (and the replay is working, I can see it changes the values), so I guess, the remap is not really working or am I missing something? According to the documentation I saw, this should be possible, but I am not sure it is still working in the jade release. Thanks in advance! Balint

Using change_camera_info.py to change camera info distortion params in rosbag

$
0
0
Howdy folks I have logged some RGB and Depth images from a ZED camera in a rosbag, along with the camera info messages. I didn't save the point clouds as this was making the bagfiles too big. Instead, I replay my bagfiles and make use of the depth_image_proc nodlets to construct the point cloud. Unfortunately I noticed that my cloud geometry is warped and I suspect that that I have been using an incorrect distortion model. ***Question 1*: Does the depth_image_proc/point_cloud_xyzrgb nodelet take the distortion model into account when constructing the point clouds from the depth image and the camera info data?** Assuming that the distortion model is used for generating the point clouds, then I would like to somehow update my bagfiles with the new distortion model. When searching for an existing tool to achieve this, I found ***change_camera_info.py*** in bag tools :http://wiki.ros.org/bag_tools. ***Question 2*: I am a C++ ROS programmer, and I don't have experience with using Python in ROS. Can someone please explain to me how I would need to use change_camera_info.py . How does the replacement YAML input file have to look like?** Thanks in advance Galto

Writing a ROS command-line utility in C++ - what is the difference compared to writing a ROS node in C++ ?

$
0
0
Howdy folks So far I have written ROS nodes in C++ and invoked them in launch files. Now I want to write a ROS command-line utility for off-line processing rosbag files in C++ (using the rosbag C++ API), which doesn't interact with any other nodes per se. More in particular I want to write a utility that looks for camera_info messages in a given bagfile and change camera calibration and distortion parameters. **My question is: Do I write a command-line utility just like I would write a node in C++, within the catkin build framework? What's different between writing a utility and writing a node in C++? Does anyone know of a good C++ example that I can learn from?** Thanks in advance Galto

Rewriting a message into a new rosbag

$
0
0
I have a rosbag that publishes the paths of a robot only once. I am writing a plugin to visualize it, so I want to rewrite the message again and again into my new rosbag. Below is the code, I am not sure if it is right, because my new rosbag doesn't publish it in constant fashion. import rosbag import random with rosbag.Bag('Plugin.bag', 'w') as outbag: for topic, msg, t in rosbag.Bag('2016-07-18-16-06-32.bag').read_messages(): if topic == "/input/path_manager/path" and msg.header: msg.header.frame_id = "map" msg.name="path"+ str(random.randrange(1,200)) outbag.write(topic, msg, t) if topic == "/tf" and msg.transforms: outbag.write(topic, msg, t)

Discrepancy in topic displayed Hz

$
0
0
Hi, I've run in a strange situation. I've recorded in a rosbag a topic with should be publish at 100 Hz. When playing back the bag with command-line instruction rosbag play, the topic is shown to be publish at 100.0 Hz (either by rostopic hz or by rqt topic_monitor). However, when I verify the callback rate of a subscriber subscribed to this topic, I get a much lower freq, around 20.0 Hz. Now for the interesting part. When I open the same bag with rqt_bag and visually validate the message reception rate, I find the rate to be actually 20.0 Hz. Furthermore, if I play the bag from rqt_bag, the rate displayed is 20.0 Hz. My question would be, why the displayed rate is incorrect with rosbag play?

change the string message of one of my topics to a float in rosbag

$
0
0
Hi, I will like to change the string message of one of my topics to a float in rosbag so i could be able to plot it in rqt_plot since rqt_plot doesnt support string

rosbag 'UnicodeDecodeError'

$
0
0
I have some rosbags. Most of them seem to be okay according to 'rosbag check '. But a few of them cause the check to be aborted in the middle of the bag with the error below. What is the best way to avoid this decoding error? Traceback (most recent call last): File "/opt/ros/indigo/bin/rosbag", line 35, in rosbag.rosbagmain() File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/rosbag_main.py", line 863, in rosbagmain cmds[cmd](argv[2:]) File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/rosbag_main.py", line 452, in check_cmd migrations = checkbag(mm, args[0]) File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/migration.py", line 76, in checkbag for topic, msg, t in bag.read_messages(raw=True): File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/bag.py", line 2331, 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 2469, in seek_and_read_message_data_record msg_type = _get_message_type(connection_info) File "/opt/ros/indigo/lib/python2.7/dist-packages/rosbag/bag.py", line 1565, in _get_message_type message_type = genpy.dynamic.generate_dynamic(info.datatype, info.msg_def)[info.datatype] File "/opt/ros/indigo/lib/python2.7/dist-packages/genpy/dynamic.py", line 168, in generate_dynamic tmp_file.file.write(full_text.encode()) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2788: ordinal not in range(128)

Access next element in topics from rosbag C++ API

$
0
0
Hi, I have bagfiles with a bunch of different topics (that are synchronized). I would like to access the next element from each of those topics to perform some operations on them. And this would go on in a loop until the end of the bag file. The [C++ API example](http://wiki.ros.org/rosbag/Code%20API#CA-f1c26e1c040572c3b8f12eae457dcc7484e9f089_1) just shows how to iterate over _all_ the messages from _all_ the topics and therefore needs another check to find out which topic the message came from. Is there a way to process a bunch of topics, but individually. Also, I'm not sure of the purpose of the rosbag View class. Is this the only way to access the messages? Thank you.
Viewing all 475 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>