Mar 23, 2012 at 12:00pm UTC
i'm trying to access the x, y, z values in a vector.
the driver of the sensor sets things up like this...
cloud2_.height = height_;
cloud2_.width = width_;
cloud2_.fields.resize (5);
cloud2_.fields[0].name = "x";
cloud2_.fields[1].name = "y";
cloud2_.fields[2].name = "z";
cloud2_.fields[3].name = "rgb";
cloud2_.fields[4].name = "intensity";
'cout << cloudName->height' will give me the height value, same with 'width'
but how can i get the value for x y or z?
'cout << cloudName->fields[0]' will show a bunch of stuff but not the actual value?
any ideas?
Mar 23, 2012 at 12:09pm UTC
How about:
cout << cloudName->fields[0].name
Mar 23, 2012 at 12:10pm UTC
have you tried cloudName->x?
Mar 23, 2012 at 12:25pm UTC
cout << cloudName->fields[0].name
returns 'x'
cloudName->x
returns 'error: no member named x'
thanks for the suggestions! keep em' coming :)
Mar 23, 2012 at 12:26pm UTC
I thought that's what you wanted it to return. 'x'.
Last edited on Mar 23, 2012 at 12:28pm UTC
Mar 23, 2012 at 12:46pm UTC
yes, correct but i want the value not just the letter.
just like if i put cloudName->height, it returns 160 or whatever the height is.
Mar 23, 2012 at 12:48pm UTC
But "x" is a string value belonging to the element name . x is not an element itself. There isn't an element named x that stores a value.
Mar 23, 2012 at 5:06pm UTC
You need to look for the type of the elements contained in fields.
Presumably, fields[x] contain other data members than just a name, or they wouldn't be particularly useful. I would guess one of those other data members is what you want to be accessing.