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

Bagfile (containing depth and RGB data) to picture frames

$
0
0
When I convert a bagfile (containing depth and RGB data) to picture frames, I get different number of picture frames each time I launch the code given in the tutorial given below and the subsequent video I compile is totally wayward. http://wiki.ros.org/rosbag/Tutorials/Exporting%20image%20and%20video%20data Please guide me through this

tf::TransformListener gets wrong tf

$
0
0
Hello, TL;DR tf::TransformListener gets a different transform than shown in RVIZ I am having quite a strange problem. I am using a rosbag file to playback recorded data and I am adding new transforms and using them while doing that: rosparam set use_sim_time true rosbag play 2016-09-12-14-51-41.bag --clock The transform is published with a python node, where the origin is static (defined with cfg-values) and the rotation is coming from the values of an IMU. The interesting part how the tf is published should be this (in the callback of the IMU subscription): br = tf.TransformBroadcaster() br.sendTransform((frame_offset_x, frame_offset_y, frame_offset_z), quaternion, rospy.Time.now(), frame_child, frame_parent ) With the following values: frame_offset_x = 0 frame_offset_y = 0 frame_offset_z = 1.2 quaternion = rotation of the IMU (only around the x and y axis) frame_child = level_laser_2 frame_parent = base_footprint The created Transform in RVIZ looks like expected. It's 1.2m above base_footprint with some rotation on top. In the picture, the Fixed Frame is set to "base_footprint" ![level_tf in RVIZ](/upfiles/14737549797623874.png) However if I lookup the transform in a ROS node using the tf::TransformListener I get a different result: #include #include ... tf_listener_ = new tf::TransformListener( ros::Duration(10) ); // in the constructor ... void callback( const sensor_msgs::PointCloud2Ptr& cloud_in ) { ... if ( tf_listener_->waitForTransform(tf_target_, cloud_in->header.frame_id, cloud_in->header.stamp, ros::Duration( scan_time_ )) ) { tf::StampedTransform transform; tf_listener_->lookupTransform(tf_target_, cloud_in->header.frame_id, cloud_in->header.stamp, transform); ROS_INFO("%s %s -> %s\tat%lf", node_name_.c_str(), cloud_in->header.frame_id.c_str(), tf_target_.c_str(), cloud_in->header.stamp.toSec()); tfScalar tf[16]; transform.getOpenGLMatrix(tf); ROS_INFO("%s\n" "/ %lf\t%lf\t%lf\t%lf \\\n" "| %lf\t%lf\t%lf\t%lf |\n" "| %lf\t%lf\t%lf\t%lf |\n" "\\ %lf\t%lf\t%lf\t%lf /", node_name_.c_str(), tf[0], tf[4], tf[8], tf[12], tf[1], tf[5], tf[9], tf[13], tf[2], tf[6], tf[10], tf[14], tf[3], tf[7], tf[11], tf[15]); } else { // display error here } ... } The output of this is: [ INFO] [1473756806.521699009, 1473684710.202103154]: /level_laser_velodyne: base_footprint -> level_laser_2 at1473684709.395050 [ INFO] [1473756806.521764836, 1473684710.202103154]: /level_laser_velodyne: / 0.997645 0.001908 -0.068567 0.002741 \ | 0.001908 0.998454 0.055557 -0.002221 | | 0.068567 -0.055557 0.996098 -0.039822 | \ 0.000000 0.000000 0.000000 1.000000 / But it should be something like: [ INFO] [1473756806.521764836, 1473684710.202103154]: /level_laser_velodyne: / R R R 0 \ | R R R 0 | | R R R 1.2 | \ 0 0 0 1 / Does anybody know what I am doing wrong? Thank you for your help, Tobias

Set RViz camera/view on fuerte

