rossubscriber with callback missing messages
2 views (last 30 days)
Show older comments
I'm using a rossubscriber to interface a C++ simulator with an algorithm written in Matlab. At each time step of the simulations I'm publishing a custom navigation message from ten different entities to one topic which I would like Matlab to parse for a separate navigation algorithm. Despite a very large buffer size or running the simulator very slowly, the ros subscriber will miss many of the messages from some entities while not missing others.
For example, in 23 messages from ten entities, my subscriber and call back recorded; 23, 14, 18, 15, 16, 18, 18, 19, 18, 23 messages. Is there something I'm missing to get the subscriber to read and parse all of the messages?
rosinit('XX.XX.XX.XX')
global Messages;
Messages = [];
global splineFits;
num_entitiez = 10;
splineFits = [];
for ii = 1:num_entitiez
splineFit.ID = ii;
splineFit.Time = [];
splineFit.ECEF = [];
splineFit.Vel = [];
splineFit.Quat = [];
splineFit.RotVel = [];
splineFits = [splineFits; splineFit];
end
sub = rossubscriber('/Sim_State_msg','navigation_msgs/StateECEFWithCovariance',@navigationMessageReader,"BufferSize",1000000);
function navigationMessageReader(~,message,~)
global splineFits;
global Messages;
Messages = [Messages; message];
Time = message.Header.Stamp.Sec + message.Header.Stamp.Nsec/1000000000;
X = message.Pose.Pose.Position.X;
Y = message.Pose.Pose.Position.Y;
Z = message.Pose.Pose.Position.Z;
vX = message.Twist.Twist.Linear.X;
vY = message.Twist.Twist.Linear.Y;
vZ = message.Twist.Twist.Linear.Z;
qX = message.Pose.Pose.Orientation.X;
qY = message.Pose.Pose.Orientation.Y;
qZ = message.Pose.Pose.Orientation.Z;
qW = message.Pose.Pose.Orientation.W;
vR = message.Twist.Twist.Angular.X;
vP = message.Twist.Twist.Angular.Y;
vY = message.Twist.Twist.Angular.Z;
ID = str2double(message.Header.FrameId);
splineFits(ID).Time = [splineFits(ID).Time;Time];
splineFits(ID).ECEF = [splineFits(ID).ECEF;X Y Z];
splineFits(ID).Vel = [splineFits(ID).Vel;vX vY vZ];
splineFits(ID).Quat = [splineFits(ID).Quat;qX qY qZ qW];
splineFits(ID).RotVel = [splineFits(ID).RotVel;vR vP vY];
end
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Specialized Messages in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!