ROS Subscribe Block - Signal Selector
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ben Isaac
am 21 Mär. 2019
Beantwortet: Ben Isaac
am 22 Mär. 2019
Hi there,
I am using ROS Subscribe block in simulink to access ROS messages from a Vicon system. I have created custom ROS messages for the Vicon markers and I can view the X,Y,Z positions online via: rostopic echo /vicon/markers. However, when I try to use a display block in Simulink to display the X,Y,Z positions, I get the error shown in the second snapshot shown below. The error suggests that I need to use a Signal Selector before using a Bus Selector. However, I am not sure what the signal indexing format is. Could you please provide some guidance? Thank you.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Cam Salzberger
am 21 Mär. 2019
Hey again, Ben,
The issue is that the Markers_ field is, presumably, an array. For a MATLAB equivalent, it'd be like if you had a structure:
s = struct('a',[struct('x', 1, 'y', 2, 'z', 3), struct('x', 4, 'y', 5, 'z', 6)])
And then tried to do:
>> s.a.x
ans =
1
ans =
4
MATLAB can handle this because it just gives out multiple answers. Simulink cannot because it expects a strict structure (pun intended) to its signals. What you've tried to do, and is the correct thing to do, is to pick out the array field, pick out which elements you want, then pick out the fields you want to display from there. See attached image for an illustration.
This is similar to doing s.a(1).x in MATLAB. If you need to get this into an array, it's a bit more troublesome. There are some tips for working with arrays of buses in the documentation. You might also consider passing it into a MATLAB function block to operate on. Alternatively, if you just want to quickly check that your data is coming in appropriately, consider the Simulink Data Inspector, which can handle arrays of buses.
-Cam
0 Kommentare
Siehe auch
Kategorien
Mehr zu Specialized Messages finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!