ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Your message contains an array, so you do not need to create and array your self. If you have instantiated it, it already contains the array (which for C++ is serialized as std::vector). Use it like:
parse_and_pub::Lookuptable your_msg_obj; // declare message instance
// fill lookup table
for ( /* all the values you want to add */ )
{
your_msg_obj.LuT.push_back( 12.5 /* or whatever double value */ );
// your_msg_obj.LuT is of type std::vector<double>
// just treat it like you would thread any other vector of that kind
// i. e. use .resize(), .push_back(), operator[] on it or
derive iterators on it as you like }
// and publish your message with filled look up table vector
your_publisher.publish( your_msg_obj );
2 | No.2 Revision |
Your message contains an array, so you do not need to create and array your self. If you have instantiated it, it already contains the array (which for C++ is serialized as std::vector). Use it like:
parse_and_pub::Lookuptable your_msg_obj; // declare message instance
// fill lookup table
for ( /* all the values you want to add */ )
{
your_msg_obj.LuT.push_back( 12.5 /* or whatever double value */ );
// your_msg_obj.LuT is of type std::vector<double>
// just treat it like you would thread any other vector of that kind
// i. e. use .resize(), .push_back(), operator[] on it or
or
// derive iterators on it as you like
}
}
// and publish your message with filled look up table vector
your_publisher.publish( your_msg_obj );
3 | No.3 Revision |
Your message contains an array, so you do not need to create and array your self. If you have instantiated it, it already contains the array (which for C++ is serialized as std::vector). Use it like:
parse_and_pub::Lookuptable your_msg_obj; // declare message instance
// fill lookup table
for ( /* all the values you want to add */ )
{
your_msg_obj.LuT.push_back( 12.5 /* or whatever double value */ );
// your_msg_obj.LuT is of type std::vector<double>
// just treat it like you would thread any other vector of that kind
// i. e. use .resize(), .push_back(), operator[] on it or
// derive iterators on it as you like
}
// and publish your message with filled look up table vector
your_publisher.publish( your_msg_obj );
Update for your comment:
For creating an array of msgs you can do:
std::vector<parse_and_pub::Lookuptable> your_luts;
your_luts.resize(1);
your_luts[0].LuT.push_back( 12.5 );
However, you won't be able to publish such a vector (also not if you use share_ptrs to messages). If you want to publish an arrary of such look up tables you must have another message type containing an array of your lookup tables:
Your Lookuptable.msg:
float64[] Lut
Your 2nd LookuptablesArray.msg:
parse_and_pub/Lookuptable[] look_up_tables ## array of Lookuptable.msg
Then you could create an instance of parse_and_pub::LookuptablesArray
fill that and publish that.