Ask Your Question
0

How to receive and array of floats over a user defined message type ?

asked 2012-04-18 10:23:31 -0500

ZsurzsaLaszlo gravatar image

Example message type :


Request : //request feature's 308 variables!

float64[308] features

Response : //response Contains object type!

int64 object_type


After compiling with success all of this and the .cpp code. How do i access the float array ? There is some confusing code because the array created, that can be accessed in eclipse is like : <double, allocator<double="">>

Help needed! Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-04-18 13:29:41 -0500

Mac gravatar image

If you're in C++, the type in the C++ message object is a std::vector<double>, which is traditionally accessed using subscripting:

double x = foo[5];

edit flag offensive delete link more

Comments

2

Actually fixed length arrays are now boost::array's, not std::vector's. See http://ros.org/wiki/msg for details on the mapping between types in message files and types in client libraries.

Eric Perko gravatar image Eric Perko  ( 2012-04-18 15:01:52 -0500 )edit
3

What he said.

Mac gravatar image Mac  ( 2012-04-19 05:59:59 -0500 )edit

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2012-04-18 10:23:31 -0500

Seen: 2,655 times

Last updated: Apr 18 '12