Hello. I have created node (in python) that publishes messages nav_msgs/Odometry. In my CoppeliaSim model there is child script for receiving this messages:
function atlans_callback(msg)
local t = simROS.getTime()
if file_sub~=nil then
file_sub:write(tostring(t)..' '..tostring(msg.header.stamp)..'\n')
end
end
function sysCall_init()
local SUBSCRIBE_FILE_NAME = '/path/to/file/subscribe.txt'
atlans_subscriber = simROS.subscribe('/atlans/odometry', 'nav_msgs/Odometry', 'atlans_callback', 1)
simROS.subscriberTreatUInt8ArrayAsString(atlans_subscriber)
file_sub = io.open(SUBSCRIBE_FILE_NAME,'w')
end
function sysCall_cleanup()
if file_sub ~= nil then
file_sub:close()
end
end
The frequency the node publishes messages is 100 Hz. I expect the differences of neaby entries in the file to be about 0.01. But the value jumps from 1E-4 to 0.05. What is the cause of this problem?
Hi, fferri. Sorry for my stupidity. The frequency of callback function calling is interesting for me (simROS.getTime()). I wrote a Python node that subscribing to the topic. The problem remained. The frequency of receiving messages is several times less than 100 Hz. As I understand it, the problem is described in https://stackoverflow.com/questions/408 ... g-messages. Its solution is that the tcp_nodelay parameter in the rospy.Subscriber constructor have to be set to True. However, this parameter is not present in the ROS plugin for Coppeliasim.
but I don't think that is going to make a difference, as -according to ROS documentation- the tcpNoDelay hint only affects the latency of the connection.
Also, your target rate of 100Hz depends on how heavy the simulation it is, as ros::spinOnce is called in the main simulation loop (in the instancepass event).