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

how to use concatenatePointCloud

$
0
0
I am publishing /tf with a tf_broadcaster node. Also I am publishing with velodyne_driver node. Then the velodyne_pointcloud Transform nodelet is suscribed to both previous topics, applies the tf to the velodyneScan data and and publishes a PointCloud2 message. I want to concatenate these PointCloud2 messages, trying to get a denser pointcloud in just one message. I guess I have to use pcl::concatenatePointCloud but I am not sure how to use it. Shall I create a node subscribing to PointCloud2 message and in the callback something like below?: accumulatedPointCloud= pcl::concatenatePointCloud (oldPointCloud, newPointCloud ) publish(accumulatedPointCloud)

pointcloud_to_laserscan returns inf in ROS indigo.

$
0
0
Hi, I am using ROS indigo under UBUNTU 14.04. I am also simulating a turtlebot equipped with kinect camera in v-rep and would like to run gmapping through ROS. Since gmapping requires laserscan data, and I can only publish pointcloud data to ROS from v-rep, I need to use pointcloud_to_laserscan package. However I haven't been successful so far, and this is what I've done so far: I can publish the simulated kinect data to ROS as sensor_msgs/PointCloud2 type on a topic called /cloud_in. This pointcloud data is being published with respect to frame_id of base_scan. I also publish some frames in my tf tree including world, base_link (the robot frame), and base_scan (the kinect frame) with the following hierarchy: world -> base_link -> base_scan Then, when I run my pointcloud_to_laserscan launch file, the laserscan data is supposed to be published on /scan topic. However, depending on what I set for the target_frame parameter in my launch file, I run into different issues. Here are the different cases: 1- If "target_frame" is not set in the launch file, then it will publish laserscan data on /scan topic with respect to the same frame_id of base_scan. If I echo the pointcloud data from /cloud_in topic, I see the frame_id to be /base_scan. If I also echo the /scan topic, its frame_id is also /base_scan. The problem in this setting is that /scan topic returns manly inf values, which is incorrect given my simulated environment. In addition, I do not get anything by running the following command: $ rosparam get /pointcloud_to_laserscan/target_frame From my understanding of similar posts on the web, this is apparently because of incorrect frame setting and transformation, so I did the following next. 2- If "target_frame" is set to base_link or world in the launch file, then nothing gets published on /scan topic. By running rqt_console, I see the following error: Transform failure: Invalid argument "/base_scan" passed to lookupTransform argument source_frame in tf2 frame_ids cannot start with a '/' like: Location:~/v-rep_ws/src/pointcloud_to_laserscan/src/pointcloud_to_laserscan_ nodelet.cpp:PointCloudToLaserScanNodelet::cloudCb:185 In this case the following command returns base_link or world depending on the launch file parameter. $ rosparam get /pointcloud_to_laserscan/target_frame 3- If "target_frame" is set to /base_link or /world in the launch file, then nothing gets published on /scan topic again. By running rqt_console, I see the following error: Transform failure: Invalid argument "/base_link" passed to lookupTransform argument target_frame in tf2 frame_ids cannot start with a '/' like: Location:~/v-rep_ws/src/pointcloud_to_laserscan/src/pointcloud_to_laserscan_ nodelet.cpp:PointCloudToLaserScanNodelet::cloudCb:185 In this case the following command returns /base_link or /world depending on the launch file parameter. $ rosparam get /pointcloud_to_laserscan/target_frame I would really appreciate any hint or help on these issues.

changing rgb values of /camera/depth_registered/points - not visible!

$
0
0
I am working on a ROS node which subscribes to /camera/depth_registered/points and convert in to a pcl::PointCloud. From there, I explicitly set the rgb values of each point (using the rgb unpacking method) in the cloud, convert the pcl::PointCloud to a ROS sensor_message::PointCloud2 (using pcl::toROSMsg(..)) and then publish the point cloud with different colors. For testing, I initially set all pixels to be green. My problem is that I don't see a green point cloud...I only see the original scene rgb values. rviz has a color transformer for PointCloud2 which I select 'rgb8' for (this shows original scene rgb values). I've tried the other options but I'll either get a grayscale version of the scene ('intensity') or a rainbow version ('axisColor') or plain white ('flatColor'). I really need to change these rgb values for visualization purposes; can anyone suggest what I might be doing wrong (or how to fix it)? thanks! brigit

