HI all, I use Ubuntu 14.04 LTI with ROS Indigo. Then I simulate kinect in Gazebo:
` 20 ${60 * M_PI/180.0} R8G8B8 640 480 0.05 3 true 20 ${name}/rgb/image_raw ${name}/rgb/camera_info ${name}/depth/image_raw ${name}/depth/camera_info ${name}/depth/points 0.5 ${name}_depth_optical_frame 0.0 0.0 0.0 0.0 0.0 `
Then I convert pointcloud2 to pcl::PointXYZ
follow the link:[pcl/overview](http://wiki.ros.org/pcl/Overview)
> 3.1 For a subscriber that receives pcl::PointCloud objects directly:
**My code:**
`void callback(const pcl::PointCloud::ConstPtr& position)
{
const char *path="/home/lin/Desktop/distance.dat";
ofstream file(path);
for(int i=0; i<307200;i++)
{
cout << "(x,y,z) = " << position -> points[i] << std::endl;
file << position -> points[i];
}
}
int main(int argc, char** argv){
ros::init(argc, argv, "distance_publisher");
ros::NodeHandle nh;
std::string topic = nh.resolveName("camera/depth/points");
uint32_t queue_size = 1;
// create a templated subscriber
ros::Subscriber sub = nh.subscribe> (topic, queue_size, callback);
ros::Rate r(0.1);
while(nh.ok()){
ros::spinOnce();
r.sleep();
}
}
`
**I get lots of NAN data , I just want to know when convert pointcloud2 to pcl::PointXYZ, it will remove nan data automatically or I need to filter it.**
↧
lots of nan data when convert pointcloud2 to pcl::PointXYZ
↧
voxel_grid filter in all dimensions
I would like to filter point clouds in x, y, and z. I see from the [tutorials](http://wiki.ros.org/pcl_ros/Tutorials/filters#VoxelGrid) and [examples](http://wiki.ros.org/pcl_ros/Tutorials/VoxelGrid%20filtering) how to downsample with limits on a single axis. How can I downsample with limits on all three axes? Do I have to run three instances of voxel_grid, with one feeding into the other?
Here is an example launch file that limits in the z axis:
filter_field_name: z
filter_limit_min: 0.1
filter_limit_max: 2.0
filter_limit_negative: False
leaf_size: 0.08
↧
↧
converting velodyne packets to pointcloud
Hii,
I have velodyne packets and its config file . I want to convert it to point cloud in a C++ program. Can anyone provide me API to do this .
↧
MoveIt perception - Failed to configure updater of type PointCloudUpdater
I'm attempting to load an existing pointcloud into moveit but it keeps throwing an error. Specifically, it says "Failed to configure updater of type PointCloudUpdater"
Here's the console output immediately before the error:
Starting context monitors...
ros.moveit_ros_planning.planning_scene_monitor: Starting scene monitor
ros.moveit_ros_planning.planning_scene_monitor: Listening to '/planning_scene'
ros.moveit_ros_planning.planning_scene_monitor: Starting world geometry monitor
ros.moveit_ros_planning.planning_scene_monitor: Listening to '/collision_object' using message notifier with target frame '/base_link '
ros.moveit_ros_planning.planning_scene_monitor: Listening to '/planning_scene_world' for planning scene world geometry
ros.moveit_ros_perception: Failed to configure updater of type PointCloudUpdater
Here's my sensors.yaml file:
sensors:
- sensor_plugin: occupancy_map_monitor/PointCloudOctomapUpdater
image_topic: /cloud_pcd
max_range: 5.0
point_subsample: 1
padding_offset: 0.1
padding_scale: 1.0
filtered_cloud_topic: filtered_cloud
I load my pointcloud using the following console command:
rosrun pcl_ros pcd_to_pointcloud /home/Documents/out_pcd/processed_clouds/Scanner-2_rosbag.bag.pcd
Which publishes the pointcloud2 to the topic /cloud_pcd
Here's my sensor_manager.launch.xml:
And finally, here's vehicle_model_moveit_sensor_manager.launch.xml:
Any advice at this stage would be appreciated. I can't seem to find any record of others having this error.
↧
is there any function to convert sensor_msg::pointcloud2 to velodyne_pointcloud::PointXYZIR? I want to get the ring number
I am getting the data as a sensor_msg::pointcloud2 and then i convert them in to pcl::pointcloud to do clustering and ground plane removal and other processing. Now i am in need to access the ring number. what i thought is it would be easier if i can convert the sensor_msg::pointcloud2 to velodyne_pointcloud::PointXYZIR. which gives me the ring values of the corresponding points in the pcl::pointcloud. but i could not find any functions doing this conversion
↧
↧
Convert point cloud video to .las format
I have point cloud video and I want to convert it to .las format. Maybe there is tool for point cloud video conversion to .las 3D format? Or maybe you can give an approach for achieving that?
↧
Pointcloud2 messages and logical operations...
Hello!
I currently am writing something that I need to AND two pointclouds together, my question is, how do I go about doing such.
I already tried something similar to:
`combined_pc.data = pointcloud_a.data && pointcloud_b.data` to no avail.
Do I need to iterate through every element in "data" and AND them together, then shove it into `combined_pc.data`?
When I try this, it fails to build with this error snippet:
`error: no match for ‘operator&&’ (operand types are ‘sensor_msgs::PointCloud2_>::_data_type {aka std::vector}’ and ‘sensor_msgs::PointCloud2_>::_data_type {aka std::vector}’)
combinedPC_.data = baseframeL_.data && baseframeR_.data;
^`
Thanks in advance!
↧
PCL - coordinates from PointCloud2 message
Hey guys,
So I'm a little new to ROS, so forgive some amateurishness. I'm working with a LiDAR that publishes a topic (/Sensor/points) in the format sensor_msgs::PointCloud2. I'm trying to write a subscriber program (C++) to take this data and output the x,y,z coordinates. I'm later hoping to store these values for some analysis.
I've converted the PointCloud2 format to a PointCloud format and then, when I print points.size(), the LiDAR is outputting over 40,000 points every time the callback function is invoked. I'm assuming that these are 40,000 sets of x,y and z coordinates and I want to access these.
I've tried to do points[0] (many different numbers apart from zero as well) and all I get is (nan,nan,nan). Any help would be greatly appreciated! I've attached my code below (except the include fies).
For reference, this is ROS-Indigo on Ubuntu 14.04 LTS.
Thanks,
Rayal
void interpet(const sensor_msgs::PointCloud2 msg)
{
pcl::PointCloud msg_;
pcl::fromROSMsg(msg,msg_);
ROS_INFO_STREAM(msg_.points[0]); //index 0 because I'm not really sure what to do
}
int main(int argc, char **argv)
{
ros::init(argc,argv,"Receiver");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe("Sensor/points",1000,&interpet);
ros::spin();
}
↧
Transforming a pointcloud2 in python
I've searched and searched, but can't find a good answer to this. I'm using python so don't have access to `pcl_ros` (which seems deprecated anyway?) and other answers are all for older versions of ROS (I'm using kinetic). The `tf2_sensor_msgs` looks like it's supposed to do it, but I can't import it directly (no module found). I'm using the `tf2_ros` package with a Transform buffer and listener.
self.transform_buffer = tf2.Buffer()
self.transform_listener = tf2.TransformListener(self.transform_buffer)
# Later I try:
pointcloud = self.transform_buffer.transform(pointcloud, 'base_link')
Error:
.... File "/home/zac/mbot/ros/src/mbot_api/src/web_server.py", line 266, in get_laserscan pointcloud = ros_thread.get_velodyne_points_for_time(requested_ts) File "/home/zac/mbot/ros/src/mbot_api/src/web_server.py", line 135, in get_velodyne_points_for_time pointcloud = self.transform_buffer.transform(pointcloud, 'base_link') File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/buffer_interface.py", line 63, in transform do_transform = self.registration.get(type(object_stamped)) File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/buffer_interface.py", line 202, in get raise TypeException('Type %s if not loaded or supported'% str(key)) TypeExceptionI'm receiving a PointCloud2 message in the /velodyne frame and I want to transform it into the /base_link frame.
↧
↧
how to Transform Pointcloud2 with tf
Hi,
I tried to run the python code on this link http://answers.ros.org/question/9103/how-to-transform-pointcloud2-with-tf/ and got such an error below :
Traceback(most recent call last):
File "/home/ahmet/catkin_ws/src/laserTF/src/laserTransform.py", line 26 in module>
listener.waitForTransform("/base_link", "/odom" , rospy.Time(0),rospy.Duration(1.0))
tf.Exception: . canTransform returned after 1.00039 timeout was 1.
How to solve this problem ? Please help me this time . @jayess
↧
Accessing depth data from a pointcloud2 message
Hi all!
I want to select the depth (*z*) values of a given row from a `sensor_msgs/pointcloud2` message. I have this code so far:
for (int i = 0; i < cloud->width; i++)
{
int index = cloud->row_step*ROW_NUM + cloud->point_step*i + cloud->fields[2].offset;
memcpy(&depth_data[i], &cloud->data[index], sizeof(float));
}
However the code is probably not correct, as the values it gives don't seem to be the real ones. I chose the middle row of the pointcloud (num. 239) and put the sensor in front of the wall, so "the ray of the middle row" should be normal to the wall and so the z value should be the real distance from the wall. The result was: real distance 2m, the *z* value from the message 0.001. When I changed the row number to some other value, the *z* values were even below 0 (which is definitely not correct as I want to get the forward distances). So what am I doing wrong in my code? (I do not want to convert the ros message to a pcl structure.) Thanks in advance!
↧
Trying to understand PointCloud2 msg
Hello,
Can someone please post a clear explanation of how to understand pointcloud2 message? I want to get x,y,z point from the message and I found a solution to do that, but I am not able to understand why there are so many numbers in data field?
Can someone please explain?
Thanks.
↧
Kinect 2 mapping of 2D pixel to 3D Pointcloud2 point
Hi everyone,
I see that this is a question that has been answered a couple of times before but all the answers I have found didn't work out. So alas I'll have to ask once more.
In a ROS Nodelet I'm receiving a (approximately) synchronized dataset of 1. a message of type `sensor_msgs::Image` and 2. a message of type `sensor_msgs::PointCloud2`, both from a Kinect 2 (using `iai_kinect2` nodelets like `kinect2_bridge`).
What I'm trying to do now is to find a specific point in the PointCloud2 that corresponds to a certain pixel (u, v) in the image. I want to do it for a number of pixels one by one. I broadcast the recognized points via TF2_ROS. That works so far. I can visualize the PointCloud2 and the generated TF frames in RVIZ.
Unfortunately though, it seems that only **some** of the points that I'm searching in the PointCloud2 seem to be located correctly. Although they are correctly located in the 2D image they are not mapped to the correct points in the cloud.
I'm picking the corresponding point from the point cloud like this (kinda pseudo code, don't nail me down to syntax errors):
void incoming_callback(sensor_msgs::PointCloud2ConstPtr& pcl, sensor_msgs::ImageConstPtr& img, int u, int v) {
int point_index = u * pcl->point_step + v * pcl->row_step;
int point_idx_x = point_index + pcl->fields[0].offset;
int point_idx_y = point_index + pcl->fields[1].offset;
int point_idx_z = point_index + pcl->fields[2].offset;
float x;
float y;
float z;
memcpy(&x, &pcl->data[point_idx_x], sizeof(float));
memcpy(&y, &pcl->data[point_idx_y], sizeof(float));
memcpy(&z, &pcl->data[point_idx_z], sizeof(float));
.....
}
Where u (col) and v (row) are the coordinates of the pixel in the camera image.
I'm not sure why some of the points get mapped wrongly... maybe someone can give me some insight and/or the royal road to do this with `ROS Kinetic Kame`.
Thanks a lot!
↧
↧
how to Transform Pointcloud2 with tf
Hi,
I tried to run the python code on this link http://answers.ros.org/question/9103/how-to-transform-pointcloud2-with-tf/ and got such an error below :
Traceback(most recent call last):
File "/home/ahmet/catkin_ws/src/laserTF/src/laserTransform.py", line 26 in module>
listener.waitForTransform("/base_link", "/odom" , rospy.Time(0),rospy.Duration(1.0))
tf.Exception: . canTransform returned after 1.00039 timeout was 1.
How to solve this problem ? Please help me this time . @jayess
↧
Rviz pointcloud2 alpha/size
Hi all, Couldn't find an answer on the web, although this does not seem to me as such an exotic issue.
I know about the option to color the point cloud by according to a given field in the cloud, but is it possible in any way to change either the size or alpha of the cloud based on a field? (e.g. bigger or stronger points with higher intensity).
Many thanks to whoever can help, and also to those who can't :)
Cheers, Steve
↧
Problem reading PointCloud2 message
Hello everyone,
I'm trying to find an object by color and then get the distance to it.
However I'm having trouble reading the PointCloud2 message.
I can see through RVIZ that the topic is sending the right cloud, however when I try to read it through my code I am having some issues:
- The x,y,z are sometimes negative
- The rgb values are almost zero (6.82247660989e-39 for example).
My code for getting the RGB values of the cloud:
generator = pc2.read_points(cloud, field_names = ['rgb'], skip_nans = True)
matrix = np.empty(shape = (cloud.height, cloud.width), dtype=float)
for i, element in enumerate(generator):
print element[0] // for debugging reasons, prints a near-zero float
np.put(matrix, [[i / cloud.width, i % cloud.width]], [element[0]])
What am I doing wrong, and how can I get a matrix to use with OpenCV2?
I'm using ROS Indigo, running through Gazebo
↧
Problems reading PointCloud2 message
Hello everyone,
I'm trying to find an object by color and then get the distance to it.
However I'm having trouble reading the PointCloud2 message.
I can see through RVIZ that the topic is sending the right cloud, however when I try to read it through my code I am having some issues:
- The x,y,z are sometimes negative
- The rgb values are almost zero (6.82247660989e-39 for example).
My code for getting the RGB values of the cloud:
generator = pc2.read_points(cloud, field_names = ['rgb'], skip_nans = True)
matrix = np.empty(shape = (cloud.height, cloud.width), dtype=float)
for i, element in enumerate(generator):
print element[0] // for debugging reasons, prints a near-zero float
np.put(matrix, [[i / cloud.width, i % cloud.width]], [element[0]])
Note that the variable cloud is the PointCloud2 message recieved from the topic, and pc2 is the namespace PointCloud2.
What am I doing wrong, and how can I get a matrix to use with OpenCV2?
I'm using ROS Indigo, running through Gazebo.
Thanks in advance
↧
↧
RGB and Depth sensor_msgs::Image vs XYZRGB sensor_msgs::PointCloud2
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.
↧
can't use octomap to create a complete map
i am using octomap mapping to create a map from lidar VLP-16 PointCloud2 messages, however every time my robot moves forward, i keep loosing the previous mapping.
How could i Be able to create the whole map using octomap mapping ?
Thanks for your help :).
↧
cannot transform laser using laser_assembler
I've successfully used laser_assembler to convert laser scans to pointclouds. However, when viewing the concatenated clouds in rviz they are not de-rotated (projected) accordingly with the fixed frame I've chosen. Pictures:
initially (laser is started):

After moving the LiDAR around:

Even though octomap progresses correctly in terms of absolute position (x,y,z), it strikes out when it comes to the angles.
Launch file:
I've tried every possible combination of fixed_frame and frame_id for laser_assembler and octomap respectively, but the result is always the same, either I get a 2D or a 3D octomap that gets rotated by the laser's unprojected frame. I've even pulled in pcl_ros and modified the periodic_snapshotter to transform the resulting pointcloud but no cigar. Here is the code for your review. I tried all combinations possible for the transforms so it's nothing about that (the rest of periodict_snapshotter.cpp is the same):
// Make the service call
if (client_.call(srv)) {
tf::StampedTransform localTransform;
try {
listener_.lookupTransform("scanmatcher_frame", "map",
ros::Time(0), localTransform);
}
catch (tf::TransformException &ex)
// If the tf listener cannot find the transform, print an error and continue
{
ROS_ERROR("Error: %s", ex.what());
}
// Transform the point cloud from the map_world frame into the base_footprint frame
sensor_msgs::convertPointCloudToPointCloud2(srv.response.cloud, initialCloud2);
pcl_ros::transformPointCloud("map", localTransform, initialCloud2,
transformedCloud2);
ROS_INFO("Published Cloud with %u points",
(uint32_t)(srv.response.cloud.points.size()));
transformedCloud2.header.frame_id = "map";
pub_.publish(transformedCloud2);
}
Any ideas? I feel like I'm super closed but I just don't know what's going on.
↧