Gustavo,<div><br></div><div><br></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr>

<td valign="top" style="font:inherit"><p style="margin-bottom:0in"><font face="Times New Roman, serif">I
am having some problems receiving messages.</font></p>
<p style="margin-bottom:0in"><font face="Times New Roman, serif">The
idea is to implement an EKF using data from odometry, gps, laser scan
and row detection.</font></p>
<p style="margin-bottom:0in"><font face="Times New Roman, serif">These
messages are recorded in bags, with frequencies of 45, 95, 75 and 15
Hz, respectively.</font></p>
<p style="margin-bottom:0in"><font face="Times New Roman, serif">The
first strange thing noticed is that, using subscribers queue size = 1
and spinOnce() with  loop_rate.sleep() of 1 KHz, I am missing about
50% of the messages recorded in the bags. It is strange, because the
total frequency of the messages in the bags is 230 Hz, and the code
is running at 1 KHz.</font></p></td></tr></tbody></table></blockquote><div><br></div><div>When you care about receiving all the messages sent to a topic, you should always use a buffer size > 1.   If you only care about the last message received, a buffer size of 1 is great.  In your testcase, even when you set the desired rate to 1kHz, there is no guarantee that your buffer won't fill up and drop messages. Your average rate could reach 1 kHz, but the actual times when your buffer is serviced can vary greatly.</div>

<div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">

<p style="margin-bottom:0in"><font face="Times New Roman, serif">After
it, I started to receive all the messages. But looking to the screen,
it is possible to see that the different type messages are arriving
out of time order.  ROS processes the entire queue of one message
type before starting to process the others. This could be the reason
for receiving messages in wrong order. But even looking to the first
message of each block type, the time stamps are still out of order.</font></p></td></tr></tbody></table></blockquote><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">
<p style="margin-bottom:0in"><font face="Times New Roman, serif">I
tried different things, like spin() with multi threads and the
approximate time message filter, and I am still receiving the
messages out of order. My last try was to store all the messages in a
single bag, and run the code in
</font><a href="http://www.ros.org/wiki/rosbag/Cookbook" target="_blank">http://www.ros.org/wiki/rosbag/Cookbook</a><font face="Times New Roman, serif">
to order the messages in the bag to match the timestamps. The results
got much better, but I am still receiving some messages out of time
order.</font></p>
<p style="margin-bottom:0in"><span class="Apple-style-span" style="font-family: 'Times New Roman', serif; ">Is
ROS supposed to work like this? Do you have any suggestion to solve
these problems?</span></p></td></tr></tbody></table></blockquote><div><br></div><div>Yes, this is the way ROS works. When you receive messages from different sources, there is no guarantee in which order you will receive/process them. I do believe though that messages from a single source should arrive in order.  Is that not the case?</div>

<div><br></div><div>The robot_pose_ekf package solves a problem very similar to the one you're trying to solve.  In the robot pose ekf we use an internal buffer to store incoming messages from different sources.  The buffer temporary stores messages while you're waiting until you received a message from all your sources up to a certain timestamp. The robot pose ekf uses a tf Transformer as its buffer. First of all the Transformer nicely deals with keeping a fixed time history, but more importantly the Transformer also takes care of interpolation between data with different timestamps.  When running an EKF, you probably want data from all your sources at one and the same timestamp, but all sources have their own timestamps and are not synchronized. So you'll need some kind of interpolation. To use the Transformer, you'll have to convert all your data to 6D Poses though.</div>

<div><br></div><div>Hope this helps,</div><div><br></div><div>Wim</div><div><br></div><div><br></div><div> </div></div><br>-- <br>--<br>Wim Meeussen<br>Willow Garage Inc.<br><<a href="http://www.willowgarage.com">http://www.willowgarage.com</a>)<br>


</div>