PCL Pointcloud type conversion/pointer issue

$
0
0
As I want to get used to the PCL library, I tried to test switching between PointCloud and PointCloud2 types. The node corresponding to the following callback function compiles, but produces a segmentation error. The problem occurs 100% in the code fragment after `// OPTIONAL: Perform voxel filtering` provided below. It is likely due to making mistakes when converting the types or confusing pointers (kinda new to C++). Any help is appreciated. void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input) { // convert sensor_msgs to PointCloud pcl::PointCloud cloud; pcl::fromROSMsg (*input, cloud); // ////////////////////////////////////////////////////////////// // OPTIONAL: Perform voxel filtering pcl::PCLPointCloud2Ptr cloud_unfiltered; pcl::toPCLPointCloud2(cloud, *cloud_unfiltered); // LINE 29!! pcl::PCLPointCloud2ConstPtr cloudPtr(cloud_unfiltered); pcl::PCLPointCloud2 cloud_filtered; pcl::VoxelGrid sor; sor.setInputCloud (cloudPtr); sor.setLeafSize (0.1, 0.1, 0.1); sor.filter (cloud_filtered); pcl::fromPCLPointCloud2(cloud_filtered, cloud); // ///////////////////////////////////////////////////////////// **gdb backtrace:** Program received signal SIGSEGV, Segmentation fault. 0x0000000000413a36 in pcl::toPCLPointCloud2 (cloud=..., msg=...) at /usr/include/pcl-1.7/pcl/conversions.h:248 248 msg.height = cloud.height; (gdb) bt #0 0x0000000000413a36 in pcl::toPCLPointCloud2 (cloud=..., msg=...) at /usr/include/pcl-1.7/pcl/conversions.h:248 #1 0x000000000040d498 in cloud_cb (input=...) at /home/mma7rng/catkin_ws/src/pcl_planar_segmentation/src/pcl_planar_segmentation_node.cpp:29 #2 0x0000000000411b4b in operator() (a0=..., this=) at /usr/include/boost/function/function_template.hpp:767 #3 boost::detail::function::void_function_obj_invoker1> const> const&)>, void, boost::shared_ptr> const>>::invoke(boost::detail::function::function_buffer&, boost::shared_ptr> const>) (function_obj_ptr=..., a0=...) at /usr/include/boost/function/function_template.hpp:153 #4 0x00000000004168d8 in operator() (a0=..., this=0x6360b8) at /usr/include/boost/function/function_template.hpp:767 #5 ros::SubscriptionCallbackHelperT> const> const&, void>::call (this=0x6360b0, params=...) at /opt/ros/jade/include/ros/subscription_callback_helper.h:144 #6 0x00007ffff646a6b5 in ros::SubscriptionQueue::call() () from /opt/ros/jade/lib/libroscpp.so #7 0x00007ffff6424107 in ros::CallbackQueue::callOneCB(ros::CallbackQueue::TLS*) () from /opt/ros/jade/lib/libroscpp.so #8 0x00007ffff6424c33 in ros::CallbackQueue::callAvailable(ros::WallDuration) () from /opt/ros/jade/lib/libroscpp.so #9 0x00007ffff646d1e5 in ros::SingleThreadedSpinner::spin(ros::CallbackQueue*) () from /opt/ros/jade/lib/libroscpp.so #10 0x00007ffff6454e0b in ros::spin() () from /opt/ros/jade/lib/libroscpp.so #11 0x000000000040cea9 in main (argc=1, argv=0x7fffffffd948) at /home/mma7rng/catkin_ws/src/pcl_planar_segmentation/src/pcl_planar_segmentation_node.cpp:107

multiple pointcloud2 to one single laserscan

$
0
0
Hello there, I have a robot using 2 3D cámeras (both different) Astra Pro and Pico_flexx, both them get a different pointcloud output but both are pointcloud2, one of those cámeras is watching forward and the other one backwards. I am trying to get odometry and navigation with those cámeras both since one wouldn't be enough, and for that i was already using laser_scan_matcher, in the documentation says it can use pointcloud2 as an input. AMCL accepts only laserscan for navigation since it was developed for 2d navigation. So, what i tried first was pointcloud_to_laserscan with one camera which i found insufficient for the purpose (that's why 2 cameras). I need to "merge" those 2 pointclouds into one but what i found at the forums tells that both pointclouds need to have the same number of points (to concat...) Any idea what to use to either use both clouds for laser_scan_matcher, or to achive 2 pointclouds into 1 laserscan? thank you