$
0
0
Hi, I'm writing a RViz plugin which allows the user to play rosbags and record them. During playing the rosbags I would like to make it possible to do a tracking shot in the scene. Therefore I have to set the current view in RViz. Is there a possibility to do this programmatically? There are some articles which say it is possible with a RViz plugin, but it's never explained anywhere. If it is not possible in a single plugin, is it possible via librviz? Thanks in advance, best regards, Josch. EDIT: The node should run on fuerte and Ubuntu 12.04 LTS. EDIT 2: New question: How do I get an instance from the VisualizationManager? Creating my own one requires a RenderPanel and a WindowManagerInterface-implementing class.

Logging and processing the same sensor data

$
0
0
Hi all, In my system I have a sensor that sends data via TCP/IP. This data should be logged for future processing and also used for a live computation at the same time. Since i am a newbie to ROS, I have a question concerning a good design for the situation above. Does it make sense to write a node(let) which simply opens the socket, reads the data and publishes the bytes as they come from the sensor. Then use two node(let)s to subscribe to the topic? Or better, one node reads the data, processes it and writes the data to a rosbag? What happens to this design if there are 20 sensors? Regards

The meaning of the frequency value in rosbags

$
0
0
Dear all, i downloaded a rosbag from the internet and looked at the info of this file: path: ../raw/Vehicle1_velodyne_pos.bag version: 2.0 duration: 36:10s (2170s) start: Aug 12 2015 09:22:18.17 (1439364138.17) end: Aug 12 2015 09:58:28.86 (1439366308.86) size: 23.0 MB messages: 152840 compression: none [29/29 chunks] types: tf/tfMessage [94810edda583a504dfda3829e70d7eec] topics: tf 152840 msgs @ 99.2 Hz : tf/tfMessage As you can see, the topic __tf__ have 152840 messages and after that there is the number 99.2 Hz. I computed: (end_time - start_time) / number of messages and i got ca. 70 Hz. What is the meaning of the number 99.2 Hz?

How to add message field in a rosbag

$
0
0
I got a rosbag with a number of topics being played. I am interested in adding a Header (more specifically, a frame_id) to the message received so some 3d points in it are automatically displayed in RViz in the correct frame defined. Is this possible? I know you can iterate a rosbag with the type of loop: for topic, msg, t in inbag.read_messages(): if topic == "/desired_topic": outbag.write(topic,msg.h,t) if topic not in ["/desired_topic"]: outbag.write(topic,msg,t) outbag.close() But I don't know how to add a field to the incoming message and save it in a new bag.

Understanding messages MDSum

