the cloud doesnt move in z axis [closed]

asked 2012-03-16 12:41:50 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

hi I'm getting a pcl with a laser, but the cloud does not move in the z axis.

I made ​​a concatenation of data and the broadcaster TF shipping displacement z.

Annex the code of the cloud.

#include <ros/ros.h>
#include <tf/transform_broadcaster.h>

double c=0;

void transformada()

  static tf::TransformBroadcaster br;
  tf::Transform transform;
  transform.setOrigin( tf::Vector3(0, 0, c) );
  transform.setRotation( tf::Quaternion(1, 0, 0, 0) );
  br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "world", "laser"));

int main(int argc, char** argv)
  ros::init(argc, argv, "my_tf_broadcaster");
  ros::NodeHandle node;

  while (ros::ok())
  return 0;

#include <stdio.h>
#include <fstream>
#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <laser_geometry/laser_geometry.h>

#include <pcl_ros/point_cloud.h>
#include <pcl_ros/transforms.h>
#include <pcl_ros/impl/transforms.hpp>
#include <tf/transform_listener.h>
#include <pcl/io/pcd_io.h>

ros::Publisher publicador;
laser_geometry::LaserProjection projector_;
pcl::PointCloud<pcl::PointXYZ>::Ptr nubespcl (new pcl::PointCloud<pcl::PointXYZ>);
//pcl::PointCloud<pcl::PointXYZ> nubespcl;
tf::TransformListener *listener_;

void escaneo (const sensor_msgs::LaserScan::ConstPtr& scan_in)
    sensor_msgs::PointCloud2::Ptr nubemsg(new sensor_msgs::PointCloud2);
    //sensor_msgs::PointCloud2 nubemsg;
    pcl::PointCloud<pcl::PointXYZ>::Ptr nubepcl (new pcl::PointCloud<pcl::PointXYZ>);
    pcl::fromROSMsg (*nubemsg,*nubepcl);
    *nubespcl +=*nubepcl;

int main(int argc, char **argv)
    ros::init(argc, argv, "nube_de_puntos");
    ros::NodeHandle n;
    std::string toplector = n.resolveName("scan");
    uint32_t size = 20;
    std::string top_nube_pub = n.resolveName("ptos_nube");
    publicador = n.advertise<sensor_msgs::PointCloud2>(top_nube_pub, size);
    listener_=new tf::TransformListener();
    ros::Subscriber sub = n.subscribe<sensor_msgs::LaserScan>(toplector, size, escaneo);

    delete listener_;
    pcl::io::savePCDFileASCII ("/home/andres/ros_workspace/nube.pcd",*nubespcl);
    return 0;
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2012-10-21 12:17:57


What do you mean by "The cloud does not move in the Z axis"? Can you give a screenshot, or some more details?

Mac gravatar image Mac  ( 2012-08-27 12:08:28 -0500 )edit