Ask Your Question
0

PointCloud has no member named ‘serializationLength’

asked 2013-01-24 07:00:16 -0500

astrokenny gravatar image

I am trying to migrate some code from ros diamondback to ros fuerte and I am getting this compiler error:

error: ‘const PointCloud’ has no member named ‘serializationLength’

The PointCloud type it mentions is specifically a sensor_msgs::PointCloud. I am including <pcl_ros point_cloud.h=""> as some posts have suggested. What is wrong?

edit retag flag offensive close merge delete

Comments

Are you trying to reuse the same workspace in Fuerte you had previously built using Diamondback?

joq gravatar image joq  ( 2013-01-24 08:16:32 -0500 )edit

I'm not using ros workspaces.

astrokenny gravatar image astrokenny  ( 2013-01-24 09:52:45 -0500 )edit

If you're not using ROS this is the wrong forum.

tfoote gravatar image tfoote  ( 2013-01-26 14:03:54 -0500 )edit

I think he meant he is not using workspaces as in rosws. So I am reopening, as I am facing the same issue, and I am proposing a solution

brice rebsamen gravatar image brice rebsamen  ( 2013-02-01 09:32:04 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2013-02-01 10:04:21 -0500

brice rebsamen gravatar image

Here is what was working under diamondback:

void serializePointCloudROS(const sensor_msgs::PointCloud& cloud, ostream& out) {
    out << "Cloud" << endl;
    out << "serialization_length" << endl;
    out << cloud.serializationLength() << endl;
    uint8_t data[cloud.serializationLength()];
    cloud.serialize(data, 0);
    assert(sizeof(char*) == sizeof(uint8_t*));
    out.write((char*)data, cloud.serializationLength());
}

And here is what I am replacing it with in fuerte.

void serializePointCloudROS(const sensor_msgs::PointCloud& cloud, ostream& out) {
    assert(sizeof(char*) == sizeof(uint8_t*));
    uint32_t serial_size = ros::serialization::serializationLength(cloud);
    boost::shared_array<uint8_t> buffer(new uint8_t[serial_size]);
    ros::serialization::OStream stream(buffer.get(), serial_size);
    stream << cloud;

    out << "Cloud" << endl;
    out << "serialization_length" << endl;
    out << serial_size << endl;
    out.write((char*)stream.getData(), serial_size);
}

And for the deserialization, this is what I had in diamondback:

bool deserializePointCloudROS(std::istream& istrm, sensor_msgs::PointCloud* cloud) {
    string line;

    getline(istrm, line);
    if(line.compare("Cloud") != 0)
        return false;

    getline(istrm, line);
    if(line.compare("serialization_length") != 0)
        return false;

    uint32_t serialization_length = 0;
    istrm >> serialization_length;
    getline(istrm, line);

    uint8_t data[serialization_length];
    istrm.read((char*)data, serialization_length);
    cloud->deserialize(data);
    getline(istrm, line);

    return true;
}

And here is what I am replacing it with in fuerte.

bool deserializePointCloudROS(std::istream& istrm, sensor_msgs::PointCloud* cloud) {
    string line;

    getline(istrm, line);
    if(line.compare("Cloud") != 0)
        return false;

    getline(istrm, line);
    if(line.compare("serialization_length") != 0)
        return false;

    uint32_t serialization_length = 0;
    istrm >> serialization_length;
    getline(istrm, line);

    boost::shared_array<uint8_t> buffer(new uint8_t[serialization_length]);
    istrm.read((char*)buffer.get(), serialization_length);
    ros::serialization::IStream stream(buffer.get(), serialization_length);
    stream >> *cloud;
    getline(istrm, line);

    return true;
}

It compiles, but I haven't tested it yet.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-01-24 07:00:16 -0500

Seen: 924 times

Last updated: Feb 01 '13