Proper way to transform a point cloud

$
0
0
Hello, I am using V-REP to simulate a vehicle with a Velodyne. To simulate the behavior of the real Velodyne, I transform at each simulation pass the captured points to the /odom frame. This is to gather 360º data and correct the delay between samples due to the car velocity (this is what I asked in [this question](http://answers.ros.org/question/239849/how-is-tf-data-handled-by-velodyne_driver/)). Now, other members of my team, need the point cloud to be given relative to the velodyne frame (base_laser), so I just need to transform the point cloud relative to /odom to the desired target frame. My tf tree is /odom->/base_link->/base_laser and is working fine. I use Ubuntu 14.04 and ROS Indigo. The best solution I found was using the pcl_ros package and I tried doing sensor_msgs::PointCloud2 buffer_local; tf::TransformListener listener; pcl_ros::transformPointCloud("/base_laser",_buffer, buffer_local, listener); _pubVelodyne.publish(buffer_local); being **_buffer** the previous pointcloud relative to /odom. I am getting the following error: > [ERROR] [1475751606.660104363]: "base_laser" passed to lookupTransform argument target_frame does not exist. It looks like transformPointCloud calls the lookupTransform function but is unable to find the "base_laser" frame. My tf tree is correct (I've checked it with rosrun tf view_frames) and if instead of transforming it to "base_laser" I transform it to "/odom" (itself), I get the original pointcloud without errors, as expected. Where can be the error? Is the use of the TransformListener right? My pointcloud uses the timestamp of ROS, so it should be right. Another option would be using the transformPointCloud funtion with the transform directly retrieved from tf by me. Any ideas? **UPDATE 1:** I was using the TransformListener just after creating it, that's why I got that error. Now I create a listener as a class member and I get another error: > [ERROR] [1475759993.562920093]: Lookup would require extrapolation into the future. Requested time 1475759993.562353881 but the latest data is at time 1475759993.468326569, when looking up transform from frame [odom] to frame [base_laser] I understand I get this error because transformPointCloud wants to use a later transform, so I should use waitForTransform before calling transformPointCloud, right? So, if I want to use the latest transform available, I would have to manually retrieve it using listener.lookupTransform("/odom", "/base_laser", ros::Time(0), transform); and then use transformPointCloud(original_PC, transformed_PC, transform_matrix) (after converting the StampedTransform to a Transform object). **UPDATE 2:** Simply use this [pcl_ros::transformPointCloud](http://docs.ros.org/kinetic/api/pcl_ros/html/namespacepcl__ros.html#a34090d5c8739e1a31749ccf0fd807f91) definition. **UPDATE 3:** The previous only works for PointCloud data. For PointCloud2 the available definitions of pcl_ros::transformPointCloud are [these](http://docs.ros.org/indigo/api/pcl_ros/html/namespacepcl__ros.html#a29cf585a248dc53517834f4c5a1c4d69). In order to get the latest available transform, it must be done as suggested in my first Update of this question. Regards

RGB and Depth sensor_msgs::Image vs XYZRGB sensor_msgs::PointCloud2

$
0
0
Hello, So I have ROS running across multiple machines on a limited network, and I have two possibilities, transfer a XYZRGB sensor_msgs::PointCloud2 directly or two sensor_msgs::Image (one rgb and one depth) and assemble the cloud remotely from the RGBD data and the camera intrinsics. The assembled cloud is equal to the original sensor_msgs::PointCloud2, i checked. From the data I collected, I noticed that transferring two sensor_msgs::Image was 85% faster in the worst case scenario, and i dont know why. Is there any reason to why it would be faster? Thanks in advance.

pointCloud2 to pcl::pointcloud conversion

$
0
0
I am using velodyne VLP16. The information I am getting from it is "unordered" pointCloud2. I am having a trouble to translate it to pcl::pointcloud. According to the code provided online [here] (https://github.com/ros-drivers/velodyne/blob/master/velodyne_pointcloud/src/conversions/colors.cc). I can simply get the x,y, and z value of the point from pointCloud2 by using a pcl function **without giving the function any information regarding the sensor** I am using(layer no. etc). Why is this the case?

PointCloud2 access data

$
0
0
I have a PointCloud2 topic and I need to access the x, y and z of the points. I have found: pcl::PointCloud::ConstPtr The problem is that I don't know how to use it. Do you know where can I find some example code describing how to get coordinates in PCL2? [EDIT] Now, I am using this code but it is not working properly void pcl2_to_scan::callback(const sensor_msgs::PointCloud2ConstPtr &pPCL2) { for (uint j=0; j < pPCL2->height * pPCL2->width; j++){ float x = pPCL2->data[j * pPCL2->point_step + pPCL2->fields[0].offset]; float y = pPCL2->data[j * pPCL2->point_step + pPCL2->fields[1].offset]; float z = pPCL2->data[j * pPCL2->point_step + pPCL2->fields[2].offset]; // Some other operations } } Thank you.

convert VLP16 sensor_msgs/PointCloud2 to sensor_msgs/LaserScan

$
0
0
I would like to test a library that require a sensor *_msgs/LaserScan* topic. I found this question http://answers.ros.org/question/9450/how-to-setup-pointcloud_to_laserscan/ but I am pretty new to ROS and I have a lot of difficulties in adapting this solution to my case. Could you help me with this?

Track faces when Kinect is mounted sideways.

$
0
0
I've got a Kinect mounted sideways on my setup, and it needs to stay that way, and detect faces. All the libraries I've tried don't recognize a sideways face. I have a node that publishes a PointCloud2 of the depth-registered colored point cloud rotated from sideways back to right-side-up, but I haven't found a library that accepts a PointCloud2 as input for face tracking. Any suggestions? The only thing I need the library to publish is a point in 3d space at about the center of the head or face. Thanks in advance if you know of something, because that will save me from having to convert my PointCloud2 back to a disparity image just to feed it to the head tracker.

Two Topics with Same Callback

$
0
0
Hi everyone, I am subscribing to two different topics (each with different md5sums) using a single callback. I am using the `message_filters` class to achieve this. In my broadcaster, I am publishing a `point cloud` and an opencv `image`. I want to subscribe in a separate code. My callback signature looks like so: void callback(const sensor_msgs::ImageConstPtr& ensensoImage, const sensor_msgs::PointCloud2ConstPtr& ensensoCloud) { cv::Mat ir; PointCloudT cloud; getImage(ensensoImage, ir); getCloud(ensensoCloud, cloud); ROS_INFO_STREAM("cloud: " << cloud); std::lock_guard lock(mutex); this->ir = ir; this->cloud = cloud; updateImage = true; updateCloud = true; } When I run my code, however, I get an `std::terminate` as follows: ``` user@user:~/catkin_ws$ rosrun ensenso ensenso_viewer terminate called after throwing an instance of 'ros::ConflictingSubscriptionException' what(): Tried to subscribe to a topic with the same name but different md5sum as a topic that was already subscribed [sensor_msgs/PointCloud2/1158d486dd51d683ce2f1be655c3c181 vs. sensor_msgs/Image/060021388200f6f0f447d0fcd9c64743] Aborted (core dumped) ``` Is it not possible to have a callback with different classes of a namespace or am I missing something? For reference, the whole code is [here](https://github.com/lakehanne/ensenso/blob/devel/src/ensenso_viewer.cxx). I would appreciate any help. Thanks!

Sensor publish a pointcloud2 msg to ROS

$
0
0
Hey, is there any 3D LiDAR sensors in Gazebo which publish a pointcloud2 msg to ROS? thx a lot

Datatype to access pointcloud2

$
0
0
Hello all, i am working on pobot object detection project and m totally new at Ros. so far in project we have published pointclouds but can anyone tell me after subscribing to a pointcloud2 message through ros, how to access its data field ( WHERE THE ACTUAL DATA IS STORED) ROS_INFO("I heard Height[%d] Width[%d] point_step[%d] row_step[%d] data[%d] ", msg->height, msg->width, msg->point_step, msg->row_step); through this i can access height,width but what is the datatype for data field??

Put sensor_msgs::PointCloud into row of sensor_msgs::PointCloud2

$
0
0
Hey all, I am currently trying to create a function that will take a sensor_msgs::PointCloud that has 953 points in it and replace a row of a sensor_msgs::PointCloud2 that has height 36 and width 953 (we don't know if this cloud is full yet). I would like to have access of this PointCloud2 outside of my function but I just don't have the skill to do this. Here is what I have so far: void replaceRowInPointCloud2(sensor_msgs::PointCloud2 cloud2_out, sensor_msgs::PointCloud cloud_in, int row){ for (int i=0; i<954; i++){ int arrayPosition = row*cloud2_out.row_step + i*cloud2_out.point_step; int arrayPosX = arrayPosition + cloud2_out.fields[0].offset; // X has an offset of 0 int arrayPosY = arrayPosition + cloud2_out.fields[1].offset; // Y has an offset of 4 int arrayPosZ = arrayPosition + cloud2_out.fields[2].offset; // Z has an offset of 8 memcpy(&cloud2_out.data[arrayPosX],&cloud_in.points[i].x , sizeof(float)); memcpy(&cloud2_out.data[arrayPosY],&cloud_in.points[i].y , sizeof(float)); memcpy(&cloud2_out.data[arrayPosZ],&cloud_in.points[i].z , sizeof(float)); } } This code compiles but crashes immediately on first call. I would appreciate any help, tips, or suggestions. Thank you! EDIT 1: This is what I've done that compiles and runs, but never actually publishes a cloud that Rviz can view. cloud_b is a global variable so that I can just change the point values, convert to sensor_msgs, then publish at any time. I think that the ROS messages don't come across because they are invalid, but I dont know why. It's probably some sort of formatting issue. pcl::fromROSMsg(cloud2_out,cloud_a); for (int i=0;i<594;i++){ cloud_b.points[row*953+i]= cloud_a.points[i]; } pcl::toROSMsg(cloud_b,cloud2_out); EDIT 2: This is what I have now.. sensor_msgs::convertPointCloudToPointCloud2 (cloud_out, cloud2_out); cloud_pub.publish(cloud_out); pcl::fromROSMsg(cloud2_out,cloud_a); for (int i=0;i<953;i++) { cloud_b.points[posindex/5*953+i]=cloud_a.points[i]; } pcl::toROSMsg(cloud_b,cloud2_out); cloud2_pub.publish(cloud2_out); Which compiles and runs. The first time it runs, it will run for quite a long time before crashing. I suspect it crashes due to memory leaks. When I use rostopic echo on my topic, it shows a valid stream of numbers with no repeating sequences. After it crashes once, further launches of the program will run 8 runs of my callback. If i rostopic echo my topic, it will display a stream of points (many repeated sequences of points, with many zero's) from my PointCload2, and it shows as dense. When the program does not crash immediately, rviz shows no warnings. When it does crash immediately, the terminal with Rviz running also shows "Invalid argument passed to canTransform argument source_fram in tf2 frame_ids cannot be empty". How do I fix this? I can give any explanation as needed and again I appreciate any help.

how to use Velodyne VLP16 and laser_scan_matcher with cloud input?

$
0
0
I have a robot equipped with a 3D-Lidar (Velodyne VLP16) and want to use laser_scan_matcher (http://wiki.ros.org/laser_scan_matcher) to estimate it's position. The velodyne driver (http://wiki.ros.org/velodyne_pointcloud?distro=indigo) publishes *velodyne_points* (sensor_msgs/PointCloud2) which I intend to use as input for the laser_scan_matcher by setting the use_cloud_input parameter to 'true'. The following error is produced: "Invalid number of rays". After some research I found that only 10000 rays are accepted, while there are roughly ~19000 in the PointCloud2 message. Obviously, I could always use pointcloud_to_laserscan in between to get a /scan topic out of the velodyne_points and use it as input to the laser_scan_matcher. This works fine but I was hoping to get a better result for the position estimation if I use the PointCloud2 message directly. My question: is there a convenient way to adjust the number of published points in the PointCloud2 message? Or is there a way to circumvent the "number of rays" restriction? I found the two following posts with similar questions/problems, if it helps: http://answers.ros.org/question/61758/localization-just-from-imu-data/ http://answers.ros.org/question/226070/laser_datac-location/

Start with costmap_2d

$
0
0
Hello friends, looking for some tutorials from where i can create a simple occupancy grid map from pointclouds i.e. conversion of sensor_msgs/pointcloud2 to nav_msgs/occupancygrid. I found costmap_2d can be useful but don't know how to use it.

Conversion from sensor_msgs::PointCloud2 to pcl::PointCloud

$
0
0
Hi all, I am digging deep in this forum, but I'm getting lost. I am using ROS Groovy and receiving a sensor_msgs::PointCloud2 from a depth_image_proc nodelet and I want to process it using PCL 1.7. None of the solutions found in this forum are working for me, i.e., I miss some function prototype of toPCL, fromROSMsg, etc. functions. I would like to do something like: void CloudViewerPlugin::pointcloudCallback(const sensor_msgs::PointCloud2::ConstPtr& msg) { pcl::PointCloud cloud; pcl::PCLPointCloud2 pcl_pc; pcl_conversions::toPCL(*msg, pcl_pc); pcl::fromPCLPointCloud2(pcl_pc, cloud); or void CloudViewerPlugin::pointcloudCallback(const sensor_msgs::PointCloud2::ConstPtr& msg) { pcl::PointCloud cloud; pcl::fromROSMsg(*msg, cloud); but I found no function prototype to do this.

Ros publish() taking more time than expected

$
0
0
Dear All I have observed a strange behavior in my node. I am trying to publish pointcloud topic and subscribing in another node. While profiling the pointcloud node I have observed the publish() method was taking around 10ms of the time. When no one subscribing there is no delay. The delay was observed when the other node was subscribing to the topic. I have also tried to echo the topic and observe the time.I have observed around 2ms delay. Can any one explain me why this was happening and how can I minimize this overhead ? **EDIT: Adding source code** The snippet of code in the main method of the pointcloud subscribing node. In side callback I have only a print statement. `typedef sync_policies::ExactTime MySyncPolicy; message_filters::Subscriber imageCam_sub(nh,left_info_topic, 50); message_filters::Subscriber image_sub(nh, left_topic, 50); message_filters::Subscriber PC_sub(nh, topic_name, 50); Synchronizer sync(MySyncPolicy(50),PC_sub, image_sub, imageCam_sub); sync.registerCallback(boost::bind(&callback, &oD, _1, _2,_3));` Thanks in advance

node crashes after rosrun !!

$
0
0
hi guys i am doing blobdetection and tracking ,,, in ros i have implemented something using point cloud to get my x y and z ,, but while catkin_make i have no errors but after rosrun the image is not streaming ..![image description](/upfiles/14926187533410801.png) https://pastebin.com/i71RQcU2 this is my full code please help guys
Viewing all 171 articles
Browse latest View live


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