ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
As a workaround, I decided to implement a timeshift
node which shifts the timestamp to the current hour. Here is the complete Python code and my ueyecam
launch file:
timeshift.py:
#!/usr/bin/env python
import rospy
import sys
from sensor_msgs.msg import Image
import numpy as np
def callback(data):
rospy.loginfo("Handling message from %s", data.header.stamp)
data.header.stamp += rospy.Duration.from_sec(np.round((rospy.Time.now() - data.header.stamp).to_sec() / 3600.0) * 3600.0)
pub.publish(data)
if __name__ == "__main__":
if len(sys.argv) < 3:
raise Exception("Usage: %s input_topic output_topic" % sys.argv[0])
rospy.init_node("timeshift")
pub = rospy.Publisher(sys.argv[2], Image, queue_size=1)
rospy.Subscriber(sys.argv[1], Image, callback, queue_size=1)
rospy.spin()
ueyecam.launch:
<launch>
<arg name="camname" />
<node pkg="nodelet" type="nodelet" name="nodelet_manager" args="manager" />
<node pkg="nodelet" type="nodelet" name="$(arg camname)" args="load ueye_cam/ueye_cam_nodelet nodelet_manager">
<param name="camera_name" value="$(arg camname)" />
<param name="image_width" value="1600" />
<param name="image_height" value="1200" />
<param name="frame_name" value="$(arg camname)" />
<param name="camera_intrinsics_file" value="$(find camera)/launch/$(arg camname).yaml" />
<param name="frame_rate" value="15" />
<param name="exposure" value="10" />
<remap from="~/image_raw" to="~/image_raw_old" />
</node>
<node pkg="camera" type="timeshift.py" name="timeshift" args="/$(arg camname)/image_raw_old /$(arg camname)/image_raw" />
</launch>
2 | No.2 Revision |
As a workaround, I decided to implement a timeshift
node which shifts the timestamp to the current hour. Here is the complete Python code and my ueyecam
launch file:
timeshift.py:
#!/usr/bin/env python
import rospy
import sys
from sensor_msgs.msg import Image
import numpy as np
def callback(data):
rospy.loginfo("Handling message from %s", data.header.stamp)
data.header.stamp += rospy.Duration.from_sec(np.round((rospy.Time.now() - data.header.stamp).to_sec() / 3600.0) * 3600.0)
pub.publish(data)
if __name__ == "__main__":
if len(sys.argv) < 3:
raise Exception("Usage: %s input_topic output_topic" % sys.argv[0])
rospy.init_node("timeshift")
pub = rospy.Publisher(sys.argv[2], Image, queue_size=1)
rospy.Subscriber(sys.argv[1], Image, callback, queue_size=1)
rospy.spin()
ueyecam.launch:
<launch>
<arg name="camname" />
<node pkg="nodelet" type="nodelet" name="nodelet_manager" args="manager" />
<node pkg="nodelet" type="nodelet" name="$(arg camname)" args="load ueye_cam/ueye_cam_nodelet nodelet_manager">
<param name="camera_name" value="$(arg camname)" />
<param name="image_width" value="1600" />
<param name="image_height" value="1200" />
<param name="frame_name" value="$(arg camname)" />
<param name="camera_intrinsics_file" value="$(find camera)/launch/$(arg camname).yaml" />
<param name="frame_rate" value="15" />
<param name="exposure" value="10" />
<remap from="~/image_raw" to="~/image_raw_old" />
</node>
<node pkg="camera" type="timeshift.py" name="timeshift" args="/$(arg camname)/image_raw_old /$(arg camname)/image_raw" />
</launch>