$
0
0
I am trying to understand how the MD5Sum of the messages is being calculated following this [link](http://wiki.ros.org/ROS/Technical%20Overview#Message_serialization_and_msg_MD5_sums) So far, I undestand that a plain message like std_msgs/Header translates to: uint32 seq time stamp string frame_id And if I paste that block of text into [this online MD5Sum calculator](http://www.password-generator-tool.com/md5-hash-generator) it correctly gives me the Header hash: 2176decaecbce78abc3b96ef049fabed Now, for complex messages, the documentation states that: "*In order to catch changes that occur in embedded message types, the MD5 text is concatenated with the MD5 text of each of the embedded types, in the order that they appear.*" So, how that would translate to a message like geometry_msgs/Vector3Stamped ? I tried combinations like this: Header header Vector3 vector uint32 seq time stamp string frame_id float64 x float64 y float64 z or like this: Header header Vector3 vector 2176decaecbce78abc3b96ef049fabed 4a842b65f413084dc2b10fb484ea7f17 Also with capital letters but none gives me the correct Vector3Stamped MD5Sum of 7b324c7325e683bf02a9b14b01090ec7

rosbag dies with MemoryError

$
0
0
Hi, I'm trying to use some large bag file. rosbag command dies with following error. I tried `rosbag reindex` also dies with same error. yasu@JO7UEB-VM-ROS:/media/sf_works/dataset/EuRoC$ rosbag info MH_01_easy.bag Traceback (most recent call last): File "/opt/ros/melodic/bin/rosbag", line 35, in rosbag.rosbagmain() File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/rosbag_main.py", line 1012, in rosbagmain cmds[cmd](argv[2:]) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/rosbag_main.py", line 163, in info_cmd b = Bag(arg, 'r', skip_index=not options.freq) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 458, in __init__ self._open(f, mode, allow_unindexed) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 1415, in _open if mode == 'r': self._open_read(f, allow_unindexed) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 1443, in _open_read self._version = self._read_version() File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 1551, in _read_version version_line = self._file.readline().rstrip().decode() MemoryError How can I use my bag file? Here is my environment, - OS: Ubuntu 18.04.1 LTS - ROS version: melodic This ubuntu is running on VirtualBox on Windows 10, ThinkPad Yoga 260 Thanks.

how to let the node process rosbag twice

$
0
0
Hey everyone, Bascially, I use the rosnode to process rosbag to create my database, and I would like to feed rosbag to this node again, but the node just don't work and have the error msgs, Warning: TF_OLD_DATA ignoring data from the past for frame depth at time 727885 according to authority unknown_publisher Possible reasons are listed at http://wiki.ros.org/tf/Errors%20explained According to the link abobe : The fix for this is to send an Empty message the topic /reset_time. There is a button in rviz to do this. But I dont find it in rviz, any help here?

TF_OLD_DATA ignoring data from the past, when rosbag twice

$
0
0
Hey everyone, Bascially, I use the rosnode to process rosbag to create my database, and I would like to feed rosbag to this node again, but the node just don't work and have the error msgs, Warning: TF_OLD_DATA ignoring data from the past for frame depth at time 727885 according to authority unknown_publisher Possible reasons are listed at http://wiki.ros.org/tf/Errors%20explained According to the link abobe : The fix for this is to send an Empty message the topic /reset_time. There is a button in rviz to do this. But I dont find it in rviz, any help here?

Extracting compressed image data from bag file results in doubled up or dropped frames

$
0
0
Hi, I'm trying to extract compressed images from a bag file. Here is my launch file: This results in some frames not being saved and some frames being saves multiple times. Also a lot of frames are saved out of order so the video I make out of the frames is really choppy.

Save specific data from a rosbag into an C++ array variable.

$
0
0
Hello, Currently I am working on a project and we need to extract msgs from a topic inside a rosbag file. Our first idea was to save all the msgs of the topic into a .txt and after that process that data with C++ but there is too much data and is not the optimal solution. (rostopic echo /topic > data.txt) My question is the next: How can I extract some specific msg for an specific timestamp in C++ and save those msg into an array? After that i would like to use that array for my C++ code. PD: I have checked rosbag c++ API but I didn´t find how to do that. Thanks for your help

How to import rosbag API into an C++ Project

$
0
0
Hello to all, Currently I am working on a project and we need to extract data from a bagfile and process it. After my research i found that the [rosbag API](http://wiki.ros.org/rosbag/Code%20API) could be used for my purpose. I have a general idea of how to code what I want by using the API but my problem comes on how can import it into my project. **QUESTION: What should I do to be able to use the rosbag API in my project?** Basically i cannot `#include ` in my project so I cannot use any functionality of the API. I tried to write this in the CMakeList.txt of my C++ project in CLion but it gives an error on the compilation because it cannot find the packages. find_package(catkin REQUIRED COMPONENTS rosbag rosconsole roscpp roslib sensor_msgs std_msgs ) Is there a guide or some information about how to do it?m

ROS bags + Gazebo synchronization issue

$
0
0
Dear all, I'm having an issue currently on trying to record some ROS bags to replicate some robot movements during a Gazebo simulation. I'm starting to record the referred bags after I start my controller application who just reads keyboard inputs and publishes into a ROStopic the changes, that might happen or not depending on what key pressing is done(or not), even if there are no changes to the values advertised for this topic, their publication is still done on a fixed frequency. The problem i'm facing is that the created bag doesn't replicate this as synchronized as it should(i.e the robot starts to change his direction earlier in the simulation that what was recorded over)... I get this output from the first lines of the **rosbag play**: **[ INFO] [1544196733.072599942]: Opening 11111.bag Waiting 0.2 seconds after advertising topics... done. Hit space to toggle paused, or 's' to step. [DELAYED] Bag Time: 0.101000 Duration: 0.000000 / 189.299000 Delay: 0 [RUNNING] Bag Time: 0.101000 Duration: 0.000000 / 189.299000 [RUNNING] Bag Time: 0.101000 Duration: 0.000000 / 189.299000 [RUNNING] Bag Time: 0.101129 Duration: 0.000129 / 189.299000 [RUNNING] Bag Time: 0.200516 Duration: 0.099516 / 189.299000 [RUNNING] Bag Time: 0.300226 Duration: 0.199226 / 189.299000** What may be causing this issue? Take in mind that this synchronization issue always happens(different bags recorded and tested already) by the bag changing the topic values **earlier**(some seconds) than when they were recorded... For further needed description on the methodology I'm following for recording or related to the application that is controlling this topic publication, i'm clearly the one interested in clarifying this. Thank you. Best regards, Bruno Vieira

tf from rosbag within node

$
0
0
Hello, i recorded 40 rosbags with my mobile base moving autonomously. I just recorded the tf-topic. If i play the bag from command line i can see the model of my base in rviz. So the bags are just fine. But i want to visualize the driven path. therefor i need to get the coordinates. i do this with a tf-listener. Just fine so far. But i have to start the bags one by one from the terminal. i would prefer to run them within my node. open one bag (index 01), play it, extract coords, save coords to .txt, play next bag (index 02), .... But it seems like i don't get it. i tried the code at the end. But my problem is, that i don't subscribe to the TF-topic. I just need it for the Listener. So i don't know what to do with the normal code (see comments). So, is there a way? Or do i have to deal with all the 40 files by hand? #include "ros/ros.h" #include "geometry_msgs/PoseStamped.h" #include "tf/tf.h" #include "tf/transform_listener.h" #include "tf/transform_datatypes.h" #include #include #include #include using namespace std; int main(int argc, char **argv) { ros::init(argc, argv, "logger"); ros::NodeHandle n; ros::Rate loop_rate(10); tf::TransformListener listener; rosbag::Bag bag; bag.open("/home/......../door_2/door_01.bag", rosbag::bagmode::Read); std::vector topics; topics.push_back("/tf"); rosbag::View view(bag, rosbag::TopicQuery(topics)); while (ros::ok()) { // normally something like this is used, but i don't subscribe to any topic BOOST_FOREACH(rosbag::MessageInstance const m, view) { if (m.getTopic() == depth_cam_info) { } } // get coords (works if bag is run from terminal) geometry_msgs::PoseStamped base_pose, map_pose; base_pose.header.frame_id = "base_link"; base_pose.pose.orientation.w = 1.0; listener.transformPose("map", base_pose, map_pose); // append to file (works if bag is played from terminal) ofstream myfile; myfile.open ("/home/lukas/Desktop/coordinates.txt", std::ios_base::app); myfile << map_pose.pose.position.x << ", " << map_pose.pose.position.y << "\n"; myfile.close(); // just needed ros::spinOnce(); loop_rate.sleep(); } }

How to pass topic names as input argument in the command line terminal?

$
0
0
Hello ! I have a problem that states "Read a rosbag, to parse a topic, that is passed as an input argument" How do I pass the input argument using "rosrun" in the command line terminal? My code snippet: #include #include i #include using namespace std; void topicCallBack(const sensor_msgs::PointCloud2::ConstPtr&msg) { cout<<"Reading message of type PointCloud2\n"<
header; if(msg->width) cout<< "\nInpoint Cloud\nwidth is"<width; //THIS LINE WILL NOT WORK AS MSG IS OF TYPE POINT CLOUD if(msg->transforms.transform.translation) cout<< " reading message of type TF\n"; } int main(int argc, char **argv) { ros::init(argc, argv,"parser"); ros::NodeHandle nh; //intializing the subscriber ros::Subscriber sub = nh.subscribe("/camera/depth/points",1000, topicCallBack); ros::spin(); return 0; } Here I have given my topic name as "/camera/depth/points" which publishes the message of type sensor_msgs/PointCloud2. But in my command line terminal, if I pass the topic name as "/tf", how do I ask it to publish the message of type tf/tfMessage because the subscriber is of type PointCloud2? In total, I have three topics that publish messages of type PointCloud2, tf, odom messages. But I am not able to see, how to pass different topic names in the command line argument and publish the respective message type Thanks!

Problem getting real-time_map using hector_slam!!!

$
0
0
'Hello all, I am using Xbox360, Ros Kinetic, Ubuntu 16.04LTS I am new to ROS. I want to map an unknown enviroment using kinect. For this I am using freenect and gmapping. I have done these steps: 1. roslaunch freenect_launch freenect.launch 2. rosrun pointcloud_to_laserscan pointcloud_to_laserscan_node cloud_in:=/camera/depth/points 3. rosbag record -O mybag /scan 4. rostopic echo /scan /////////i can see scan data is available here 5. rqt_graph here is my [MY RQT_GRAPH](https://drive.google.com/open?id=1P10v22SWJYPIo_2HziGoaON2TSl-oPYk) and here is [MY FRAMES.PDF](https://drive.google.com/open?id=1wubudBvtFN2D0_AEz6lsZAdQK5L8GlLA) This is all great. But the problem is getting data from the bag file 1. roscore 2. rosparam set use_sim_time true 3. roslaunch hector_slam_launch tutorial.launch scan:=/base_scan 4. rosbag play --clock mybag.bag 5. rqt_graph here is my [MY RQT_GRAPH](https://drive.google.com/open?id=1kipWQA95MoOC9qUFm06J336YTk2kBlQa) and here is [MY FRAMES.PDF](https://drive.google.com/open?id=1XqM7RxhbN8QMM6QS84NU7Nu2MqCFDoPv) I can't see any error in RViz. But I can't see the map either. The terminal where I launch hector_slam shows the error that [ WARN] [1515990267.492285826]: No transform between frames /map and scanmatcher_frame available after 20.002855 seconds of waiting. This warning only prints once. [ INFO] [1515990270.173023564]: lookupTransform base_footprint to camera_depth_optical_frame timed out. Could not transform laser scan into base_frame. 5. rostopic pub syscommand std_msgs/String "savegeotiff" but the terminal in which tutorial.launch is running stated that [ INFO] [1515995399.174200553]: HectorSM sysMsgCallback, msg contents: savegeotiff [ INFO] [1515995399.174327483]: HectorSM Map service called [ INFO] [1515995399.194847114]: GeotiffNode: Map service called successfully [ INFO] [1515995399.222169236]: Cannot determine map extends! [ INFO] [1515995399.222222911]: Couldn't set map transform I HAVE ALSO RUN `rosrun tf view_frames` AND I NOTICED THAT `world` IS NOT CONNECTED TO `base_frame` can anyone help me with this please do post a comment if any other specifications required. Thank you in advance.....

using rosbag in callback

$
0
0
For my project I am interested in many frames of reference contained in a list called frame_list, each with Pose messages published to their own topic e.g. '*frame*_transform'. I am trying to subscribe to all of these topics and use rosbag to save the Poses as they are published. The code below creates the .bag file, but does not write any data into it even though messages are being published to the topics. Is this a good way to achieve what I want? Can anybody spot where I am going wrong? Thanks. #!/usr/bin/env python import roslib import rospy import rosbag from geometry_msgs.msg import Pose def callback(data, args): bag = rosbag.Bag('data.bag', 'w') bag.write(str(args), data) if __name__ == '__main__': if rospy.has_param('init_complete'): #check if initialisation is complete rospy.init_node('rosbag_writer') #initiate node frame_list = rospy.get_param('frame_list') #import list of frames from rosparam for frame in frame_list: rospy.Subscriber(str(frame) + '_transform', Pose, callback, frame) #check for frame transforms rospy.spin()

How to save video stream ?

$
0
0
I want to record video with a usb webcam to process it later. To do that, I found limited info. One is to use `rosbag` to save published topics. Another way is to use opencv to write video. Which method would provide a simple solution to save video ? (maybe another alternative method beyond what I said) I have a source code of`image_pub`package to publish images as following; #include #include #include #include #include int main(int argc, char **argv) { ROS_INFO("Starting image_pub ROS node...\n"); ros::init(argc, argv, "image_pub"); ros::NodeHandle nh("~"); std::string camera_topic; std::string camera_info_topic; std::string camera_info_url; std::string img_path; std::string frame_id; float pub_rate; int start_sec; bool repeat; nh.param("camera_topic", camera_topic, "/camera/image_raw"); nh.param("camera_info_topic", camera_info_topic, "/camera/camera_info"); nh.param("camera_info_url", camera_info_url, ""); nh.param("img_path", img_path, ""); nh.param("frame_id", frame_id, ""); nh.param("pub_rate", pub_rate, 30.0f); nh.param("start_sec", start_sec, 0); nh.param("repeat", repeat, false); ROS_INFO("CTopic : %s", camera_topic.c_str()); ROS_INFO("ITopic : %s", camera_info_topic.c_str()); ROS_INFO("CI URL : %s", camera_info_url.c_str()); ROS_INFO("Source : %s", img_path.c_str()); ROS_INFO("Rate : %.1f", pub_rate); ROS_INFO("Start : %d", start_sec); ROS_INFO("Repeat : %s", repeat ? "yes" : "no"); ROS_INFO("FrameID: %s", frame_id.c_str()); camera_info_manager::CameraInfoManager camera_info_manager(nh); if (camera_info_manager.validateURL(camera_info_url)) camera_info_manager.loadCameraInfo(camera_info_url); ros::Publisher img_pub = nh.advertise(camera_topic, 1); ros::Publisher info_pub = nh.advertise(camera_info_topic, 1); cv::VideoCapture vid_cap(img_path.c_str()); if (start_sec > 0) vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec); ros::Rate rate(pub_rate); while (ros::ok()) { cv::Mat img; if (!vid_cap.read(img)) { if (repeat) { vid_cap.open(img_path.c_str()); if (start_sec > 0) vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec); continue; } ROS_ERROR("Failed to capture frame."); ros::shutdown(); } else { //ROS_DEBUG("Image: %dx%dx%d, %zu, %d", img.rows, img.cols, img.channels(), img.elemSize(), img.type() == CV_8UC3); if (img.type() != CV_8UC3) img.convertTo(img, CV_8UC3); // Convert image from BGR format used by OpenCV to RGB. cv::cvtColor(img, img, CV_BGR2RGB); auto img_msg = boost::make_shared(); img_msg->header.stamp = ros::Time::now(); img_msg->header.frame_id = frame_id; img_msg->encoding = "rgb8"; img_msg->width = img.cols; img_msg->height = img.rows; img_msg->step = img_msg->width * img.channels(); auto ptr = img.ptr(0); img_msg->data = std::vector(ptr, ptr + img_msg->step * img_msg->height); img_pub.publish(img_msg); if (camera_info_manager.isCalibrated()) { auto info = boost::make_shared(camera_info_manager.getCameraInfo()); info->header = img_msg->header; info_pub.publish(info); } } ros::spinOnce(); rate.sleep(); } return 0; }

Does rosbag.write will overwrite the whole file ?

$
0
0
Nowdays I am using rosbag to save the msgs in my programs.I want to just change some of topic msgs in a saved bags, but keep the other msgs as what they once been.But when the program start, the first rosbag.read output is original saved msgs, but after the first rosbag.write is finished, the original saved msgs have been cleared, and just what the first rosbag.write write in the rosbag.I don't know how to edit the code in this, they are always Confused. what I say is for example: here is a rosbag which save a under topic A, b under topic B. Now a new process start! After call rosbag.write(c to Topic B). The rosbag only have c under topic B,and a-A is removed.Does it a bug?How can I keep the a-A still alive.
Viewing all 475 articles
Browse latest View live


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