Manage Ros Custom Message with Variable-Length array
3 次查看(过去 30 天)
显示 更早的评论
Hi
I'm trying to read a message from ROS that is structured like this
The message is called WaypointArray.msg and contains header, two booleans and an array of Waypoints
Every waypoint has the fields x and y
I'm trying to read them following the example of reading variable-length array from ros but i cannot manage to find a solution. I place a bus selector to select the Array field and the count, a selector to select the indexes and now I have a variable length array of buses. I cannot make it work with nothing, if I place another bus selector to get the X field it tells me that it cannot work with variable length buses, the same if i place a "to workspace" field.
Is there a block in simulink to select and work the fields from the array elements? What I want at the end is like a 2xN matrix with the x and y element from every waypoint
Thank you!
0 个评论
回答(1 个)
Josh Chen
2020-11-24
编辑:Josh Chen
2020-11-24
Hi Marco,
It's a bit difficult to see the full picture without a model, but if I understand correctly, you've already managed to create this custom message, receive the message in Simulink, and extract the array out through bus selector. And you are looking for a way to return this waypoint array in the message as a 2xN matrix?
If the above description sounds right, I would recommend you use a MATLAB Function block. This block gives you the flexibility to extract and postprocess the array data just as what you can do in MATLAB. This example of using MATLAB Function block with Simulink ROS messages might be helpful.
Hope this helps,
Josh
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specialized Messages 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!